Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EndSpan ¶
EndSpan ends span, recording an error status when err is non-nil. Defer it inside a closure so err is read at function exit rather than at defer-statement time (when a named return is still nil):
defer func() { trace.EndSpan(span, retErr) }()
func InitTracer ¶
func InitTracer(ctx context.Context, serviceName, otlpAddress string, otlpInsecure bool, otlpHeaders map[string]string, otlpAttrs []string, sampleRatio float64) (func(), error)
InitTracer initializes the trace provider and the otel grpc exporter.
sampleRatio controls head-based sampling: 1.0 samples every trace, 0.0 samples none, and values in between sample that fraction of traces. Callers are expected to pass a value in [0.0, 1.0] (the --otlp-sample-ratio flag is range-validated at parse time via cli.BoundedFloat64Var). The sampler is parent-based, so a sampling decision made upstream (e.g. the controller) is honored by every downstream service the trace context propagates to (repo-server, commit-server, ...), keeping each trace whole rather than partially sampled across process boundaries.
Because the sampler is parent-based, an incoming request that already carries a W3C traceparent marked "not sampled" is not recorded even when sampleRatio is 1.0: the upstream sampling decision wins. This differs from the previous always-on sampler, which recorded every request regardless of any inbound sampling flag.
Types ¶
This section is empty.