feat(observability): gate Sentry tracing spans behind SENTRY_TRACING
Spans are now created and exported to Sentry only when SENTRY_TRACING is enabled (default off), keeping 24/7 operation within the free-tier span quota. Error monitoring stays always-on. Includes OpenSpec change gate-sentry-spans (proposal, design, specs, tasks). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
f6e8381c20
commit
a5c83ee026
@@ -1,4 +1,5 @@
|
||||
import * as Sentry from "@sentry/node";
|
||||
import { isTracingEnabled } from "./tracing.js";
|
||||
|
||||
const dsn = process.env.SENTRY_DSN?.trim();
|
||||
|
||||
@@ -8,8 +9,13 @@ export function initSentry(): void {
|
||||
Sentry.init({
|
||||
dsn,
|
||||
environment: process.env.NODE_ENV ?? "development",
|
||||
tracesSampleRate: process.env.NODE_ENV === "production" ? 0.1 : 1,
|
||||
integrations: [Sentry.httpIntegration(), Sentry.expressIntegration()],
|
||||
// Tracing/spans are gated by SENTRY_TRACING (default off) to stay within
|
||||
// the Sentry free-tier span quota during 24/7 operation. Error monitoring
|
||||
// is always on.
|
||||
...(isTracingEnabled()
|
||||
? { tracesSampleRate: process.env.NODE_ENV === "production" ? 0.1 : 1 }
|
||||
: {}),
|
||||
});
|
||||
|
||||
process.on("unhandledRejection", (reason) => {
|
||||
|
||||
Reference in New Issue
Block a user