feat(core-shared): enable OTel auto-instrumentations (http + undici + pg)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user