fix(otel): consolidate to single OTel SDK init at instrumentation.register hook
All three apps' instrumentation.ts files now call initOtelServerNode directly instead of initSentryServer/initSentryServerNode, closing the startup window where @sentry/nextjs auto-instrumentation could send unscrubbed errors before bindAll() fires. bindOtelInstrumentation no longer calls initOtelServerNode (SDK init belongs at app boot, binding at request scope). Orphaned sentry/ init-server*.ts files deleted; their package.json subpath exports removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
// apps/web-next/instrumentation.ts
|
||||
// Next.js convention: this module runs once on server boot.
|
||||
// Delegates to the centralized init helper in core-shared.
|
||||
// Next.js convention: this module runs once on server boot (before any request handler).
|
||||
// Initializes the OTel SDK here so PII scrub processors are active from the very first
|
||||
// request — before bindAll() fires. Calling initOtelServerNode here (not inside bindAll)
|
||||
// closes the startup window where @sentry/nextjs auto-instrumentation could send
|
||||
// unscrubbed errors (C1 fix).
|
||||
|
||||
export async function register() {
|
||||
if (
|
||||
process.env["NEXT_RUNTIME"] === "nodejs" ||
|
||||
process.env["NEXT_RUNTIME"] === "edge"
|
||||
) {
|
||||
const { initSentryServer } = await import(
|
||||
"@repo/core-shared/instrumentation/sentry/init-server"
|
||||
const { initOtelServerNode } = await import(
|
||||
"@repo/core-shared/instrumentation/otel/init-server-node"
|
||||
);
|
||||
initSentryServer({
|
||||
dsn: process.env["WEB_NEXT_SENTRY_DSN"],
|
||||
app: "web-next",
|
||||
release: process.env["VERCEL_GIT_COMMIT_SHA"],
|
||||
initOtelServerNode({
|
||||
dsn: process.env["WEB_NEXT_SENTRY_DSN"] ?? "",
|
||||
serviceName: "web-next",
|
||||
environment: process.env["NODE_ENV"] ?? "development",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user