From cdfca850ac719bbf17db2788d3bda078edeba889 Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Mon, 11 May 2026 12:06:00 +0200 Subject: [PATCH] feat(core-shared): enable OTel auto-instrumentations (http + undici + pg) --- .../instrumentation/otel/init-server-node.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/core-shared/src/instrumentation/otel/init-server-node.ts b/packages/core-shared/src/instrumentation/otel/init-server-node.ts index 0905879..d151f3c 100644 --- a/packages/core-shared/src/instrumentation/otel/init-server-node.ts +++ b/packages/core-shared/src/instrumentation/otel/init-server-node.ts @@ -1,4 +1,8 @@ import { NodeSDK, tracing } from "@opentelemetry/sdk-node"; +import { registerInstrumentations } from "@opentelemetry/instrumentation"; +import { HttpInstrumentation } from "@opentelemetry/instrumentation-http"; +import { UndiciInstrumentation } from "@opentelemetry/instrumentation-undici"; +import { PgInstrumentation } from "@opentelemetry/instrumentation-pg"; import { buildResource } from "./resource"; import { createSentryOtelBridge } from "./sentry-bridge"; @@ -57,5 +61,23 @@ export function initOtelServerNode(opts: InitOtelServerNodeOpts): NodeSDK { }); sdk.start(); + + registerInstrumentations({ + instrumentations: [ + new HttpInstrumentation({ + requestHook: (span, request) => { + const url = (request as { url?: string }).url ?? ""; + span.setAttribute("http.url.path", url.split("?")[0] ?? ""); + }, + ignoreIncomingRequestHook: (req) => { + const url = (req as { url?: string }).url ?? ""; + return url === "/_health" || url === "/_otel-export"; + }, + }), + new UndiciInstrumentation(), + new PgInstrumentation({ enhancedDatabaseReporting: false }), + ], + }); + return sdk; }