Skip to content

Commit 9fe60c7

Browse files
committed
refactor: export collectOtel to eliminate duplication
1 parent 5207102 commit 9fe60c7

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

apps/api/src/core/providers/logging.provider.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { LoggerService as LoggerServiceOriginal } from "@akashnetwork/logging";
22
import { HttpLoggerIntercepter } from "@akashnetwork/logging/hono";
3-
import { context, trace } from "@opentelemetry/api";
3+
import { collectOtel } from "@akashnetwork/logging/otel";
44
import { container, injectable } from "tsyringe";
55

66
// Set up OpenTelemetry mixin for all LoggerService instances
77
// This collects trace information and adds it to log entries
8-
LoggerServiceOriginal.mixin = () => {
9-
const currentSpan = trace.getSpan(context.active());
10-
return { ...currentSpan?.spanContext() };
11-
};
8+
LoggerServiceOriginal.mixin = collectOtel;
129

1310
container.register(HttpLoggerIntercepter, { useValue: new HttpLoggerIntercepter(LoggerServiceOriginal.forContext("HTTP")) });
1411

packages/logging/src/otel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { LoggerService } from "./services/logger/logger.service";
77
* Collects OpenTelemetry span context for logging
88
* This mixin adds trace information to log entries
99
*/
10-
function collectOtel() {
10+
export function collectOtel() {
1111
const currentSpan = trace.getSpan(context.active());
1212
return { ...currentSpan?.spanContext() };
1313
}

0 commit comments

Comments
 (0)