Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Leverage Suppression Context in Sdk #2868

Merged
merged 16 commits into from
Mar 28, 2025

Conversation

cijothomas
Copy link
Member

@cijothomas cijothomas commented Mar 27, 2025

Fixes: #761
Continuing on top of #2821 , this PR modifies SDK's own components to suppress telemetry from its own operation using Context::enter_telemetry_suppressed_scope. This is done in the dedicated thread created by BatchProcessors, PeriodicReader.

Also modified Log SDK to respect this and ignore logs if under suppression.
I did not modify Trace SDK and Metrics SDK to do the same because:

  1. I am unsure if this is even needed in Metrics SDK at all, given there is some perf hit (only ~1 ns, which may not look much, but once we have bound instruments even 1 ns looks huge!)
  2. Trace SDK (and API) need some refactoring to find the right spot to do this. This is better handled in its own PR. Edited: This is done in Sampler now. This could be moved even earlier after some refactoring outside of this PR.

Note: This does not prevent logs from external crates like tonic, hyper being fed back to Otel, as they don't propagate Otel context. That also can be solved, but this PR is not attempting to solve that.

Basic tests added, design doc updated.

@cijothomas cijothomas requested a review from a team as a code owner March 27, 2025 01:25
Copy link

codecov bot commented Mar 27, 2025

Codecov Report

Attention: Patch coverage is 91.30435% with 12 lines in your changes missing coverage. Please review.

Project coverage is 81.1%. Comparing base (50f0bb8) to head (668ca50).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-sdk/src/logs/mod.rs 88.5% 7 Missing ⚠️
opentelemetry-sdk/src/logs/simple_log_processor.rs 91.8% 3 Missing ⚠️
opentelemetry-sdk/src/logs/logger.rs 83.3% 1 Missing ⚠️
opentelemetry-sdk/src/trace/mod.rs 95.4% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2868     +/-   ##
=======================================
+ Coverage   80.8%   81.1%   +0.2%     
=======================================
  Files        124     124             
  Lines      23836   23927     +91     
=======================================
+ Hits       19283   19410    +127     
+ Misses      4553    4517     -36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@utpilla
Copy link
Contributor

utpilla commented Mar 27, 2025

  1. I am unsure if this is even needed in Metrics SDK at all, given there is some perf hit (only ~1 ns, which may not look much, but once we have bound instruments even 1 ns looks huge!)

The regular instruments don't have to follow what bounded instrument does. They can easily accommodate the cost of doing the check, but we probably should have a consistent story for all metric instruments.

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

Thanks for working on this., LGTM, with nit comments.

@cijothomas cijothomas merged commit 62e43c5 into open-telemetry:main Mar 28, 2025
24 checks passed
@cijothomas cijothomas deleted the cijothomas/suppress-sdk branch March 28, 2025 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite trace generator
4 participants