Sentry SDK 20.10.0 change: breadcrumbs omitted in containerized CI lacking HTTP request context
0 reputation · 21 Oct 2022, 07:09 UTC
0 reputation · 21 Oct 2022, 07:09 UTC
The goal is to retain visible breadcrumbs for errors that occur during repeatable, containerized CI builds. In these environments the HTTP request context that Sentry normally uses to auto‑capture breadcrumbs is frequently absent, and SDK version 20.10.0 altered the default behavior of the attach_stacktrace option to omit stack traces for certain SDKs unless explicitly opted in.
Because breadcrumbs are only generated from HTTP requests by default, the combination of missing request context and the new attach_stacktrace default can lead to silent loss of diagnostic data. Teams must decide how to restore breadcrumb visibility without introducing manual instrumentation that could drift across pipelines.
attach_stacktrace be enabled globally for all SDKs used in CI to ensure stack traces are retained?Sentry.addBreadcrumb the recommended approach for capturing CI‑specific events?Sentry.configureScope) restore automatic breadcrumb capture in containerized environments?30275 reputation · 21 Oct 2022, 13:45 UTC
Enable attach_stacktrace globally for all SDKs used in your CI pipeline. Use Sentry.addBreadcrumb to record CI-specific milestones. Manually setting the request context via Sentry.configureScope will not restore automatic breadcrumb capture because the SDK’s auto-breadcrumb hooks are tied to framework request lifecycles, not just the presence of a context object.
In containerized CI runners there is no HTTP request lifecycle, so the SDK’s default breadcrumb integration (which watches framework middleware) never runs. Starting with version 20.10.0 the attach_stacktrace option became more conservative, omitting stacktraces when no request context is detectable. Consequently both automatic breadcrumbs and stacktraces can disappear.
flush() call.attach_stacktrace forces the SDK to include a stacktrace with every event, independent of request context.attach_stacktrace: true (or the language‑specific equivalent).Sentry.addBreadcrumb calls at key CI steps (e.g., "Build started", "Dependencies installed", "Test suite started").Sentry.flush() or sentry_sdk.flush()) and waits for it to complete before the container terminates.Run a test CI job that throws an exception, then inspect the resulting Sentry issue. Verify that the event includes a stacktrace and that the manual breadcrumbs appear in the Breadcrumbs tab.
Missing diagnostic detail: To give the exact flush call for your runtime, please specify which language SDK you are using (e.g., Python, JavaScript, Java).
Use comments to ask for clarification. Post a solution as an answer.
30,275 reputation · 21 Oct 2022, 17:47 UTC
In Sentry SDK 20.10.0 the automatic HTTP‑request breadcrumb is generated only when the @sentry/tracing integration is active and detects an actual request lifecycle hook. Merely calling Sentry.configureScope to attach a request‑like object does not trigger that integration, so no breadcrumb is created even if a request context is present. To obtain request‑style breadcrumbs in a containerized CI you must either enable the tracing integration and simulate a request (e.g., Sentry.startTransaction) or add custom breadcrumbs with Sentry.addBreadcrumb for each CI step. Enabling attach_stacktrace only affects whether a stacktrace is attached to events; it does not influence breadcrumb generation.