diff --git a/MIGRATION.md b/MIGRATION.md index 994557cbadc4..dadca8ed4cc2 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -481,6 +481,24 @@ Sentry.init({ `ignoreSpans` itself is unchanged in shape, but it now takes effect when a span **starts** rather than when the transaction is sent. Matched spans are never recorded at all, which means a matched non-segment span's children are re-parented to its parent instead of being dropped. +#### `ignoreStatusCodes` is deprecated + +The `ignoreStatusCodes` option is deprecated on `httpIntegration` and `httpServerSpansIntegration` (Node and the SDKs built on it) as well as on `denoHttpIntegration` and `denoServeIntegration`. It will be removed in v12, without a direct replacement. + +The filter runs on the finished transaction event, which is no longer supported span streaming. Child spans are sent as they end, before the response status code is known, so a request's spans can no longer be dropped once the status turns out to be uninteresting. The option therefore only has an effect with `traceLifecycle: 'static'`. + +To keep specific requests out of Sentry, decide before they are instrumented: Use `tracesSampler`, or ignore the request via `ignoreIncomingRequests`, which matches on the incoming request instead of on the response: + +```js +Sentry.init({ + integrations: [ + Sentry.httpIntegration({ + ignoreIncomingRequests: urlPath => urlPath.startsWith('/admin'), + }), + ], +}); +``` + #### Opting out of span streaming To keep the previous transaction-based model, set `traceLifecycle: 'static'`: @@ -656,7 +674,8 @@ Sentry.init({ This filter runs on transaction events (`processEvent`), so it only takes effect when `traceLifecycle` is `'static'`. The default `'stream'` lifecycle does not produce transaction events, and typical Deno apps are unaffected. Node's -`httpIntegration` has the same limitation. +`httpIntegration` has the same limitation. For that reason, [`ignoreStatusCodes` is deprecated](#ignorestatuscodes-is-deprecated) +and will be removed in v12. Transactions that are kept now also carry the HTTP status in the top-level `response` context, as in the other server SDKs. @@ -1424,6 +1443,8 @@ Sentry.httpIntegration({ }); ``` +Note that `ignoreStatusCodes` is itself [deprecated](#ignorestatuscodes-is-deprecated) and will be removed in v12. + ### `@sentry/cloudflare` - The `@sentry/cloudflare/nodejs_compat` subpath export was removed. Since `nodejs_compat` is now required for all users, the main `@sentry/cloudflare` entry point includes everything that was previously only available via the subpath. diff --git a/packages/deno/src/integrations/deno-serve.ts b/packages/deno/src/integrations/deno-serve.ts index 527bb1f062fe..156fb9fd8559 100644 --- a/packages/deno/src/integrations/deno-serve.ts +++ b/packages/deno/src/integrations/deno-serve.ts @@ -29,6 +29,11 @@ export type DenoServeIntegrationOptions = { * produce transaction events, so the filter does not run. * * @default `[[401, 404], [301, 303], [305, 399]]` + * + * @deprecated This option only has an effect if `traceLifecycle` is set to `'static'`. With span streaming + * (`traceLifecycle: 'stream'`, the default), the SDK ignores it: child spans are sent as they end, before the + * response status code is known, so a request's spans cannot be dropped retroactively. `ignoreStatusCodes` will be + * removed in v12 of the SDK. */ ignoreStatusCodes?: (number | [number, number])[]; }; @@ -88,6 +93,7 @@ const instrumentedDenoServe = (serve: typeof Deno.serve): typeof Deno.serve => }); const _denoServeIntegration = ((options: DenoServeIntegrationOptions = {}) => { + // oxlint-disable-next-line typescript/no-deprecated const ignoreStatusCodes = options.ignoreStatusCodes ?? DEFAULT_IGNORE_STATUS_CODES; return { diff --git a/packages/deno/src/integrations/http.ts b/packages/deno/src/integrations/http.ts index f696186b9261..f4cfeee81d17 100644 --- a/packages/deno/src/integrations/http.ts +++ b/packages/deno/src/integrations/http.ts @@ -107,6 +107,11 @@ export interface DenoHttpIntegrationOptions { * limitation. * * @default `[[401, 404], [301, 303], [305, 399]]` + * + * @deprecated This option only has an effect if `traceLifecycle` is set to `'static'`. With span streaming + * (`traceLifecycle: 'stream'`, the default), the SDK ignores it: child spans are sent as they end, before the + * response status code is known, so a request's spans cannot be dropped retroactively. `ignoreStatusCodes` will be + * removed in v12 of the SDK. */ ignoreStatusCodes?: (number | [number, number])[]; @@ -146,6 +151,7 @@ export interface DenoHttpIntegrationOptions { const _denoHttpIntegration = ((options: DenoHttpIntegrationOptions = {}) => { const breadcrumbs = options.breadcrumbs ?? true; const tracePropagation = options.tracePropagation ?? true; + // oxlint-disable-next-line typescript/no-deprecated const ignoreStatusCodes = options.ignoreStatusCodes ?? DEFAULT_IGNORE_STATUS_CODES; return { diff --git a/packages/node/src/integrations/http/httpServerSpansIntegration.ts b/packages/node/src/integrations/http/httpServerSpansIntegration.ts index cb9de82677b0..a00d048591a0 100644 --- a/packages/node/src/integrations/http/httpServerSpansIntegration.ts +++ b/packages/node/src/integrations/http/httpServerSpansIntegration.ts @@ -84,7 +84,14 @@ export interface HttpServerSpansIntegrationOptions { * By default, spans with some 3xx and 4xx status codes are ignored (see @default). * Expects an array of status codes or a range of status codes, e.g. [[300,399], 404] would ignore 3xx and 404 status codes. * + * Important: This option is ignored by default! It only has an effect if `traceLifecycle` is set to `'static'`. + * * @default `[[401, 404], [301, 303], [305, 399]]` + * + * @deprecated This option only has an effect if `traceLifecycle` is set to `'static'`. With span streaming + * (`traceLifecycle: 'stream'`, the default), the SDK ignores it: child spans are sent as they end, before the + * response status code is known, so a request's spans cannot be dropped retroactively. `ignoreStatusCodes` will be + * removed in v12 of the SDK, without replacement. */ ignoreStatusCodes?: (number | [number, number])[]; @@ -98,6 +105,7 @@ export interface HttpServerSpansIntegrationOptions { const _httpServerSpansIntegration = ((options: HttpServerSpansIntegrationOptions = {}) => { const ignoreStaticAssets = options.ignoreStaticAssets ?? true; const ignoreIncomingRequests = options.ignoreIncomingRequests; + // oxlint-disable-next-line typescript/no-deprecated const ignoreStatusCodes = options.ignoreStatusCodes ?? DEFAULT_IGNORE_STATUS_CODES; const { onSpanCreated } = options;