Skip to content

Conversation

@trask
Copy link
Member

@trask trask commented Aug 6, 2025

Incubating implementation for open-telemetry/opentelemetry-specification#4612

github-merge-queue bot pushed a commit to open-telemetry/opentelemetry-specification that referenced this pull request Sep 23, 2025
…ers (#4612)

Alternative to #4611

Some related prior discussions:
-
#4208 (comment)
-
#4207 (comment)

Java POC @
open-telemetry/opentelemetry-java#7529

Declarative config for this is a bit nicer than in #4611, also supports
applying different minimum severity levels to different loggers:

```
file_format: "1.0"

logger_provider:
  logger_configurator/development:
    default_config:
      minimum_severity: WARN
      trace_based: true
    loggers:
      - name: "com.example.app.*"
        config:
          minimum_severity: INFO
      - name: "com.example.db.*"
        config:
          minimum_severity: ERROR
```

---------

Co-authored-by: Liudmila Molkova <[email protected]>
Co-authored-by: Robert Pająk <[email protected]>
@trask trask force-pushed the minimum-severity-and-trace-based-log-configuration branch from 747bc91 to f607dc9 Compare October 22, 2025 03:58
@trask trask changed the title POC Add minimum severity and trace-based logger configuration Incubating: Add minimum severity and trace-based logger configuration Oct 22, 2025
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.21%. Comparing base (de48d1b) to head (7aa2b8d).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7529      +/-   ##
============================================
+ Coverage     90.16%   90.21%   +0.04%     
- Complexity     7229     7247      +18     
============================================
  Files           821      822       +1     
  Lines         21809    21828      +19     
  Branches       2136     2139       +3     
============================================
+ Hits          19665    19693      +28     
+ Misses         1472     1469       -3     
+ Partials        672      666       -6     

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

@trask trask force-pushed the minimum-severity-and-trace-based-log-configuration branch 3 times, most recently from d8f0544 to c471c04 Compare October 22, 2025 17:17
@trask trask force-pushed the minimum-severity-and-trace-based-log-configuration branch from c471c04 to 6d538c3 Compare October 22, 2025 17:36
Comment on lines 39 to 47
/** Returns a disabled {@link LoggerConfig}. */
public static LoggerConfig disabled() {
return DISABLED_CONFIG;
}

/** Returns an enabled {@link LoggerConfig}. */
public static LoggerConfig enabled() {
return DEFAULT_CONFIG;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

do we want to keep these shortcuts? I'd lean towards removing them to avoid confusion that passing one of them at runtime only enables/disables (as opposed to resetting all the properties)

Copy link
Member

Choose a reason for hiding this comment

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

The argument to keep them is for a consistent API across TracerConfig, MeterConfig, LoggerConfig.

A question to ask is whether there are sensible / intuitive default values for minimumSeverity, traceBased when you want it to call enabled() / disabled().

  • enabled(): I would expect this to be unopinionated on minimumSeverity, traceBased, and that's what we see in the defaults.
  • disabled(): I would expect minimumSeverity, traceBased to not matter, since I expect all logs to be disabled.

So I don't see these methods as misleading. However, another argument to remove them is that they're probably not all that useful anymore. disabled() is still useful, but instead of enabled(), I'd expect more users to want a shortcut enable logs with severity greater than some threshold.

If we don't care about consistency with tracing and metrics, I think it would be most useful to have an API that accommodates the common scenarios users would want to express, since repreating .builder()...build() gets verbose. Something like:

enableAll();
enableAllSampled();
enableAboveSeverity(Severity);
enableSampledAboveSeverity(Severity);
disable();

Could also adjust them to return a Builder prepopulated with setEnabled(true) or setEnabled(false).

Copy link
Member Author

Choose a reason for hiding this comment

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

enabled(): I would expect this to be unopinionated on minimumSeverity, traceBased, and that's what we see in the defaults.

won't calling updateLoggerConfig(LoggerConfig.enabled()) wipe out your existing minimumSeverity and traceBased configuration? that doesn't seem unopinionated to me 😄

@trask trask force-pushed the minimum-severity-and-trace-based-log-configuration branch from ff37f15 to 7131c10 Compare October 22, 2025 19:31
@trask trask force-pushed the minimum-severity-and-trace-based-log-configuration branch from 7131c10 to a88392e Compare October 22, 2025 19:34
@trask trask marked this pull request as ready for review October 22, 2025 19:58
@trask trask requested a review from a team as a code owner October 22, 2025 19:58
Comment on lines 39 to 47
/** Returns a disabled {@link LoggerConfig}. */
public static LoggerConfig disabled() {
return DISABLED_CONFIG;
}

/** Returns an enabled {@link LoggerConfig}. */
public static LoggerConfig enabled() {
return DEFAULT_CONFIG;
}
Copy link
Member

Choose a reason for hiding this comment

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

The argument to keep them is for a consistent API across TracerConfig, MeterConfig, LoggerConfig.

A question to ask is whether there are sensible / intuitive default values for minimumSeverity, traceBased when you want it to call enabled() / disabled().

  • enabled(): I would expect this to be unopinionated on minimumSeverity, traceBased, and that's what we see in the defaults.
  • disabled(): I would expect minimumSeverity, traceBased to not matter, since I expect all logs to be disabled.

So I don't see these methods as misleading. However, another argument to remove them is that they're probably not all that useful anymore. disabled() is still useful, but instead of enabled(), I'd expect more users to want a shortcut enable logs with severity greater than some threshold.

If we don't care about consistency with tracing and metrics, I think it would be most useful to have an API that accommodates the common scenarios users would want to express, since repreating .builder()...build() gets verbose. Something like:

enableAll();
enableAllSampled();
enableAboveSeverity(Severity);
enableSampledAboveSeverity(Severity);
disable();

Could also adjust them to return a Builder prepopulated with setEnabled(true) or setEnabled(false).

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