You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-09-16 09:26:25 +02:00
Use the context passed to ExportSpans
for measurements in stdouttrace
(#7198)
Without this the measurements are receiving broken context.
This commit is contained in:
@@ -98,7 +98,7 @@ func (e *Exporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan)
|
||||
if e.selfObservabilityEnabled {
|
||||
count := int64(len(spans))
|
||||
|
||||
e.spanInflightMetric.Add(context.Background(), count, e.selfObservabilityAttrs...)
|
||||
e.spanInflightMetric.Add(ctx, count, e.selfObservabilityAttrs...)
|
||||
defer func(starting time.Time) {
|
||||
// additional attributes for self-observability,
|
||||
// only spanExportedMetric and operationDurationMetric are supported
|
||||
@@ -108,9 +108,9 @@ func (e *Exporter) ExportSpans(ctx context.Context, spans []trace.ReadOnlySpan)
|
||||
addAttrs = append(addAttrs, semconv.ErrorType(err))
|
||||
}
|
||||
|
||||
e.spanInflightMetric.Add(context.Background(), -count, e.selfObservabilityAttrs...)
|
||||
e.spanExportedMetric.Add(context.Background(), count, addAttrs...)
|
||||
e.operationDurationMetric.Record(context.Background(), time.Since(starting).Seconds(), addAttrs...)
|
||||
e.spanInflightMetric.Add(ctx, -count, e.selfObservabilityAttrs...)
|
||||
e.spanExportedMetric.Add(ctx, count, addAttrs...)
|
||||
e.operationDurationMetric.Record(ctx, time.Since(starting).Seconds(), addAttrs...)
|
||||
}(time.Now())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user