Expand description
The semantic_relationships derivation: the plan builders for every edge
branch behind the computed table — trace-derived service calls (with
virtual-node edges for unmatched clients), agent calls from span
structure, same-row co-declared edges, and the declared-edge union. Shared
expression helpers and the entity registry live in the parent module.
Structs§
- Calls
Source - A trace table’s scan paired with the entity declarations its derivations
key on — a unit of
build_relationships_plan. Theservicedeclaration feeds service calls, theagentdeclaration agent calls; the two are independent, so a table whose service declaration is unusable still derives agent edges (and vice versa). - CoDeclared
Source - A declaring table’s scan paired with its entity declarations, from which
the same-row co-declaration rules derive edges.
is_tracegates the agent-edge vocabulary, which the RFC ties to span structure. - Declared
Source - The declared-edge table’s scan (
semantic_relationships_declared), whose rowsbuild_relationships_planunions into the edge set. - Relationship
Sources - Everything
build_relationships_planderives edges from.
Constants§
- CHILD_
SPAN_ 🔒EARLY_ NANOS - A child server span starts no earlier than 5 minutes before its client span (clock-skew allowance) and no later than 1 hour after it; the bounds keep the join windowed instead of pairing arbitrarily distant spans of a long-lived trace.
- CHILD_
SPAN_ 🔒LATE_ NANOS - CO_
DECLARED_ 🔒VALID_ COLUMN - DECLARED_
REVISION_ 🔒COLUMN - Ranking column used to pick the latest declared-edge revision per edge key.
- RELATIONSHIP_
COLUMNS 🔒 - The projected columns of
semantic_relationships, in order. Every derived branch and the declared-edge branch must project exactly these so the top-levelUNION ALLtype-aligns;build_relationships_planre-selects them over the union to enforce the contract. (The physical declared table additionally storesvalid_from/valid_until, which feed the validity filter and the projected window columns.) - VIRTUAL_
NODE_ 🔒CONFIDENCE - Confidence of a virtual-node edge: the peer was named by a client-side
attribute, not witnessed by a server span (the RFC requires
< 1.0).
Functions§
- agent_
calls_ 🔒branch - The
parent_agent calls agentderivation over trace tables declaring anagententity: pair each span with its child span (no span-kind filter — agent spans are typically INTERNAL) across all agent-declaring tables, keep pairs whose agent identities differ, and aggregate RED metrics per 60s window. Anchored like the service derivation on the caller: the parent side is bounded to the source window and stampsobserved_at, the child side widens by the time-proximity allowance and supplies status/duration. - build_
relationships_ plan - Builds the
semantic_relationshipsplan: the service-calls, agent-calls, co-declared, and declared-edge branches unioned and re-projected to the 18-column contract. ReturnsNonewhen no source can contribute edges, so the computed table streams empty. - builtin 🔒
- The embedded conventions, with a broken file surfaced as a plan error.
- calls_
branch 🔒 - The
callsderivation: union the client spans and the server spans of all trace tables (each projected to a normalized shape with its own table’sserviceidentity), left-join clients to their child server spans ontrace_id+parent_span_id, and aggregate RED metrics per 60s window — the plan form of the Tempo servicegraph connector. Unioning spans before the join pairs a client with a server stored in a different trace table (x-greptime-trace-table-namerouting); with a single table it degenerates to the previous self-join. ReturnsNonewhen no trace table has a usableservicedeclaration. - client_
spans 🔒 (timestamp, trace_id, span_id, src_id, status_code, duration_nano, virtual_dst, virtual_conn).src_idis built from the table’sservicedeclaration, so edges land on exactly the entity ids the registry emits (a composite identity renders the same sortedk=vform); the per-table projection is what lets tables with different declarations union.- co_
declared_ 🔒branch - The same-row co-declared branch: for each source table, every vocabulary
pair whose two entity types the table declares yields an edge projection,
expanded from one scan via
unnest_rows(the registry idiom). Attribute edges carryprovenance = 'attribute'; agent edges are span-structure observations and carryprovenance = 'trace'. - declared_
edges 🔒 - The declared-edge branch: the latest revision per edge key as of the
queried window (mito dedups on primary key +
observed_at, so re-asserting an edge stores a new revision), filtered by business-validity overlap. - duration_
nano_ 🔒expr - One trace table’s client spans, normalized to
A trace table’s
duration_nanois UInt64 on tables created before the signed-integer ingest change and Int64 after it. The per-table selects are unioned, and those two have no common integer type. - real_
wins 🔒 CASE WHEN has_pair THEN real ELSE virtual END— the real-wins projection over the mixed aggregate.- server_
spans 🔒 - One trace table’s server spans, normalized to
(timestamp, trace_id, parent_span_id, dst_id, status_code, duration_nano). - span_
predicate 🔒 - The window + span-kind + identity predicate shared by both join sides.
strictbounds the scan to the source window; the non-strict side widens by the join’s time-proximity allowance (the join bounds reference the other side’s timestamp and cannot prune this side’s scan on their own). - virtual_
attrs_ 🔒expr - The
attributesJSON of a virtual edge, from the aggregatedconnection_type.