opentelemetry-rust icon indicating copy to clipboard operation
opentelemetry-rust copied to clipboard

feat: add support for `OTEL_SDK_DISABLED` environment variable

Open iamsauravsharma opened this issue 4 months ago • 5 comments

Fixes #1936

Changes

Add support for OTEL_SDK_DISABLED environment variable using no-op SDK implementation as explained Opentelemetry SDK environment variable docs. When set to true, the SDK will provide no-op implementations for all API components (Tracer, Logger, and Meter).

Implemented no-op provider classes that mimic the shutdown no-op providers for logger and tracer with only difference is shutdown variable which is set to false for disabled no op. Where as for metrics existing noop is re used

Merge requirement checklist

  • [X] CONTRIBUTING guidelines followed
  • [X] Unit tests added/updated (if applicable)
  • [X] Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • [ ] Changes in public API reviewed (if applicable)

iamsauravsharma avatar Jul 28 '25 12:07 iamsauravsharma

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: iamsauravsharma / name: Saurav Sharma (e2eb5fbf20fbc20f77be080d3af260a6f1d7ea0e)

Codecov Report

:x: Patch coverage is 28.03030% with 95 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 80.1%. Comparing base (2b63b75) to head (e2eb5fb).

Files with missing lines Patch % Lines
opentelemetry-sdk/src/logs/logger_provider.rs 18.7% 39 Missing :warning:
opentelemetry-sdk/src/trace/provider.rs 36.8% 36 Missing :warning:
opentelemetry-sdk/src/metrics/meter_provider.rs 29.1% 17 Missing :warning:
opentelemetry-sdk/src/logs/logger.rs 0.0% 3 Missing :warning:
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3088     +/-   ##
=======================================
- Coverage   80.5%   80.1%   -0.4%     
=======================================
  Files        129     129             
  Lines      23294   23420    +126     
=======================================
+ Hits       18756   18782     +26     
- Misses      4538    4638    +100     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov[bot] avatar Jul 28 '25 12:07 codecov[bot]

Since overwriting OTEL_SDK_DISABLED environment variable would effects other test when running parallel test. 3 new test are ignored by default and scripts/test.sh is updated so 3 test run themselves in last step

iamsauravsharma avatar Jul 28 '25 14:07 iamsauravsharma

Implemented some changes as requested

iamsauravsharma avatar Aug 05 '25 03:08 iamsauravsharma

@cijothomas @lalitb just a reminder about this PR. I’ve pushed the requested changes or replied with my reasoning. could you please take another look?

iamsauravsharma avatar Oct 28 '25 02:10 iamsauravsharma