Skip to content

Commit

Permalink
Create an instrumentation.ts file
Browse files Browse the repository at this point in the history
  • Loading branch information
stefl committed Aug 29, 2024
1 parent ee5a00a commit 9b34052
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions apps/nextjs/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("./instrumentation/tracer");
}
}
7 changes: 7 additions & 0 deletions apps/nextjs/instrumentation/tracer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { initializeTracer } from "@oakai/core/src/tracing/baseTracing";

export function initTracer() {
initializeTracer({});
}

initTracer();
2 changes: 1 addition & 1 deletion packages/core/src/tracing/baseTracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function initializeTracer(options: DatadogOptions) {
options.runtimeMetrics !== undefined ? options.runtimeMetrics : true,
sampleRate: options.sampleRate || 1,
profiling: options.profiling !== undefined ? options.profiling : true,
plugins: options.plugins !== undefined ? options.plugins : true,
plugins: options.plugins !== undefined ? options.plugins : false,
});
}
}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/tracing/serverTracing.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { initializeTracer, tracer as baseTracer, isTest } from "./baseTracing";
import { tracer as baseTracer, isTest } from "./baseTracing";
import { mockTracer } from "./mockTracer";

initializeTracer({});

export interface TracingSpan {
setTag: (key: string, value: string | number | boolean | undefined) => void;
finish: () => void;
Expand Down

0 comments on commit 9b34052

Please sign in to comment.