Skip to content

[sdk-logs] Logger.emit() does not prevent work being done when its LoggerProvider has shutdown #6823

Description

@trentm

(From Carlos' review, mentioned at OTel JS SIG today: https://docs.google.com/document/d/1tCyoQK49WVcE-x8oryZOTTToFm7sIeUhxFPm9g-qL1k/edit?tab=t.0#heading=h.bu4c09f6jdw3)

Logger.emit() doesn’t prevent side work to happen in case its LoggerProvider has shutdown, e.g. metrics reporting.

I agree.

While class Logger.emit starts with this:

  public emit(logRecord: LogRecord): void {
    const currentContext = logRecord.context || context.active();
    if (!this.enabled(logRecord)) {
      return;
    }
    ...

that this.enabled(logRecord) is something slightly different.
this.enabled(...) handles (a) filtering of log records based on severity and other attributes from LoggerConfig, and (b) check if all LogRecordProcessors for this Logger return false for their .enabled(...) method which is, again, about filtering and not about shutdown state.

Compare with the equivalent start of the equivalent in OTel Java, FWIW:
https://github.com/open-telemetry/opentelemetry-java/blob/a00536a2c7b3a3f7a0952dbea12e9249da18611d/sdk/logs/src/main/java/io/opentelemetry/sdk/logs/SdkLogRecordBuilder.java#L139-L146
That if (loggerSharedState.hasBeenShutdown()) is the part JS is missing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions