You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-27 22:49:15 +02:00
Propagate context to self-observability measurements in sdk/trace (#7209)
Ensures metric functionality that integrates with trace context (e.g. exemplars) correctly receive the trace context and anything else the user has passed.
This commit is contained in:
@@ -509,7 +509,10 @@ func (s *recordingSpan) End(options ...trace.SpanEndOption) {
|
||||
attrSamplingResult = s.tracer.spanLiveMetric.AttrSpanSamplingResult(otelconv.SpanSamplingResultRecordOnly)
|
||||
}
|
||||
|
||||
s.tracer.spanLiveMetric.Add(context.Background(), -1, attrSamplingResult)
|
||||
// Add the span to the context to ensure the metric is recorded
|
||||
// with the correct span context.
|
||||
ctx := trace.ContextWithSpan(context.Background(), s)
|
||||
s.tracer.spanLiveMetric.Add(ctx, -1, attrSamplingResult)
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user