Skip to content

Commit f148059

Browse files
committed
Stop swallowing webapp logs when the span isn’t being recorded
1 parent 328947d commit f148059

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

packages/core-backend/src/logger.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,20 @@ export class Logger {
9696
// Get the current context from trace if it exists
9797
const currentSpan = trace.getSpan(context.active());
9898

99-
if (!currentSpan || currentSpan.isRecording()) {
100-
const structuredLog = {
101-
...structureArgs(safeJsonClone(args) as Record<string, unknown>[], this.#filteredKeys),
102-
...this.#additionalFields(),
103-
timestamp: new Date(),
104-
name: this.#name,
105-
message,
106-
level,
107-
traceId: currentSpan?.spanContext().traceId,
108-
parentSpanId: currentSpan?.spanContext().spanId,
109-
};
110-
111-
loggerFunction(JSON.stringify(structuredLog, this.#jsonReplacer));
112-
}
99+
const structuredLog = {
100+
...structureArgs(safeJsonClone(args) as Record<string, unknown>[], this.#filteredKeys),
101+
...this.#additionalFields(),
102+
timestamp: new Date(),
103+
name: this.#name,
104+
message,
105+
level,
106+
traceId:
107+
currentSpan && currentSpan.isRecording() ? currentSpan?.spanContext().traceId : undefined,
108+
parentSpanId:
109+
currentSpan && currentSpan.isRecording() ? currentSpan?.spanContext().spanId : undefined,
110+
};
111+
112+
loggerFunction(JSON.stringify(structuredLog, this.#jsonReplacer));
113113
}
114114
}
115115

0 commit comments

Comments
 (0)