Documentation
¶
Overview ¶
Package trace reads distributed-tracing exports and reduces them to the few facts GraphLume can line up against the static graph: which endpoints were really called, which functions really ran, which tables were really touched, and how long each took.
What this is, and what it deliberately is not ¶
It is a READER, not a tracing system.
It does not sample. Sampling is a decision the producer already made, before these bytes existed; re-sampling here would silently change the denominator under every count this package reports, and a call rate computed from a sample the caller did not choose is worse than no call rate.
It does not talk to a collector, an agent, a Jaeger query API or any other network endpoint. The only input is a byte slice the caller already holds. That boundary is what makes the whole package testable against raw exporter output, and it is why nothing here can leak a repository's trace data outward.
It does not correlate. Nothing in this file knows what a symbol, an endpoint or a table row in the index looks like, and it never will. A CodeHint is the raw material for correlation — a function name, a route template, a file and line — handed back verbatim for the caller to match against the graph. Keeping the matching rules out of here is deliberate: those rules differ per language and per instrumentation library, they change often, and burying them in a parser would make both halves untestable.
It does not retain the export. Spans carry arbitrary user attributes — SQL text with embedded credentials, URLs with bearer tokens, request bodies. Only a small allow-list of keys survives parsing; see [allowedAttributes].
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse reads spans from an OTLP/JSON or Jaeger-UI JSON export. Returns the format it used. maxBytes <= 0 means the package default.
Every bound is reported as an error naming the limit. The span list is never silently truncated: a caller that asked "which endpoints are never called" and got a quietly shortened span set would conclude that live endpoints are dead, which is the single most damaging wrong answer this package could give.
Types ¶
type CodeHint ¶
type CodeHint struct {
// Function is from code.function / code.function.name.
Function string
// Namespace is from code.namespace (a class or package).
Namespace string
// File and Line are from code.filepath / code.lineno.
File string
Line int
// Route is the HTTP route template from http.route (NOT http.target,
// which carries real path parameters and would explode the cardinality).
Route string
Method string // http.method / http.request.method
// DBTable is from db.sql.table / db.collection.name.
DBTable string
// DBOperation is from db.operation / db.operation.name.
DBOperation string
}
CodeHint is what this span says about the code that produced it.
type Operation ¶
type Operation struct {
Name string
Service string
Calls int
Errors int
// P50Nanos and P95Nanos are computed from the observed durations. They are
// exact percentiles over the spans present, not an estimate.
P50Nanos int64
P95Nanos int64
Hint CodeHint
}
Operation is one span name aggregated across traces.
type Span ¶
type Span struct {
TraceID string
SpanID string
ParentID string
Name string
Service string
Kind string // server | client | internal | producer | consumer | ""
StartNanos int64
EndNanos int64
// Status is "ok" | "error" | "" (unset).
Status string
// Attributes holds only the KEYS GraphLume correlates on; see CodeHint.
Attributes map[string]string
}
Span is one operation in a distributed trace, reduced to what GraphLume can correlate with code.
func (Span) DurationNanos ¶
DurationNanos is End-Start, or 0 when either is missing.
A negative difference is also reported as 0 rather than as a negative duration. It happens for real — a span whose start and end were stamped on two machines with skewed clocks — and letting it through would drag a percentile below zero, which is a latency no reader can act on.