Skip to content

Conversation

@mahendrabishnoi2
Copy link
Member

@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

@codecov
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).
⚠️ Report is 86 commits behind head on main.

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
Member 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
Member 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
Member 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
Member 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?

@pellared
Copy link
Member

pellared commented Sep 1, 2025

@mahendrabishnoi2 PTAL #7272

@flc1125
Copy link
Member

flc1125 commented Sep 11, 2025

Hi, since this process involves specification adjustments and historical review records (which may contain invalid review suggestions), it’s impossible to tell which items need attention amid the large volume of information.

Could we create a new PR based on the current branch before preparing for the review, so that subsequent reviews can proceed more smoothly?

Thanks~

@MrAlias MrAlias added this to the v1.39.0 milestone Sep 15, 2025
@MrAlias
Copy link
Contributor

MrAlias commented Sep 15, 2025

@mahendrabishnoi2 please take a look at #7004. I have updated the issue with a check list of items from our project Observability guidelines that need to be completed in this PR.

As @flc1125 pointed out, you may find it easier to open a new PR. But feel free to update this PR as well. If you plan to update this PR, please mark it as a draft while you are working to address the items listed in #7004 and the Observability guidelines.

@MrAlias MrAlias added the area:trace Part of OpenTelemetry tracing label Sep 15, 2025
@mahendrabishnoi2
Copy link
Member Author

mahendrabishnoi2 commented Sep 17, 2025

Closed in favor of #7374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:trace Part of OpenTelemetry tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trace SDK observability - simple processor metrics

4 participants