Skip to content

Make SdkLoggerProvider.get() return noop Logger when no processors are configured - #8838

Open
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/sdk-logger-provider-get-noop-shortcut
Open

thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/sdk-logger-provider-get-noop-shortcut

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #8836

Description

  • SdkLoggerProvider.loggerBuilder() returns LoggerProvider.noop().loggerBuilder(name) when no LogRecordProcessor is configured, but get() skipped that check and always built a real SdkLogger.
  • With no processors, get("x").isEnabled(Severity.INFO) returned true while loggerBuilder("x").build().isEnabled(...) returned false; the Logs SDK spec requires Enabled to return false when no processors are registered. The SdkLogger also allocated a record and counted otel.sdk.log.created on every emit before NoopLogRecordProcessor dropped it.
  • Only direct SdkLoggerProvider.get() calls are affected; OpenTelemetrySdk.getLogsBridge().get() already routes through loggerBuilder().
  • get() now returns LoggerProvider.noop().get(name) under the same isNoopLogRecordProcessor condition, matching loggerBuilder() and SdkMeterProvider. The check was lost in Optimize log hot path #4913, which replaced loggerBuilder(name).build() with a direct registry lookup.

Related: #8740 / #8815 (same shortcut for SdkTracerProvider), spec specification/logs/sdk.md "Enabled".

Testing done

  • Added SdkLoggerProviderTest#get_NoProcessor_UsesNoop; it failed before the fix (SdkLogger vs DefaultLogger) and passes after.
  • ./gradlew :sdk:logs:check — 90 tests + 22 testIncubating passed.
  • ./gradlew :sdk:all:test — 23 tests passed.
  • No public API change; docs/apidiffs unchanged.

@thswlsqls
thswlsqls marked this pull request as ready for review September 18, 2026 02:06
@thswlsqls
thswlsqls requested a review from a team as a code owner September 18, 2026 02:06
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on maintainers · refreshed 2026-09-21 15:26 UTC

Merge when ready.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.37%. Comparing base (509182e) to head (3a8811f).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8838      +/-   ##
============================================
+ Coverage     91.34%   91.37%   +0.03%     
- Complexity    10652    10657       +5     
============================================
  Files          1010     1010              
  Lines         28696    28698       +2     
  Branches       3682     3682              
============================================
+ Hits          26212    26224      +12     
+ Misses         1683     1671      -12     
- Partials        801      803       +2     

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

No deployments
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.

SdkLoggerProvider.get() returns a real Logger when no processors are configured, unlike loggerBuilder()

2 participants