Documentation
¶
Overview ¶
Package telemetry implements fullsend's distributed tracing (ADR 0050).
Setup configures an OpenTelemetry TracerProvider with two exporters:
- fileExporter (synchronous) writes every span as OTLP JSON to run-telemetry.jsonl.
- otlptracehttp (batched) exports to a remote backend when an OTEL_EXPORTER_OTLP_*ENDPOINT is configured.
When neither exporter can be created, Setup returns a noop tracer so the run is never affected.
Index ¶
Constants ¶
const FlushTimeout = 5 * time.Second
FlushTimeout is the budget for tp.Shutdown to flush pending spans at CLI exit.
const MaxSpanAttrValueLen = 8192
MaxSpanAttrValueLen bounds every span attribute value recorded through this provider. The SDK applies the limit to span attributes only — event messages are bounded at their call site — counting characters, not bytes (a multibyte value can reach four bytes per character on the wire), and it repairs invalid UTF-8 only when it truncates: values at or under the limit pass through unrepaired, so free-text attribute values are repaired at their call sites (internal/cli stringAttr). Both properties are pinned by TestAttrLimit_SDKBehaviorCanary. The exception-event bound in internal/cli (maxSpanEventMsgLen, bytes) is defined from this constant so the shared numeric default cannot drift, each side applying it in its own unit. It applies only when the SDK took no operator override — the first non-empty of OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT and OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT decides alone, and a parseable value there, including -1 (unlimited), is honored as-is.
const TelemetryFile = "run-telemetry.jsonl"
TelemetryFile is the artifact name written to the output dir.
Variables ¶
This section is empty.
Functions ¶
func Setup ¶ added in v0.32.0
Setup creates a TracerProvider with file and (optionally) OTLP exporters. On any failure it returns a noop tracer and an empty cleanup func so the run is never affected. The cleanup func shuts down the provider (flushing the OTLP batch processor) and closes the file; it should be called with a context that has enough budget for the OTLP flush (typically context.Background() with a 5s timeout).
func Traceparent ¶ added in v0.32.0
func Traceparent(sc trace.SpanContext) string
Traceparent returns the W3C traceparent header value for a span context. Returns "" for invalid (zero) span contexts so callers can omit the header rather than emitting an all-zero value that W3C forbids.
func TraceparentWithFlags ¶ added in v0.32.0
func TraceparentWithFlags(sc trace.SpanContext, flags trace.TraceFlags) string
TraceparentWithFlags formats a W3C traceparent using sc's trace/span IDs but with explicit flags. Use this to propagate a sampling decision that differs from the local span's (e.g. preserving an upstream unsampled bit that AlwaysSample overrode locally).
Types ¶
This section is empty.