| 12 | * any error during bootstrap is captured. |
| 13 | */ |
| 14 | export const initializeSentry = (): void => { |
| 15 | if (env.SENTRY_DSN === "") { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | Sentry.init({ |
| 20 | dsn: env.SENTRY_DSN, |
| 21 | environment: env.NODE_ENV, |
| 22 | /* |
| 23 | * `@sentry/bun` v10+ is built on `@sentry/opentelemetry`, so any |
| 24 | * sample rate > 0 registers a second tracer alongside the |
| 25 | * OpenTelemetry SDK in `config/otel/otel.ts` — both then instrument |
| 26 | * HTTP / fetch / ioredis. Default is 0 (env-tunable): OTel ships |
| 27 | * spans to Tempo, Sentry stays error-capture-only. Error events |
| 28 | * still pick up `trace_id` from the shared OTel context, so |
| 29 | * GlitchTip → Tempo click-through is preserved. |
| 30 | */ |
| 31 | tracesSampleRate: env.SENTRY_TRACES_SAMPLE_RATE, |
| 32 | sampleRate: 1.0, |
| 33 | release: env.APP_NAME, |
| 34 | }); |
| 35 | |
| 36 | logger.info("Sentry initialized", { |
| 37 | event: "sentry.initialized", |
| 38 | environment: env.NODE_ENV, |
| 39 | tracesSampleRate: env.SENTRY_TRACES_SAMPLE_RATE, |
| 40 | }); |
| 41 | }; |
| 42 | |
| 43 | const SENTRY_FLUSH_TIMEOUT_MS = 2000; |
| 44 | |