Skip to content

Conversation

mahendrabishnoi2
Copy link
Contributor

@mahendrabishnoi2 mahendrabishnoi2 commented Aug 9, 2025

Fixes: #7004

This PR adds support for experimental otel.sdk.processor.span.processed metric in simple span processor.
Definition of metric at: https://github.com/open-telemetry/semantic-conventions/blob/v1.36.0/docs/otel/sdk-metrics.md

Experimental metrics are behind a feature flag: OTEL_GO_X_SELF_OBSERVABILITY

Copy link

codecov bot commented Aug 9, 2025

Codecov Report

❌ Patch coverage is 90.19608% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.8%. Comparing base (5358fd7) to head (97c11ff).

Files with missing lines Patch % Lines
sdk/trace/simple_span_processor.go 90.1% 4 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7162   +/-   ##
=====================================
  Coverage   82.8%   82.8%           
=====================================
  Files        265     265           
  Lines      24896   24944   +48     
=====================================
+ Hits       20631   20677   +46     
- Misses      3885    3887    +2     
  Partials     380     380           
Files with missing lines Coverage Δ
sdk/trace/simple_span_processor.go 84.7% <90.1%> (+9.3%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mahendrabishnoi2 mahendrabishnoi2 marked this pull request as ready for review August 16, 2025 14:25
@mahendrabishnoi2
Copy link
Contributor Author

For some reason codecov comment is not updated but new code is covered by tests. (https://app.codecov.io/github/open-telemetry/opentelemetry-go/pull/7162)

}

// configureSelfObservability configures metrics for the simple span processor.
func (ssp *simpleSpanProcessor) configureSelfObservability() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please flatten this into the span processor creation function or refactor it to not produce side-effects.

Related:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

- separate changelog entry
- flatten self observability initialization
- reset simpleProcessorIDCounter so tests can be run in parallel and order doesn't matter
- use sync.Pool to amortize allocation for metric attrs
- use sync.Pool to amortize allocation for metric attrs
- pass context with span to ensure metric is recorded with correct span context
@mahendrabishnoi2
Copy link
Contributor Author

@MrAlias Addressed the comments. Please do another round of review when you can. Thanks.

if ssp.selfObservabilityEnabled {
// Add the span to the context to ensure the metric is recorded
// with the correct span context.
ctx := trace.ContextWithSpanContext(context.Background(), s.SpanContext())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the correct way to add span to context given we have ReadOnlySpan in this method instead of Span?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trace SDK observability - simple processor metrics
2 participants