(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.
(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)
I agree.
While class Logger.emit starts with this:
that
this.enabled(logRecord)is something slightly different.this.enabled(...)handles (a) filtering of log records based on severity and other attributes fromLoggerConfig, and (b) check if allLogRecordProcessors for thisLoggerreturnfalsefor 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.