Skip to content

Add context and severity params to ExtendedLogger#isEnabled #7268

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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
return true;
}

/** 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.

@@ -24,7 +26,7 @@ final class ExtendedSdkLogger extends SdkLogger implements ExtendedLogger {
}

@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

Copy link

codecov bot commented Apr 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.97%. Comparing base (9cb6365) to head (251ef99).
Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7268      +/-   ##
============================================
+ Coverage     89.92%   89.97%   +0.05%     
- Complexity     6721     6729       +8     
============================================
  Files           765      765              
  Lines         20277    20289      +12     
  Branches       1985     1985              
============================================
+ Hits          18234    18256      +22     
+ Misses         1448     1439       -9     
+ Partials        595      594       -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.

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
1 participant