From 9b34052d32c98505fb7bbeae2d60292ba3f0b061 Mon Sep 17 00:00:00 2001 From: Stef Lewandowski Date: Thu, 29 Aug 2024 15:46:43 +0100 Subject: [PATCH] Create an instrumentation.ts file --- apps/nextjs/instrumentation.ts | 5 +++++ apps/nextjs/instrumentation/tracer.ts | 7 +++++++ packages/core/src/tracing/baseTracing.ts | 2 +- packages/core/src/tracing/serverTracing.ts | 4 +--- 4 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 apps/nextjs/instrumentation.ts create mode 100644 apps/nextjs/instrumentation/tracer.ts diff --git a/apps/nextjs/instrumentation.ts b/apps/nextjs/instrumentation.ts new file mode 100644 index 000000000..ec316bbdb --- /dev/null +++ b/apps/nextjs/instrumentation.ts @@ -0,0 +1,5 @@ +export async function register() { + if (process.env.NEXT_RUNTIME === "nodejs") { + await import("./instrumentation/tracer"); + } +} diff --git a/apps/nextjs/instrumentation/tracer.ts b/apps/nextjs/instrumentation/tracer.ts new file mode 100644 index 000000000..a1389d308 --- /dev/null +++ b/apps/nextjs/instrumentation/tracer.ts @@ -0,0 +1,7 @@ +import { initializeTracer } from "@oakai/core/src/tracing/baseTracing"; + +export function initTracer() { + initializeTracer({}); +} + +initTracer(); diff --git a/packages/core/src/tracing/baseTracing.ts b/packages/core/src/tracing/baseTracing.ts index f8e88bff2..666fb8601 100644 --- a/packages/core/src/tracing/baseTracing.ts +++ b/packages/core/src/tracing/baseTracing.ts @@ -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, }); } } diff --git a/packages/core/src/tracing/serverTracing.ts b/packages/core/src/tracing/serverTracing.ts index b851a0037..011d44d1d 100644 --- a/packages/core/src/tracing/serverTracing.ts +++ b/packages/core/src/tracing/serverTracing.ts @@ -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;