Documentation
¶
Overview ¶
Package telemetry initializes OpenTelemetry tracing and metrics for one process and provides W3C trace-context propagation helpers. Every binary (controlplane, brain, executor, worker) calls Init at startup; the event log later emits span.* domain events from the same spans started here, so the two views never drift.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
Extract returns a copy of ctx carrying the remote span context found in carrier, or ctx unchanged when carrier holds no valid traceparent.
func Init ¶
Init installs the global W3C trace-context propagator and, when an endpoint is configured, global OTLP-exporting tracer and meter providers. On error no global state has been touched. The returned shutdown flushes buffered telemetry; call it once at process exit.
func Inject ¶
Inject writes the trace context from ctx into carrier as W3C traceparent / tracestate entries, replacing existing entries in any key casing. carrier is any string map — HTTP headers and a work item's stored trace context both flatten to this shape. A nil carrier, or a ctx without a span context, leaves everything untouched.
Types ¶
type Config ¶
type Config struct {
// ServiceName identifies the process in traces and metrics
// (e.g. "controlplane", "brain", "executor", "worker"). Required.
ServiceName string
// Endpoint is the OTLP/gRPC collector address (host:port). Empty
// disables export entirely — no dialing, no background workers — so a
// deployment without a collector runs offline by default.
Endpoint string
// Insecure dials the collector without TLS (local dev, in-cluster
// collectors behind the service mesh).
Insecure bool
// SampleRatio is the fraction of new root traces sampled, in [0, 1];
// 0 samples nothing (metrics still flow). nil defaults to 1 (sample
// everything). Child spans always follow their parent's decision, so
// a trace is never torn.
SampleRatio *float64
}
Config controls telemetry for one process. Each binary maps its own environment / Helm values onto this struct.