Skip to content

Conversation

@jack-berg
Copy link
Member

Resolves #7242.

Also noticed that the noop implementations of isEnabled for traces, metrics, and logs were all returning true instead of false, so fixed that as well.

@jack-berg jack-berg requested a review from a team as a code owner April 11, 2025 15:43

/** Overload of {@link #isEnabled(Severity, Context)} assuming {@link Context#current()}. */
default boolean isEnabled(Severity severity) {
return isEnabled(severity, Context.current());
Copy link
Member Author

Choose a reason for hiding this comment

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

The spec says this should accept Severity and Context parameters, but since we have implicit context in java, I think the most common case will be to use that. So I've included an overload where the context is omitted.

@Override
public boolean isEnabled() {
public boolean isEnabled(Severity severity, Context context) {
return loggerEnabled;
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately there's no way for the java SDK to currently respond to context or severity parameters today until we also implement LogRecordProcessor#isEnabled: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#logrecordprocessor-operations

@codecov
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.82%. Comparing base (15ae8c0) to head (2174f7a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7268   +/-   ##
=========================================
  Coverage     89.82%   89.82%           
- Complexity     6999     7002    +3     
=========================================
  Files           798      798           
  Lines         21199    21211   +12     
  Branches       2055     2055           
=========================================
+ Hits          19042    19053   +11     
  Misses         1496     1496           
- Partials        661      662    +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.

@jack-berg jack-berg merged commit d9c9583 into open-telemetry:main Jul 8, 2025
29 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.

Update and stabilize Logger#enabled

2 participants