open-telemetry / open-telemetry/opentelemetry-java

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

Open Beginner friendly
#8,836 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.5k
Forks
1k
Avg merge
3d 17h
Merged PRs (30d)
58

Description

Describe the bug
SdkLoggerProvider.get(String) returns a real SdkLogger when no LogRecordProcessor is configured, while loggerBuilder(String) returns the noop Logger in the same situation.

Steps to reproduce

SdkLoggerProvider provider = SdkLoggerProvider.builder().build();
provider.get("x").isEnabled(Severity.INFO);                     // true
provider.loggerBuilder("x").build().isEnabled(Severity.INFO);   // false

What did you expect to see?
Both calls return the same noop Logger. The Logs SDK spec ("Enabled" in specification/logs/sdk.md) requires Enabled to return false when there are no registered LogRecordProcessors. SdkMeterProvider is consistent: meterBuilder() returns noop without readers and get() delegates to it.

What did you see instead?
get() skips the isNoopLogRecordProcessor check that loggerBuilder() performs (SdkLoggerProvider.java line 89-93). The returned SdkLogger reports isEnabled as true and, on every emit, allocates a record, increments otel.sdk.log.created, and hands it to NoopLogRecordProcessor. The check was dropped in #4913, which changed get() from loggerBuilder(name).build() to a direct registry lookup.

Only direct get() calls on an SdkLoggerProvider are affected; OpenTelemetrySdk.getLogsBridge().get() routes through loggerBuilder().

What version and what artifacts are you using?
Artifacts: opentelemetry-sdk-logs
Version: main @ 509182e4b (1.67.0-SNAPSHOT)
How did you reference these artifacts? N/A

Environment
Compiler: Temurin 21
OS: N/A

Additional context
Related: #8740 / #8815 add the same shortcut to SdkTracerProvider, using SdkLoggerProvider as the reference.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with SdkLoggerProvider.java around lines 89-93 and compare get(String) with loggerBuilder(String), then read the Enabled requirement in specification/logs/sdk.md and the analogous SdkMeterProvider behavior. Done means direct get() and loggerBuilder().build() both return a noop Logger with isEnabled false when no LogRecordProcessor is configured, with regression coverage in the SDK logs tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
observability-sre
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.