Skip to content

Stabilize enabled api#8200

Merged
jack-berg merged 3 commits intoopen-telemetry:mainfrom
jack-berg:stabilize-enabled-api
Apr 2, 2026
Merged

Stabilize enabled api#8200
jack-berg merged 3 commits intoopen-telemetry:mainfrom
jack-berg:stabilize-enabled-api

Conversation

@jack-berg
Copy link
Copy Markdown
Member

@jack-berg jack-berg requested a review from a team as a code owner March 19, 2026 18:49
* @deprecated for removal after 1.55.0. Use {@link #isEnabled(Severity, Context)} or {@link
* #isEnabled(Severity)} instead.
*/
@Deprecated
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note, also removing this deprecated API

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 72.22222% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.30%. Comparing base (3fbc5ce) to head (f7c5ada).
⚠️ Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
...rc/main/java/io/opentelemetry/api/logs/Logger.java 50.00% 1 Missing ⚠️
...va/io/opentelemetry/api/metrics/DoubleCounter.java 0.00% 1 Missing ⚠️
...java/io/opentelemetry/api/metrics/DoubleGauge.java 0.00% 1 Missing ⚠️
.../io/opentelemetry/api/metrics/DoubleHistogram.java 0.00% 1 Missing ⚠️
...opentelemetry/api/metrics/DoubleUpDownCounter.java 0.00% 1 Missing ⚠️
...java/io/opentelemetry/api/metrics/LongCounter.java 0.00% 1 Missing ⚠️
...n/java/io/opentelemetry/api/metrics/LongGauge.java 0.00% 1 Missing ⚠️
...va/io/opentelemetry/api/metrics/LongHistogram.java 0.00% 1 Missing ⚠️
...o/opentelemetry/api/metrics/LongUpDownCounter.java 0.00% 1 Missing ⚠️
...c/main/java/io/opentelemetry/api/trace/Tracer.java 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (72.22%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8200      +/-   ##
============================================
+ Coverage     90.29%   90.30%   +0.01%     
+ Complexity     7652     7651       -1     
============================================
  Files           843      843              
  Lines         23066    23073       +7     
  Branches       2310     2310              
============================================
+ Hits          20827    20836       +9     
+ Misses         1520     1519       -1     
+ Partials        719      718       -1     

☔ 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.

* the response is subject to change over the application, callers should call this before each
* call to {@link #logRecordBuilder()}.
*/
default boolean isEnabled(Severity severity, Context context) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why does this need the context as an additional parameter, but the tracer & instrument ones don't?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For logs, the behavior of isEnabled can be toggled based on context. See LoggerConfig.trace_based: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#loggerconfig

There's been no discussed analog for traces or metrics.

You could get creative and imagine cases where we add such capabilities in the future, but the cases seem farfetched to me:

  • The span analog to filtering based on context is a sampler. Hard to imagine it making sense to filter out spans before calling the sampler.
  • For metrics, metric recording is binary: on and you get the whole population of measurements, off and you get none of the measurements. Hard to imagine it being useful / common to filter measurements based on some data in context.

If I'm wrong and someday the spec adds a context argument to the trace / metric enabled methods, we can add an overload to accommodate.

@jack-berg jack-berg merged commit bf27c62 into open-telemetry:main Apr 2, 2026
26 of 27 checks passed
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.

2 participants