@sentry/node 9.7.0 → 9.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/build/cjs/integrations/anr/index.js +1 -1
  2. package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js +56 -41
  3. package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +1 -1
  4. package/build/cjs/integrations/http/index.js +12 -4
  5. package/build/cjs/integrations/http/index.js.map +1 -1
  6. package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
  7. package/build/cjs/integrations/tracing/fastify.js +28 -8
  8. package/build/cjs/integrations/tracing/fastify.js.map +1 -1
  9. package/build/esm/integrations/anr/index.js +1 -1
  10. package/build/esm/integrations/anr/worker-script.js +2 -2
  11. package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js +56 -41
  12. package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +1 -1
  13. package/build/esm/integrations/http/index.js +12 -4
  14. package/build/esm/integrations/http/index.js.map +1 -1
  15. package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
  16. package/build/esm/integrations/local-variables/worker-script.js +2 -2
  17. package/build/esm/integrations/tracing/fastify.js +28 -8
  18. package/build/esm/integrations/tracing/fastify.js.map +1 -1
  19. package/build/esm/package.json +1 -1
  20. package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts.map +1 -1
  21. package/build/types/integrations/http/index.d.ts.map +1 -1
  22. package/build/types/integrations/tracing/fastify.d.ts +58 -2
  23. package/build/types/integrations/tracing/fastify.d.ts.map +1 -1
  24. package/build/types/types.d.ts +18 -0
  25. package/build/types/types.d.ts.map +1 -1
  26. package/build/types-ts3.8/integrations/tracing/fastify.d.ts +58 -2
  27. package/build/types-ts3.8/types.d.ts +18 -0
  28. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"SentryHttpInstrumentationBeforeOtel.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts"],"sourcesContent":["import { VERSION } from '@opentelemetry/core';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport { flush, logger, vercelWaitUntil } from '@sentry/core';\nimport type * as http from 'node:http';\nimport type * as https from 'node:https';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { stealthWrap } from './utils';\n\ntype Http = typeof http;\ntype Https = typeof https;\n\n/**\n * A Sentry specific http instrumentation that is applied before the otel instrumentation.\n */\nexport class SentryHttpInstrumentationBeforeOtel extends InstrumentationBase {\n public constructor() {\n super('@sentry/instrumentation-http-before-otel', VERSION, {});\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n /** Get the instrumentation for the http module. */\n private _getHttpInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition('http', ['*'], (moduleExports: Http): Http => {\n // Patch incoming requests\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n return moduleExports;\n });\n }\n\n /** Get the instrumentation for the https module. */\n private _getHttpsInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition('https', ['*'], (moduleExports: Https): Https => {\n // Patch incoming requests\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n return moduleExports;\n });\n }\n\n /**\n * Patch the incoming request function for request isolation.\n */\n private _getPatchIncomingRequestFunction(): (\n original: (event: string, ...args: unknown[]) => boolean,\n ) => (this: unknown, event: string, ...args: unknown[]) => boolean {\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, ...args: [event: string, ...args: unknown[]]): boolean {\n // Only traces request events\n if (args[0] !== 'request') {\n return original.apply(this, args);\n }\n\n const response = args[1] as http.OutgoingMessage;\n\n patchResponseToFlushOnServerlessPlatforms(response);\n\n return original.apply(this, args);\n };\n };\n }\n}\n\nfunction patchResponseToFlushOnServerlessPlatforms(res: http.OutgoingMessage): void {\n // Freely extend this function with other platforms if necessary\n if (process.env.VERCEL) {\n let markOnEndDone = (): void => undefined;\n const onEndDonePromise = new Promise<void>(res => {\n markOnEndDone = res;\n });\n\n res.on('close', () => {\n markOnEndDone();\n });\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n res.end = new Proxy(res.end, {\n apply(target, thisArg, argArray) {\n vercelWaitUntil(\n new Promise<void>(finishWaitUntil => {\n // Define a timeout that unblocks the lambda just to be safe so we're not indefinitely keeping it alive, exploding server bills\n const timeout = setTimeout(() => {\n finishWaitUntil();\n }, 2000);\n\n onEndDonePromise\n .then(() => {\n DEBUG_BUILD && logger.log('Flushing events before Vercel Lambda freeze');\n return flush(2000);\n })\n .then(\n () => {\n clearTimeout(timeout);\n finishWaitUntil();\n },\n e => {\n clearTimeout(timeout);\n DEBUG_BUILD && logger.log('Error while flushing events for Vercel:\\n', e);\n finishWaitUntil();\n },\n );\n }),\n );\n\n return target.apply(thisArg, argArray);\n },\n });\n }\n}\n"],"names":[],"mappings":";;;;;;AAWA;AACA;AACA;AACO,MAAM,mCAAoC,SAAQ,mBAAoB,CAAA;AAC7E,GAAS,WAAW,GAAG;AACvB,IAAI,KAAK,CAAC,0CAA0C,EAAE,OAAO,EAAE,EAAE,CAAC;AAClE;;AAEA;AACA,GAAS,IAAI,GAA+E;AAC5F,IAAI,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,IAAI,CAAC,uBAAuB,EAAE,CAAC;AAC5E;;AAEA;AACA,GAAU,uBAAuB,GAAwC;AACzE,IAAI,OAAO,IAAI,mCAAmC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,aAAa,KAAiB;AACjG;AACA,MAAM,WAAW,CAAC,aAAa,CA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AAa,EAAE;AACrB,KAAK,CAAC;;AAEN;AACA,IAAI,GAAG,CAAC,GAAA,GAAM,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;AACjC,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE;AACvC,QAAQ,eAAe;AACvB,UAAU,IAAI,OAAO,CAAO,eAAA,IAAmB;AAC/C;AACA,YAAY,MAAM,OAAQ,GAAE,UAAU,CAAC,MAAM;AAC7C,cAAc,eAAe,EAAE;AAC/B,aAAa,EAAE,IAAI,CAAC;;AAEpB,YAAY;AACZ,eAAe,IAAI,CAAC,MAAM;AAC1B,gBAAgB,eAAe,MAAM,CAAC,GAAG,CAAC,6CAA6C,CAAC;AACxF,gBAAgB,OAAO,KAAK,CAAC,IAAI,CAAC;AAClC,eAAe;AACf,eAAe,IAAI;AACnB,gBAAgB,MAAM;AACtB,kBAAkB,YAAY,CAAC,OAAO,CAAC;AACvC,kBAAkB,eAAe,EAAE;AACnC,iBAAiB;AACjB,gBAAgB,KAAK;AACrB,kBAAkB,YAAY,CAAC,OAAO,CAAC;AACvC,kBAAkB,WAAA,IAAe,MAAM,CAAC,GAAG,CAAC,2CAA2C,EAAE,CAAC,CAAC;AAC3F,kBAAkB,eAAe,EAAE;AACnC,iBAAiB;AACjB,eAAe;AACf,WAAW,CAAC;AACZ,SAAS;;AAET,QAAQ,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC;AAC9C,OAAO;AACP,KAAK,CAAC;AACN;AACA;;;;"}
1
+ {"version":3,"file":"SentryHttpInstrumentationBeforeOtel.js","sources":["../../../../src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts"],"sourcesContent":["import { VERSION } from '@opentelemetry/core';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';\nimport { flush, logger, vercelWaitUntil } from '@sentry/core';\nimport type * as http from 'node:http';\nimport type * as https from 'node:https';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { stealthWrap } from './utils';\n\ntype Http = typeof http;\ntype Https = typeof https;\n\n// The reason this \"before OTEL\" integration even exists is due to timing reasons. We need to be able to register a\n// `res.on('close')` handler **after** OTEL registers its own handler (which it uses to end spans), so that we can do\n// something (ie. flush) after OTEL has ended a span for a request. If you think about it like an onion:\n//\n// (Sentry after OTEL instrumentation\n// (OTEL instrumentation\n// (Sentry before OTEL instrumentation\n// (orig HTTP request handler))))\n//\n// registering an instrumentation before OTEL allows us to do this for incoming requests.\n\n/**\n * A Sentry specific http instrumentation that is applied before the otel instrumentation.\n */\nexport class SentryHttpInstrumentationBeforeOtel extends InstrumentationBase {\n public constructor() {\n super('@sentry/instrumentation-http-before-otel', VERSION, {});\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n /** Get the instrumentation for the http module. */\n private _getHttpInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition('http', ['*'], (moduleExports: Http): Http => {\n // Patch incoming requests\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n return moduleExports;\n });\n }\n\n /** Get the instrumentation for the https module. */\n private _getHttpsInstrumentation(): InstrumentationNodeModuleDefinition {\n return new InstrumentationNodeModuleDefinition('https', ['*'], (moduleExports: Https): Https => {\n // Patch incoming requests\n stealthWrap(moduleExports.Server.prototype, 'emit', this._getPatchIncomingRequestFunction());\n\n return moduleExports;\n });\n }\n\n /**\n * Patch the incoming request function for request isolation.\n */\n private _getPatchIncomingRequestFunction(): (\n original: (event: string, ...args: unknown[]) => boolean,\n ) => (this: unknown, event: string, ...args: unknown[]) => boolean {\n return (\n original: (event: string, ...args: unknown[]) => boolean,\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return function incomingRequest(this: unknown, ...args: [event: string, ...args: unknown[]]): boolean {\n // Only traces request events\n if (args[0] !== 'request') {\n return original.apply(this, args);\n }\n\n const response = args[1] as http.OutgoingMessage;\n\n patchResponseToFlushOnServerlessPlatforms(response);\n\n return original.apply(this, args);\n };\n };\n }\n}\n\nfunction patchResponseToFlushOnServerlessPlatforms(res: http.OutgoingMessage): void {\n // Freely extend this function with other platforms if necessary\n if (process.env.VERCEL) {\n // In some cases res.end does not seem to be defined leading to errors if passed to Proxy\n // https://github.com/getsentry/sentry-javascript/issues/15759\n if (typeof res.end === 'function') {\n let markOnEndDone = (): void => undefined;\n const onEndDonePromise = new Promise<void>(res => {\n markOnEndDone = res;\n });\n\n res.on('close', () => {\n markOnEndDone();\n });\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n res.end = new Proxy(res.end, {\n apply(target, thisArg, argArray) {\n vercelWaitUntil(\n new Promise<void>(finishWaitUntil => {\n // Define a timeout that unblocks the lambda just to be safe so we're not indefinitely keeping it alive, exploding server bills\n const timeout = setTimeout(() => {\n finishWaitUntil();\n }, 2000);\n\n onEndDonePromise\n .then(() => {\n DEBUG_BUILD && logger.log('Flushing events before Vercel Lambda freeze');\n return flush(2000);\n })\n .then(\n () => {\n clearTimeout(timeout);\n finishWaitUntil();\n },\n e => {\n clearTimeout(timeout);\n DEBUG_BUILD && logger.log('Error while flushing events for Vercel:\\n', e);\n finishWaitUntil();\n },\n );\n }),\n );\n\n return target.apply(thisArg, argArray);\n },\n });\n }\n }\n}\n"],"names":[],"mappings":";;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAM,mCAAoC,SAAQ,mBAAoB,CAAA;AAC7E,GAAS,WAAW,GAAG;AACvB,IAAI,KAAK,CAAC,0CAA0C,EAAE,OAAO,EAAE,EAAE,CAAC;AAClE;;AAEA;AACA,GAAS,IAAI,GAA+E;AAC5F,IAAI,OAAO,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,IAAI,CAAC,uBAAuB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@@ -54,7 +54,17 @@ const httpIntegration = defineIntegration((options = {}) => {
54
54
  return {
55
55
  name: INTEGRATION_NAME,
56
56
  setupOnce() {
57
- instrumentSentryHttpBeforeOtel();
57
+ // Below, we instrument the Node.js HTTP API three times. 2 times Sentry-specific, 1 time OTEL specific.
58
+ // Due to timing reasons, we sometimes need to apply Sentry instrumentation _before_ we apply the OTEL
59
+ // instrumentation (e.g. to flush on serverless platforms), and sometimes we need to apply Sentry instrumentation
60
+ // _after_ we apply OTEL instrumentation (e.g. for isolation scope handling and breadcrumbs).
61
+
62
+ // This is Sentry-specific instrumentation that is applied _before_ any OTEL instrumentation.
63
+ if (process.env.VERCEL) {
64
+ // Currently this instrumentation only does something when deployed on Vercel, so to save some overhead, we short circuit adding it here only for Vercel.
65
+ // If it's functionality is extended in the future, feel free to remove the if statement and this comment.
66
+ instrumentSentryHttpBeforeOtel();
67
+ }
58
68
 
59
69
  const instrumentSpans = _shouldInstrumentSpans(options, getClient()?.getOptions());
60
70
 
@@ -64,9 +74,7 @@ const httpIntegration = defineIntegration((options = {}) => {
64
74
  instrumentOtelHttp(instrumentationConfig);
65
75
  }
66
76
 
67
- // This is the Sentry-specific instrumentation that isolates requests & creates breadcrumbs
68
- // Note that this _has_ to be wrapped after the OTEL instrumentation,
69
- // otherwise the isolation will not work correctly
77
+ // This is Sentry-specific instrumentation that is applied _after_ any OTEL instrumentation.
70
78
  instrumentSentryHttp({
71
79
  ...options,
72
80
  // If spans are not instrumented, it means the HttpInstrumentation has not been added
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/integrations/http/index.ts"],"sourcesContent":["import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';\nimport { diag } from '@opentelemetry/api';\nimport type { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport type { Span } from '@sentry/core';\nimport { defineIntegration, getClient } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { NodeClient } from '../../sdk/client';\nimport type { HTTPModuleRequestIncomingMessage } from '../../transports/http-module';\nimport type { NodeClientOptions } from '../../types';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport type { SentryHttpInstrumentationOptions } from './SentryHttpInstrumentation';\nimport { SentryHttpInstrumentation } from './SentryHttpInstrumentation';\nimport { SentryHttpInstrumentationBeforeOtel } from './SentryHttpInstrumentationBeforeOtel';\n\nconst INTEGRATION_NAME = 'Http';\n\nconst INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';\n\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n *\n * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;\n responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => void;\n\n /**\n * You can pass any configuration through to the underlying instrumentation.\n * Note that there are no semver guarantees for this!\n */\n _experimentalConfig?: ConstructorParameters<typeof HttpInstrumentation>[0];\n };\n}\n\nconst instrumentSentryHttpBeforeOtel = generateInstrumentOnce(`${INTEGRATION_NAME}.sentry-before-otel`, () => {\n return new SentryHttpInstrumentationBeforeOtel();\n});\n\nconst instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(\n `${INTEGRATION_NAME}.sentry`,\n options => {\n return new SentryHttpInstrumentation(options);\n },\n);\n\nexport const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConfig>(INTEGRATION_NAME, config => {\n const instrumentation = new HttpInstrumentation(config);\n\n // We want to update the logger namespace so we can better identify what is happening here\n try {\n instrumentation['_diag'] = diag.createComponentLogger({\n namespace: INSTRUMENTATION_NAME,\n });\n // @ts-expect-error We are writing a read-only property here...\n instrumentation.instrumentationName = INSTRUMENTATION_NAME;\n } catch {\n // ignore errors here...\n }\n\n return instrumentation;\n});\n\n/** Exported only for tests. */\nexport function _shouldInstrumentSpans(options: HttpOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true`\n return typeof options.spans === 'boolean' ? options.spans : !clientOptions.skipOpenTelemetrySetup;\n}\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentSentryHttpBeforeOtel();\n\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n\n // This is the Sentry-specific instrumentation that isolates requests & creates breadcrumbs\n // Note that this _has_ to be wrapped after the OTEL instrumentation,\n // otherwise the isolation will not work correctly\n instrumentSentryHttp({\n ...options,\n // If spans are not instrumented, it means the HttpInstrumentation has not been added\n // In that case, we want to handle incoming trace extraction ourselves\n extractIncomingTraceFromHeader: !instrumentSpans,\n });\n },\n };\n});\n\n/**\n * Determines if @param req is a ClientRequest, meaning the request was created within the express app\n * and it's an outgoing request.\n * Checking for properties instead of using `instanceOf` to avoid importing the request classes.\n */\nfunction _isClientRequest(req: ClientRequest | HTTPModuleRequestIncomingMessage): req is ClientRequest {\n return 'outputData' in req && 'outputSize' in req && !('client' in req) && !('statusCode' in req);\n}\n\n/**\n * Detects if an incoming request is a prefetch request.\n */\nfunction isKnownPrefetchRequest(req: HTTPModuleRequestIncomingMessage): boolean {\n // Currently only handles Next.js prefetch requests but may check other frameworks in the future.\n return req.headers['next-router-prefetch'] === '1';\n}\n\nfunction getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrumentationConfig {\n const instrumentationConfig = {\n ...options.instrumentation?._experimentalConfig,\n\n disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,\n\n ignoreOutgoingRequestHook: request => {\n const url = getRequestUrl(request);\n\n if (!url) {\n return false;\n }\n\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n if (_ignoreOutgoingRequests?.(url, request)) {\n return true;\n }\n\n return false;\n },\n\n ignoreIncomingRequestHook: request => {\n // request.url is the only property that holds any information about the url\n // it only consists of the URL path and query string (if any)\n const urlPath = request.url;\n\n const method = request.method?.toUpperCase();\n // We do not capture OPTIONS/HEAD requests as transactions\n if (method === 'OPTIONS' || method === 'HEAD') {\n return true;\n }\n\n const _ignoreIncomingRequests = options.ignoreIncomingRequests;\n if (urlPath && _ignoreIncomingRequests?.(urlPath, request)) {\n return true;\n }\n\n return false;\n },\n\n requireParentforOutgoingSpans: false,\n requireParentforIncomingSpans: false,\n requestHook: (span, req) => {\n addOriginToSpan(span, 'auto.http.otel.http');\n if (!_isClientRequest(req) && isKnownPrefetchRequest(req)) {\n span.setAttribute('sentry.http.prefetch', true);\n }\n\n options.instrumentation?.requestHook?.(span, req);\n },\n responseHook: (span, res) => {\n options.instrumentation?.responseHook?.(span, res);\n },\n applyCustomAttributesOnSpan: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => {\n options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);\n },\n } satisfies HttpInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":[],"mappings":";;;;;;;;;AAgBA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B,MAAM,oBAAA,GAAuB,oDAAoD;;AAmFjF,MAAM,8BAA+B,GAAE,sBAAsB,CAAC,CAAC,EAAA,gBAAA,CAAA,mBAAA,CAAA,EAAA,MAAA;AACA,EAAA,OAAA,IAAA,mCAAA,EAAA;AACA,CAAA,CAAA;;AA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AAA,OAAA,IAAA,uBAAA,GAAA,OAAA,EAAA,OAAA,CAAA,EAAA;AACA,QAAA,OAAA,IAAA;AACA;;AAEA,MAAA,OAAA,KAAA;AACA,KAAA;;AAEA,IAAA,6BAAA,EAAA,KAAA;AACA,IAAA,6BAAA,EAAA,KAAA;AACA,IAAA,WAAA,EAAA,CAAA,IAAA,EAAA,GAAA,KAAA;AACA,MAAA,eAAA,CAAA,IAAA,EAAA,qBAAA,CAAA;AACA,MAAA,IAAA,CAAA,gBAAA,CAAA,GAAA,CAAA,IAAA,sBAAA,CAAA,GAAA,CAAA,EAAA;AACA,QAAA,IAAA,CAAA,YAAA,CAAA,sBAAA,EAAA,IAAA,CAAA;AACA;;AAEA,MAAA,OAAA,CAAA,eAAA,EAAA,WAAA,GAAA,IAAA,EAAA,GAAA,CAAA;AACA,KAAA;AACA,IAAA,YAAA,EAAA,CAAA,IAAA,EAAA,GAAA,KAAA;AACA,MAAA,OAAA,CAAA,eAAA,EAAA,YAAA,GAAA,IAAA,EAAA,GAAA,CAAA;AACA,KAAA;AACA,IAAA,2BAAA,EAAA;AACA,MAAA,IAAA;AACA,MAAA,OAAA;AACA,MAAA,QAAA;AACA,SAAA;AACA,MAAA,OAAA,CAAA,eAAA,EAAA,2BAAA,GAAA,IAAA,EAAA,OAAA,EAAA,QAAA,CAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAA,OAAA,qBAAA;AACA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/integrations/http/index.ts"],"sourcesContent":["import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';\nimport { diag } from '@opentelemetry/api';\nimport type { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport type { Span } from '@sentry/core';\nimport { defineIntegration, getClient } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { NodeClient } from '../../sdk/client';\nimport type { HTTPModuleRequestIncomingMessage } from '../../transports/http-module';\nimport type { NodeClientOptions } from '../../types';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport type { SentryHttpInstrumentationOptions } from './SentryHttpInstrumentation';\nimport { SentryHttpInstrumentation } from './SentryHttpInstrumentation';\nimport { SentryHttpInstrumentationBeforeOtel } from './SentryHttpInstrumentationBeforeOtel';\n\nconst INTEGRATION_NAME = 'Http';\n\nconst INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';\n\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n *\n * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;\n responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => void;\n\n /**\n * You can pass any configuration through to the underlying instrumentation.\n * Note that there are no semver guarantees for this!\n */\n _experimentalConfig?: ConstructorParameters<typeof HttpInstrumentation>[0];\n };\n}\n\nconst instrumentSentryHttpBeforeOtel = generateInstrumentOnce(`${INTEGRATION_NAME}.sentry-before-otel`, () => {\n return new SentryHttpInstrumentationBeforeOtel();\n});\n\nconst instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(\n `${INTEGRATION_NAME}.sentry`,\n options => {\n return new SentryHttpInstrumentation(options);\n },\n);\n\nexport const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConfig>(INTEGRATION_NAME, config => {\n const instrumentation = new HttpInstrumentation(config);\n\n // We want to update the logger namespace so we can better identify what is happening here\n try {\n instrumentation['_diag'] = diag.createComponentLogger({\n namespace: INSTRUMENTATION_NAME,\n });\n // @ts-expect-error We are writing a read-only property here...\n instrumentation.instrumentationName = INSTRUMENTATION_NAME;\n } catch {\n // ignore errors here...\n }\n\n return instrumentation;\n});\n\n/** Exported only for tests. */\nexport function _shouldInstrumentSpans(options: HttpOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true`\n return typeof options.spans === 'boolean' ? options.spans : !clientOptions.skipOpenTelemetrySetup;\n}\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // Below, we instrument the Node.js HTTP API three times. 2 times Sentry-specific, 1 time OTEL specific.\n // Due to timing reasons, we sometimes need to apply Sentry instrumentation _before_ we apply the OTEL\n // instrumentation (e.g. to flush on serverless platforms), and sometimes we need to apply Sentry instrumentation\n // _after_ we apply OTEL instrumentation (e.g. for isolation scope handling and breadcrumbs).\n\n // This is Sentry-specific instrumentation that is applied _before_ any OTEL instrumentation.\n if (process.env.VERCEL) {\n // Currently this instrumentation only does something when deployed on Vercel, so to save some overhead, we short circuit adding it here only for Vercel.\n // If it's functionality is extended in the future, feel free to remove the if statement and this comment.\n instrumentSentryHttpBeforeOtel();\n }\n\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n\n // This is Sentry-specific instrumentation that is applied _after_ any OTEL instrumentation.\n instrumentSentryHttp({\n ...options,\n // If spans are not instrumented, it means the HttpInstrumentation has not been added\n // In that case, we want to handle incoming trace extraction ourselves\n extractIncomingTraceFromHeader: !instrumentSpans,\n });\n },\n };\n});\n\n/**\n * Determines if @param req is a ClientRequest, meaning the request was created within the express app\n * and it's an outgoing request.\n * Checking for properties instead of using `instanceOf` to avoid importing the request classes.\n */\nfunction _isClientRequest(req: ClientRequest | HTTPModuleRequestIncomingMessage): req is ClientRequest {\n return 'outputData' in req && 'outputSize' in req && !('client' in req) && !('statusCode' in req);\n}\n\n/**\n * Detects if an incoming request is a prefetch request.\n */\nfunction isKnownPrefetchRequest(req: HTTPModuleRequestIncomingMessage): boolean {\n // Currently only handles Next.js prefetch requests but may check other frameworks in the future.\n return req.headers['next-router-prefetch'] === '1';\n}\n\nfunction getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrumentationConfig {\n const instrumentationConfig = {\n ...options.instrumentation?._experimentalConfig,\n\n disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,\n\n ignoreOutgoingRequestHook: request => {\n const url = getRequestUrl(request);\n\n if (!url) {\n return false;\n }\n\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n if (_ignoreOutgoingRequests?.(url, request)) {\n return true;\n }\n\n return false;\n },\n\n ignoreIncomingRequestHook: request => {\n // request.url is the only property that holds any information about the url\n // it only consists of the URL path and query string (if any)\n const urlPath = request.url;\n\n const method = request.method?.toUpperCase();\n // We do not capture OPTIONS/HEAD requests as transactions\n if (method === 'OPTIONS' || method === 'HEAD') {\n return true;\n }\n\n const _ignoreIncomingRequests = options.ignoreIncomingRequests;\n if (urlPath && _ignoreIncomingRequests?.(urlPath, request)) {\n return true;\n }\n\n return false;\n },\n\n requireParentforOutgoingSpans: false,\n requireParentforIncomingSpans: false,\n requestHook: (span, req) => {\n addOriginToSpan(span, 'auto.http.otel.http');\n if (!_isClientRequest(req) && isKnownPrefetchRequest(req)) {\n span.setAttribute('sentry.http.prefetch', true);\n }\n\n options.instrumentation?.requestHook?.(span, req);\n },\n responseHook: (span, res) => {\n options.instrumentation?.responseHook?.(span, res);\n },\n applyCustomAttributesOnSpan: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => {\n options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);\n },\n } satisfies HttpInstrumentationConfig;\n\n return instrumentationConfig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,7 +4,7 @@ import { isDebuggerEnabled } from '../../utils/debug.js';
4
4
  import { LOCAL_VARIABLES_KEY, functionNamesMatch } from './common.js';
5
5
 
6
6
  // This string is a placeholder that gets overwritten with the worker code.
7
- const base64WorkerScript = 'LyohIEBzZW50cnkvbm9kZSA5LjcuMCAoNTI2ZWQ4ZSkgfCBodHRwczovL2dpdGh1Yi5jb20vZ2V0c2VudHJ5L3NlbnRyeS1qYXZhc2NyaXB0ICovCmltcG9ydHtTZXNzaW9uIGFzIGV9ZnJvbSJub2RlOmluc3BlY3Rvci9wcm9taXNlcyI7aW1wb3J0e3dvcmtlckRhdGEgYXMgdH1mcm9tIm5vZGU6d29ya2VyX3RocmVhZHMiO2NvbnN0IG49Z2xvYmFsVGhpcyxvPSJ1bmRlZmluZWQiPT10eXBlb2YgX19TRU5UUllfREVCVUdfX3x8X19TRU5UUllfREVCVUdfXyxpPSI5LjcuMCI7Y29uc3QgYT1bImRlYnVnIiwiaW5mbyIsIndhcm4iLCJlcnJvciIsImxvZyIsImFzc2VydCIsInRyYWNlIl0scz17fTtmdW5jdGlvbiBjKGUpe2lmKCEoImNvbnNvbGUiaW4gbikpcmV0dXJuIGUoKTtjb25zdCB0PW4uY29uc29sZSxvPXt9LGk9T2JqZWN0LmtleXMocyk7aS5mb3JFYWNoKChlPT57Y29uc3Qgbj1zW2VdO29bZV09dFtlXSx0W2VdPW59KSk7dHJ5e3JldHVybiBlKCl9ZmluYWxseXtpLmZvckVhY2goKGU9Pnt0W2VdPW9bZV19KSl9fSFmdW5jdGlvbihlLHQsbz1uKXtjb25zdCBhPW8uX19TRU5UUllfXz1vLl9fU0VOVFJZX198fHt9LHM9YVtpXT1hW2ldfHx7fTtzW2VdfHwoc1tlXT10KCkpfSgibG9nZ2VyIiwoZnVuY3Rpb24oKXtsZXQgZT0hMTtjb25zdCB0PXtlbmFibGU6KCk9PntlPSEwfSxkaXNhYmxlOigpPT57ZT0hMX0saXNFbmFibGVkOigpPT5lfTtyZXR1cm4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tlfSBzZWNvbmRzLmApLGF3YWl0IHQucG9zdCgiRGVidWdnZXIuc2V0UGF1c2VPbkV4Y2VwdGlvbnMiLHtzdGF0ZToidW5jYXVnaHQifSl9KSl9fSkoKS5jYXRjaCgoZT0+e2woIkZhaWxlZCB0byBzdGFydCBkZWJ1Z2dlciIsZSl9KSksc2V0SW50ZXJ2YWwoKCgpPT57fSksMWU0KTs=';
8
8
 
9
9
  function log(...args) {
10
10
  logger.log('[LocalVariables]', ...args);
@@ -1,2 +1,2 @@
1
- /*! @sentry/node 9.7.0 (526ed8e) | https://github.com/getsentry/sentry-javascript */
2
- import{Session as e}from"node:inspector/promises";import{workerData as t}from"node:worker_threads";const n=globalThis,o="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,i="9.7.0";const a=["debug","info","warn","error","log","assert","trace"],s={};function c(e){if(!("console"in n))return e();const t=n.console,o={},i=Object.keys(s);i.forEach((e=>{const n=s[e];o[e]=t[e],t[e]=n}));try{return e()}finally{i.forEach((e=>{t[e]=o[e]}))}}!function(e,t,o=n){const a=o.__SENTRY__=o.__SENTRY__||{},s=a[i]=a[i]||{};s[e]||(s[e]=t())}("logger",(function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return o?a.forEach((o=>{t[o]=(...t)=>{e&&c((()=>{n.console[o](`Sentry Logger [${o}]:`,...t)}))}})):a.forEach((e=>{t[e]=()=>{}})),t}));const r="__SENTRY_ERROR_LOCAL_VARIABLES__";const u=t;function l(...e){u.debug&&c((()=>console.log("[LocalVariables Worker]",...e)))}async function f(e,t,n,o){const i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.result.filter((e=>"length"!==e.name&&!isNaN(parseInt(e.name,10)))).sort(((e,t)=>parseInt(e.name,10)-parseInt(t.name,10))).map((e=>e.value?.value))}async function g(e,t,n,o){const i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.result.map((e=>[e.name,e.value?.value])).reduce(((e,[t,n])=>(e[t]=n,e)),{})}function d(e,t){e.value&&("value"in e.value?void 0===e.value.value||null===e.value.value?t[e.name]=`<${e.value.value}>`:t[e.name]=e.value.value:"description"in e.value&&"function"!==e.value.type?t[e.name]=`<${e.value.description}>`:"undefined"===e.value.type&&(t[e.name]="<undefined>"))}async function b(e,t){const n=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0}),o={};for(const t of n.result)if(t.value?.objectId&&"Array"===t.value.className){const n=t.value.objectId;await f(e,n,t.name,o)}else if(t.value?.objectId&&"Object"===t.value.className){const n=t.value.objectId;await g(e,n,t.name,o)}else t.value&&d(t,o);return o}let p;(async function(){const t=new e;t.connectToMainThread(),l("Connected to main thread");let n=!1;t.on("Debugger.resumed",(()=>{n=!1})),t.on("Debugger.paused",(e=>{n=!0,async function(e,{reason:t,data:{objectId:n},callFrames:o}){if("exception"!==t&&"promiseRejection"!==t)return;if(p?.(),null==n)return;const i=[];for(let t=0;t<o.length;t++){const{scopeChain:n,functionName:a,this:s}=o[t],c=n.find((e=>"local"===e.type)),r="global"!==s.className&&s.className?`${s.className}.${a}`:a;if(void 0===c?.object.objectId)i[t]={function:r};else{const n=await b(e,c.object.objectId);i[t]={function:r,vars:n}}}await e.post("Runtime.callFunctionOn",{functionDeclaration:`function() { this.${r} = this.${r} || ${JSON.stringify(i)}; }`,silent:!0,objectId:n}),await e.post("Runtime.releaseObject",{objectId:n})}(t,e.params).then((async()=>{n&&await t.post("Debugger.resume")}),(async e=>{n&&await t.post("Debugger.resume")}))})),await t.post("Debugger.enable");const o=!1!==u.captureAllExceptions;if(await t.post("Debugger.setPauseOnExceptions",{state:o?"all":"uncaught"}),o){const e=u.maxExceptionsPerSecond||50;p=function(e,t,n){let o=0,i=5,a=0;return setInterval((()=>{0===a?o>e&&(i*=2,n(i),i>86400&&(i=86400),a=i):(a-=1,0===a&&t()),o=0}),1e3).unref(),()=>{o+=1}}(e,(async()=>{l("Rate-limit lifted."),await t.post("Debugger.setPauseOnExceptions",{state:"all"})}),(async e=>{l(`Rate-limit exceeded. Disabling capturing of caught exceptions for ${e} seconds.`),await t.post("Debugger.setPauseOnExceptions",{state:"uncaught"})}))}})().catch((e=>{l("Failed to start debugger",e)})),setInterval((()=>{}),1e4);
1
+ /*! @sentry/node 9.9.0 (43c4c83) | https://github.com/getsentry/sentry-javascript */
2
+ import{Session as e}from"node:inspector/promises";import{workerData as t}from"node:worker_threads";const n=globalThis,o="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,i="9.9.0";const a=["debug","info","warn","error","log","assert","trace"],s={};function c(e){if(!("console"in n))return e();const t=n.console,o={},i=Object.keys(s);i.forEach((e=>{const n=s[e];o[e]=t[e],t[e]=n}));try{return e()}finally{i.forEach((e=>{t[e]=o[e]}))}}!function(e,t,o=n){const a=o.__SENTRY__=o.__SENTRY__||{},s=a[i]=a[i]||{};s[e]||(s[e]=t())}("logger",(function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return o?a.forEach((o=>{t[o]=(...t)=>{e&&c((()=>{n.console[o](`Sentry Logger [${o}]:`,...t)}))}})):a.forEach((e=>{t[e]=()=>{}})),t}));const r="__SENTRY_ERROR_LOCAL_VARIABLES__";const u=t;function l(...e){u.debug&&c((()=>console.log("[LocalVariables Worker]",...e)))}async function f(e,t,n,o){const i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.result.filter((e=>"length"!==e.name&&!isNaN(parseInt(e.name,10)))).sort(((e,t)=>parseInt(e.name,10)-parseInt(t.name,10))).map((e=>e.value?.value))}async function g(e,t,n,o){const i=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=i.result.map((e=>[e.name,e.value?.value])).reduce(((e,[t,n])=>(e[t]=n,e)),{})}function d(e,t){e.value&&("value"in e.value?void 0===e.value.value||null===e.value.value?t[e.name]=`<${e.value.value}>`:t[e.name]=e.value.value:"description"in e.value&&"function"!==e.value.type?t[e.name]=`<${e.value.description}>`:"undefined"===e.value.type&&(t[e.name]="<undefined>"))}async function b(e,t){const n=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0}),o={};for(const t of n.result)if(t.value?.objectId&&"Array"===t.value.className){const n=t.value.objectId;await f(e,n,t.name,o)}else if(t.value?.objectId&&"Object"===t.value.className){const n=t.value.objectId;await g(e,n,t.name,o)}else t.value&&d(t,o);return o}let p;(async function(){const t=new e;t.connectToMainThread(),l("Connected to main thread");let n=!1;t.on("Debugger.resumed",(()=>{n=!1})),t.on("Debugger.paused",(e=>{n=!0,async function(e,{reason:t,data:{objectId:n},callFrames:o}){if("exception"!==t&&"promiseRejection"!==t)return;if(p?.(),null==n)return;const i=[];for(let t=0;t<o.length;t++){const{scopeChain:n,functionName:a,this:s}=o[t],c=n.find((e=>"local"===e.type)),r="global"!==s.className&&s.className?`${s.className}.${a}`:a;if(void 0===c?.object.objectId)i[t]={function:r};else{const n=await b(e,c.object.objectId);i[t]={function:r,vars:n}}}await e.post("Runtime.callFunctionOn",{functionDeclaration:`function() { this.${r} = this.${r} || ${JSON.stringify(i)}; }`,silent:!0,objectId:n}),await e.post("Runtime.releaseObject",{objectId:n})}(t,e.params).then((async()=>{n&&await t.post("Debugger.resume")}),(async e=>{n&&await t.post("Debugger.resume")}))})),await t.post("Debugger.enable");const o=!1!==u.captureAllExceptions;if(await t.post("Debugger.setPauseOnExceptions",{state:o?"all":"uncaught"}),o){const e=u.maxExceptionsPerSecond||50;p=function(e,t,n){let o=0,i=5,a=0;return setInterval((()=>{0===a?o>e&&(i*=2,n(i),i>86400&&(i=86400),a=i):(a-=1,0===a&&t()),o=0}),1e3).unref(),()=>{o+=1}}(e,(async()=>{l("Rate-limit lifted."),await t.post("Debugger.setPauseOnExceptions",{state:"all"})}),(async e=>{l(`Rate-limit exceeded. Disabling capturing of caught exceptions for ${e} seconds.`),await t.post("Debugger.setPauseOnExceptions",{state:"uncaught"})}))}})().catch((e=>{l("Failed to start debugger",e)})),setInterval((()=>{}),1e4);
@@ -3,7 +3,13 @@ import { defineIntegration, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_A
3
3
  import { generateInstrumentOnce } from '../../otel/instrument.js';
4
4
  import { ensureIsWrapped } from '../../utils/ensureIsWrapped.js';
5
5
 
6
- // We inline the types we care about here
6
+ /**
7
+ * Minimal request type containing properties around route information.
8
+ * Works for Fastify 3, 4 and presumably 5.
9
+ *
10
+ * Based on https://github.com/fastify/fastify/blob/ce3811f5f718be278bbcd4392c615d64230065a6/types/request.d.ts
11
+ */
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
13
 
8
14
  const INTEGRATION_NAME = 'Fastify';
9
15
 
@@ -45,10 +51,22 @@ const _fastifyIntegration = (() => {
45
51
  */
46
52
  const fastifyIntegration = defineIntegration(_fastifyIntegration);
47
53
 
54
+ /**
55
+ * Default function to determine if an error should be sent to Sentry
56
+ *
57
+ * 3xx and 4xx errors are not sent by default.
58
+ */
59
+ function defaultShouldHandleError(_error, _request, reply) {
60
+ const statusCode = reply.statusCode;
61
+ // 3xx and 4xx errors are not sent by default.
62
+ return statusCode >= 500 || statusCode <= 299;
63
+ }
64
+
48
65
  /**
49
66
  * Add an Fastify error handler to capture errors to Sentry.
50
67
  *
51
68
  * @param fastify The Fastify instance to which to add the error handler
69
+ * @param options Configuration options for the handler
52
70
  *
53
71
  * @example
54
72
  * ```javascript
@@ -64,23 +82,25 @@ const fastifyIntegration = defineIntegration(_fastifyIntegration);
64
82
  * app.listen({ port: 3000 });
65
83
  * ```
66
84
  */
67
- function setupFastifyErrorHandler(fastify) {
85
+ function setupFastifyErrorHandler(fastify, options) {
86
+ const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;
87
+
68
88
  const plugin = Object.assign(
69
89
  function (fastify, _options, done) {
70
- fastify.addHook('onError', async (_request, _reply, error) => {
71
- captureException(error);
90
+ fastify.addHook('onError', async (request, reply, error) => {
91
+ if (shouldHandleError(error, request, reply)) {
92
+ captureException(error);
93
+ }
72
94
  });
73
95
 
74
96
  // registering `onRequest` hook here instead of using Otel `onRequest` callback b/c `onRequest` hook
75
97
  // is ironically called in the fastify `preHandler` hook which is called later in the lifecycle:
76
98
  // https://fastify.dev/docs/latest/Reference/Lifecycle/
77
99
  fastify.addHook('onRequest', async (request, _reply) => {
78
- const reqWithRouteInfo = request ;
79
-
80
100
  // Taken from Otel Fastify instrumentation:
81
101
  // https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts#L94-L96
82
- const routeName = reqWithRouteInfo.routeOptions?.url || reqWithRouteInfo.routerPath;
83
- const method = reqWithRouteInfo.method || 'GET';
102
+ const routeName = request.routeOptions?.url || request.routerPath;
103
+ const method = request.method || 'GET';
84
104
 
85
105
  getIsolationScope().setTransactionName(`${method} ${routeName}`);
86
106
  });
@@ -1 +1 @@
1
- {"version":3,"file":"fastify.js","sources":["../../../../src/integrations/tracing/fastify.ts"],"sourcesContent":["import { FastifyInstrumentation } from '@opentelemetry/instrumentation-fastify';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n captureException,\n defineIntegration,\n getClient,\n getIsolationScope,\n spanToJSON,\n} from '@sentry/core';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport { ensureIsWrapped } from '../../utils/ensureIsWrapped';\n\n// We inline the types we care about here\ninterface Fastify {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register: (plugin: any) => void;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n addHook: (hook: string, handler: (request: any, reply: any, error: Error) => void) => void;\n}\n\n/**\n * Minimal request type containing properties around route information.\n * Works for Fastify 3, 4 and presumably 5.\n */\ninterface FastifyRequestRouteInfo {\n method?: string;\n // since fastify@4.10.0\n routeOptions?: {\n url?: string;\n };\n routerPath?: string;\n}\n\nconst INTEGRATION_NAME = 'Fastify';\n\nexport const instrumentFastify = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n // eslint-disable-next-line deprecation/deprecation\n new FastifyInstrumentation({\n requestHook(span) {\n addFastifySpanAttributes(span);\n },\n }),\n);\n\nconst _fastifyIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentFastify();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for [Fastify](https://fastify.dev/).\n *\n * If you also want to capture errors, you need to call `setupFastifyErrorHandler(app)` after you set up your Fastify server.\n *\n * For more information, see the [fastify documentation](https://docs.sentry.io/platforms/javascript/guides/fastify/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.fastifyIntegration()],\n * })\n * ```\n */\nexport const fastifyIntegration = defineIntegration(_fastifyIntegration);\n\n/**\n * Add an Fastify error handler to capture errors to Sentry.\n *\n * @param fastify The Fastify instance to which to add the error handler\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const Fastify = require(\"fastify\");\n *\n * const app = Fastify();\n *\n * Sentry.setupFastifyErrorHandler(app);\n *\n * // Add your routes, etc.\n *\n * app.listen({ port: 3000 });\n * ```\n */\nexport function setupFastifyErrorHandler(fastify: Fastify): void {\n const plugin = Object.assign(\n function (fastify: Fastify, _options: unknown, done: () => void): void {\n fastify.addHook('onError', async (_request, _reply, error) => {\n captureException(error);\n });\n\n // registering `onRequest` hook here instead of using Otel `onRequest` callback b/c `onRequest` hook\n // is ironically called in the fastify `preHandler` hook which is called later in the lifecycle:\n // https://fastify.dev/docs/latest/Reference/Lifecycle/\n fastify.addHook('onRequest', async (request, _reply) => {\n const reqWithRouteInfo = request as FastifyRequestRouteInfo;\n\n // Taken from Otel Fastify instrumentation:\n // https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts#L94-L96\n const routeName = reqWithRouteInfo.routeOptions?.url || reqWithRouteInfo.routerPath;\n const method = reqWithRouteInfo.method || 'GET';\n\n getIsolationScope().setTransactionName(`${method} ${routeName}`);\n });\n\n done();\n },\n {\n [Symbol.for('skip-override')]: true,\n [Symbol.for('fastify.display-name')]: 'sentry-fastify-error-handler',\n },\n );\n\n fastify.register(plugin);\n\n // Sadly, middleware spans do not go through `requestHook`, so we handle those here\n // We register this hook in this method, because if we register it in the integration `setup`,\n // it would always run even for users that are not even using fastify\n const client = getClient();\n if (client) {\n client.on('spanStart', span => {\n addFastifySpanAttributes(span);\n });\n }\n\n ensureIsWrapped(fastify.addHook, 'fastify');\n}\n\nfunction addFastifySpanAttributes(span: Span): void {\n const attributes = spanToJSON(span).data;\n\n // this is one of: middleware, request_handler\n const type = attributes['fastify.type'];\n\n // If this is already set, or we have no fastify span, no need to process again...\n if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {\n return;\n }\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.fastify',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.fastify`,\n });\n\n // Also update the name, we don't need to \"middleware - \" prefix\n const name = attributes['fastify.name'] || attributes['plugin.name'] || attributes['hook.name'];\n if (typeof name === 'string') {\n // Also remove `fastify -> ` prefix\n span.updateName(name.replace(/^fastify -> /, ''));\n }\n}\n"],"names":[],"mappings":";;;;;AAcA;;AAqBA,MAAM,gBAAA,GAAmB,SAAS;;AAE3B,MAAM,iBAAkB,GAAE,sBAAsB;AACvD,EAAE,gBAAgB;AAClB,EAAE;AACF;AACA,IAAI,IAAI,sBAAsB,CAAC;AAC/B,MAAM,WAAW,CAAC,IAAI,EAAE;AACxB,QAAQ,wBAAwB,CAAC,IAAI,CAAC;AACtC,OAAO;AACP,KAAK,CAAC;AACN;;AAEA,MAAM,mBAAoB,IAAG,MAAM;AACnC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAA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AAA,OAAA,CAAA,QAAA,CAAA,MAAA,CAAA;;AAEA;AACA;AACA;AACA,EAAA,MAAA,MAAA,GAAA,SAAA,EAAA;AACA,EAAA,IAAA,MAAA,EAAA;AACA,IAAA,MAAA,CAAA,EAAA,CAAA,WAAA,EAAA,IAAA,IAAA;AACA,MAAA,wBAAA,CAAA,IAAA,CAAA;AACA,KAAA,CAAA;AACA;;AAEA,EAAA,eAAA,CAAA,OAAA,CAAA,OAAA,EAAA,SAAA,CAAA;AACA;;AAEA,SAAA,wBAAA,CAAA,IAAA,EAAA;AACA,EAAA,MAAA,UAAA,GAAA,UAAA,CAAA,IAAA,CAAA,CAAA,IAAA;;AAEA;AACA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA;;AAEA;AACA,EAAA,IAAA,UAAA,CAAA,4BAAA,CAAA,IAAA,CAAA,IAAA,EAAA;AACA,IAAA;AACA;;AAEA,EAAA,IAAA,CAAA,aAAA,CAAA;AACA,IAAA,CAAA,gCAAA,GAAA,wBAAA;AACA,IAAA,CAAA,4BAAA,GAAA,CAAA,EAAA,IAAA,CAAA,QAAA,CAAA;AACA,GAAA,CAAA;;AAEA;AACA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA,IAAA,UAAA,CAAA,aAAA,CAAA,IAAA,UAAA,CAAA,WAAA,CAAA;AACA,EAAA,IAAA,OAAA,IAAA,KAAA,QAAA,EAAA;AACA;AACA,IAAA,IAAA,CAAA,UAAA,CAAA,IAAA,CAAA,OAAA,CAAA,cAAA,EAAA,EAAA,CAAA,CAAA;AACA;AACA;;;;"}
1
+ {"version":3,"file":"fastify.js","sources":["../../../../src/integrations/tracing/fastify.ts"],"sourcesContent":["import { FastifyInstrumentation } from '@opentelemetry/instrumentation-fastify';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n captureException,\n defineIntegration,\n getClient,\n getIsolationScope,\n spanToJSON,\n} from '@sentry/core';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport { ensureIsWrapped } from '../../utils/ensureIsWrapped';\n\n/**\n * Minimal request type containing properties around route information.\n * Works for Fastify 3, 4 and presumably 5.\n *\n * Based on https://github.com/fastify/fastify/blob/ce3811f5f718be278bbcd4392c615d64230065a6/types/request.d.ts\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ninterface MinimalFastifyRequest extends Record<string, any> {\n method?: string;\n // since fastify@4.10.0\n routeOptions?: {\n url?: string;\n };\n routerPath?: string;\n}\n\n/**\n * Minimal reply type containing properties needed for error handling.\n *\n * Based on https://github.com/fastify/fastify/blob/ce3811f5f718be278bbcd4392c615d64230065a6/types/reply.d.ts\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ninterface MinimalFastifyReply extends Record<string, any> {\n statusCode: number;\n}\n\n// We inline the types we care about here\ninterface Fastify {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n register: (plugin: any) => void;\n addHook: (hook: string, handler: (...params: unknown[]) => void) => void;\n}\n\ninterface FastifyWithHooks extends Omit<Fastify, 'addHook'> {\n addHook(\n hook: 'onError',\n handler: (request: MinimalFastifyRequest, reply: MinimalFastifyReply, error: Error) => void,\n ): void;\n addHook(hook: 'onRequest', handler: (request: MinimalFastifyRequest, reply: MinimalFastifyReply) => void): void;\n}\n\ninterface FastifyHandlerOptions {\n /**\n * Callback method deciding whether error should be captured and sent to Sentry\n *\n * @param error Captured Fastify error\n * @param request Fastify request (or any object containing at least method, routeOptions.url, and routerPath)\n * @param reply Fastify reply (or any object containing at least statusCode)\n *\n * @example\n *\n * ```javascript\n * setupFastifyErrorHandler(app, {\n * shouldHandleError(_error, _request, reply) {\n * return reply.statusCode >= 400;\n * },\n * });\n * ```\n *\n * If using TypeScript, you can cast the request and reply to get full type safety.\n *\n * ```typescript\n * import type { FastifyRequest, FastifyReply } from 'fastify';\n *\n * setupFastifyErrorHandler(app, {\n * shouldHandleError(error, minimalRequest, minimalReply) {\n * const request = minimalRequest as FastifyRequest;\n * const reply = minimalReply as FastifyReply;\n * return reply.statusCode >= 500;\n * },\n * });\n * ```\n */\n shouldHandleError: (error: Error, request: MinimalFastifyRequest, reply: MinimalFastifyReply) => boolean;\n}\n\nconst INTEGRATION_NAME = 'Fastify';\n\nexport const instrumentFastify = generateInstrumentOnce(\n INTEGRATION_NAME,\n () =>\n // eslint-disable-next-line deprecation/deprecation\n new FastifyInstrumentation({\n requestHook(span) {\n addFastifySpanAttributes(span);\n },\n }),\n);\n\nconst _fastifyIntegration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentFastify();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for [Fastify](https://fastify.dev/).\n *\n * If you also want to capture errors, you need to call `setupFastifyErrorHandler(app)` after you set up your Fastify server.\n *\n * For more information, see the [fastify documentation](https://docs.sentry.io/platforms/javascript/guides/fastify/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.fastifyIntegration()],\n * })\n * ```\n */\nexport const fastifyIntegration = defineIntegration(_fastifyIntegration);\n\n/**\n * Default function to determine if an error should be sent to Sentry\n *\n * 3xx and 4xx errors are not sent by default.\n */\nfunction defaultShouldHandleError(_error: Error, _request: MinimalFastifyRequest, reply: MinimalFastifyReply): boolean {\n const statusCode = reply.statusCode;\n // 3xx and 4xx errors are not sent by default.\n return statusCode >= 500 || statusCode <= 299;\n}\n\n/**\n * Add an Fastify error handler to capture errors to Sentry.\n *\n * @param fastify The Fastify instance to which to add the error handler\n * @param options Configuration options for the handler\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n * const Fastify = require(\"fastify\");\n *\n * const app = Fastify();\n *\n * Sentry.setupFastifyErrorHandler(app);\n *\n * // Add your routes, etc.\n *\n * app.listen({ port: 3000 });\n * ```\n */\nexport function setupFastifyErrorHandler(fastify: Fastify, options?: Partial<FastifyHandlerOptions>): void {\n const shouldHandleError = options?.shouldHandleError || defaultShouldHandleError;\n\n const plugin = Object.assign(\n function (fastify: FastifyWithHooks, _options: unknown, done: () => void): void {\n fastify.addHook('onError', async (request, reply, error) => {\n if (shouldHandleError(error, request, reply)) {\n captureException(error);\n }\n });\n\n // registering `onRequest` hook here instead of using Otel `onRequest` callback b/c `onRequest` hook\n // is ironically called in the fastify `preHandler` hook which is called later in the lifecycle:\n // https://fastify.dev/docs/latest/Reference/Lifecycle/\n fastify.addHook('onRequest', async (request, _reply) => {\n // Taken from Otel Fastify instrumentation:\n // https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts#L94-L96\n const routeName = request.routeOptions?.url || request.routerPath;\n const method = request.method || 'GET';\n\n getIsolationScope().setTransactionName(`${method} ${routeName}`);\n });\n\n done();\n },\n {\n [Symbol.for('skip-override')]: true,\n [Symbol.for('fastify.display-name')]: 'sentry-fastify-error-handler',\n },\n );\n\n fastify.register(plugin);\n\n // Sadly, middleware spans do not go through `requestHook`, so we handle those here\n // We register this hook in this method, because if we register it in the integration `setup`,\n // it would always run even for users that are not even using fastify\n const client = getClient();\n if (client) {\n client.on('spanStart', span => {\n addFastifySpanAttributes(span);\n });\n }\n\n ensureIsWrapped(fastify.addHook, 'fastify');\n}\n\nfunction addFastifySpanAttributes(span: Span): void {\n const attributes = spanToJSON(span).data;\n\n // this is one of: middleware, request_handler\n const type = attributes['fastify.type'];\n\n // If this is already set, or we have no fastify span, no need to process again...\n if (attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] || !type) {\n return;\n }\n\n span.setAttributes({\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.fastify',\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: `${type}.fastify`,\n });\n\n // Also update the name, we don't need to \"middleware - \" prefix\n const name = attributes['fastify.name'] || attributes['plugin.name'] || attributes['hook.name'];\n if (typeof name === 'string') {\n // Also remove `fastify -> ` prefix\n span.updateName(name.replace(/^fastify -> /, ''));\n }\n}\n"],"names":[],"mappings":";;;;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsEA,MAAM,gBAAA,GAAmB,SAAS;;AAE3B,MAAM,iBAAkB,GAAE,sBAAsB;AACvD,EAAE,gBAAgB;AAClB,EAAE;AACF;AACA,IAAI,IAAI,sBAAsB,CAAC;AAC/B,MAAM,WAAW,CAAC,IAAI,EAAE;AACxB,QAAQ,wBAAwB,CAAC,IAAI,CAAC;AACtC,OAAO;AACP,KAAK,CAAC;AACN;;AAEA,MAAM,mBAAoB,IAAG,MAAM;AACnC,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,SAAS,GAAG;AAChB,MAAM,iBAAiB,EAAE;AACzB,KAAK;AACL,GAAG;AACH,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACa,kBAAmB,GAAE,iBAAiB,CAAC,mBAAmB;;AAEvE;AACA;AACA;AACA;AACA;AACA,SAAS,wBAAwB,CAAC,MAAM,EAAS,QAAQ,EAAyB,KAAK,EAAgC;AACvH,EAAE,MAAM,UAAA,GAAa,KAAK,CAAC,UAAU;AACrC;AACA,EAAE,OAAO,UAAW,IAAG,OAAO,UAAA,IAAc,GAAG;AAC/C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,CAAC,OAAO,EAAW,OAAO,EAAyC;AAC3G,EAAE,MAAM,iBAAkB,GAAE,OAAO,EAAE,iBAAA,IAAqB,wBAAwB;;AAElF,EAAE,MAAM,MAAA,GAAS,MAAM,CAAC,MAAM;AAC9B,IAAI,UAAU,OAAO,EAAoB,QAAQ,EAAW,IAAI,EAAoB;AACpF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ACA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA;;AAEA;AACA,EAAA,IAAA,UAAA,CAAA,4BAAA,CAAA,IAAA,CAAA,IAAA,EAAA;AACA,IAAA;AACA;;AAEA,EAAA,IAAA,CAAA,aAAA,CAAA;AACA,IAAA,CAAA,gCAAA,GAAA,wBAAA;AACA,IAAA,CAAA,4BAAA,GAAA,CAAA,EAAA,IAAA,CAAA,QAAA,CAAA;AACA,GAAA,CAAA;;AAEA;AACA,EAAA,MAAA,IAAA,GAAA,UAAA,CAAA,cAAA,CAAA,IAAA,UAAA,CAAA,aAAA,CAAA,IAAA,UAAA,CAAA,WAAA,CAAA;AACA,EAAA,IAAA,OAAA,IAAA,KAAA,QAAA,EAAA;AACA;AACA,IAAA,IAAA,CAAA,UAAA,CAAA,IAAA,CAAA,OAAA,CAAA,cAAA,EAAA,EAAA,CAAA,CAAA;AACA;AACA;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"9.7.0","sideEffects":false}
1
+ {"type":"module","version":"9.9.0","sideEffects":false}
@@ -1 +1 @@
1
- {"version":3,"file":"SentryHttpInstrumentationBeforeOtel.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAU1G;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,mBAAmB;;IAMnE,IAAI,IAAI,CAAC,mCAAmC,EAAE,mCAAmC,CAAC;IAIzF,mDAAmD;IACnD,OAAO,CAAC,uBAAuB;IAS/B,oDAAoD;IACpD,OAAO,CAAC,wBAAwB;IAShC;;OAEG;IACH,OAAO,CAAC,gCAAgC;CAoBzC"}
1
+ {"version":3,"file":"SentryHttpInstrumentationBeforeOtel.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE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
@@ -1,6 +1,61 @@
1
+ /**
2
+ * Minimal request type containing properties around route information.
3
+ * Works for Fastify 3, 4 and presumably 5.
4
+ *
5
+ * Based on https://github.com/fastify/fastify/blob/ce3811f5f718be278bbcd4392c615d64230065a6/types/request.d.ts
6
+ */
7
+ interface MinimalFastifyRequest extends Record<string, any> {
8
+ method?: string;
9
+ routeOptions?: {
10
+ url?: string;
11
+ };
12
+ routerPath?: string;
13
+ }
14
+ /**
15
+ * Minimal reply type containing properties needed for error handling.
16
+ *
17
+ * Based on https://github.com/fastify/fastify/blob/ce3811f5f718be278bbcd4392c615d64230065a6/types/reply.d.ts
18
+ */
19
+ interface MinimalFastifyReply extends Record<string, any> {
20
+ statusCode: number;
21
+ }
1
22
  interface Fastify {
2
23
  register: (plugin: any) => void;
3
- addHook: (hook: string, handler: (request: any, reply: any, error: Error) => void) => void;
24
+ addHook: (hook: string, handler: (...params: unknown[]) => void) => void;
25
+ }
26
+ interface FastifyHandlerOptions {
27
+ /**
28
+ * Callback method deciding whether error should be captured and sent to Sentry
29
+ *
30
+ * @param error Captured Fastify error
31
+ * @param request Fastify request (or any object containing at least method, routeOptions.url, and routerPath)
32
+ * @param reply Fastify reply (or any object containing at least statusCode)
33
+ *
34
+ * @example
35
+ *
36
+ * ```javascript
37
+ * setupFastifyErrorHandler(app, {
38
+ * shouldHandleError(_error, _request, reply) {
39
+ * return reply.statusCode >= 400;
40
+ * },
41
+ * });
42
+ * ```
43
+ *
44
+ * If using TypeScript, you can cast the request and reply to get full type safety.
45
+ *
46
+ * ```typescript
47
+ * import type { FastifyRequest, FastifyReply } from 'fastify';
48
+ *
49
+ * setupFastifyErrorHandler(app, {
50
+ * shouldHandleError(error, minimalRequest, minimalReply) {
51
+ * const request = minimalRequest as FastifyRequest;
52
+ * const reply = minimalReply as FastifyReply;
53
+ * return reply.statusCode >= 500;
54
+ * },
55
+ * });
56
+ * ```
57
+ */
58
+ shouldHandleError: (error: Error, request: MinimalFastifyRequest, reply: MinimalFastifyReply) => boolean;
4
59
  }
5
60
  export declare const instrumentFastify: ((options?: unknown) => void) & {
6
61
  id: string;
@@ -26,6 +81,7 @@ export declare const fastifyIntegration: () => import("@sentry/core").Integratio
26
81
  * Add an Fastify error handler to capture errors to Sentry.
27
82
  *
28
83
  * @param fastify The Fastify instance to which to add the error handler
84
+ * @param options Configuration options for the handler
29
85
  *
30
86
  * @example
31
87
  * ```javascript
@@ -41,6 +97,6 @@ export declare const fastifyIntegration: () => import("@sentry/core").Integratio
41
97
  * app.listen({ port: 3000 });
42
98
  * ```
43
99
  */
44
- export declare function setupFastifyErrorHandler(fastify: Fastify): void;
100
+ export declare function setupFastifyErrorHandler(fastify: Fastify, options?: Partial<FastifyHandlerOptions>): void;
45
101
  export {};
46
102
  //# sourceMappingURL=fastify.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/fastify.ts"],"names":[],"mappings":"AAeA,UAAU,OAAO;IAEf,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAEhC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,CAAC;CAC5F;AAiBD,eAAO,MAAM,iBAAiB;;CAS7B,CAAC;AAWF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,0CAAyC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0C/D"}
1
+ {"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/fastify.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AAEH,UAAU,qBAAsB,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,YAAY,CAAC,EAAE;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AAEH,UAAU,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACvD,UAAU,EAAE,MAAM,CAAC;CACpB;AAGD,UAAU,OAAO;IAEf,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI,KAAK,IAAI,CAAC;CAC1E;AAUD,UAAU,qBAAqB;IAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,iBAAiB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC;CAC1G;AAID,eAAO,MAAM,iBAAiB;;CAS7B,CAAC;AAWF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB,0CAAyC,CAAC;AAazE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,CA4CzG"}
@@ -23,6 +23,8 @@ export interface BaseNodeOptions {
23
23
  tracePropagationTargets?: TracePropagationTargets;
24
24
  /**
25
25
  * Sets profiling sample rate when @sentry/profiling-node is installed
26
+ *
27
+ * @deprecated
26
28
  */
27
29
  profilesSampleRate?: number;
28
30
  /**
@@ -35,8 +37,24 @@ export interface BaseNodeOptions {
35
37
  *
36
38
  * @returns A sample rate between 0 and 1 (0 drops the profile, 1 guarantees it will be sent). Returning `true` is
37
39
  * equivalent to returning 1 and returning `false` is equivalent to returning 0.
40
+ *
41
+ * @deprecated
38
42
  */
39
43
  profilesSampler?: (samplingContext: SamplingContext) => number | boolean;
44
+ /**
45
+ * Sets profiling session sample rate - only evaluated once per SDK initialization.
46
+ * @default 0
47
+ */
48
+ profileSessionSampleRate?: number;
49
+ /**
50
+ * Set the lifecycle of the profiler.
51
+ *
52
+ * - `manual`: The profiler will be manually started and stopped.
53
+ * - `trace`: The profiler will be automatically started when when a span is sampled and stopped when there are no more sampled spans.
54
+ *
55
+ * @default 'manual'
56
+ */
57
+ profileLifecycle?: 'manual' | 'trace';
40
58
  /** Sets an optional server name (device name) */
41
59
  serverName?: string;
42
60
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAElH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;;;;;OAeG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAElD;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,MAAM,GAAG,OAAO,CAAC;IAEzE,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;;;;;;;;OASG;IACH,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KAAK,GAAG,IAAI,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,oBAAoB,CAAC,EAAE,eAAe;CAAG;AAEtF;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa,CAAC,oBAAoB,CAAC,EAAE,eAAe;CAAG;AAElG,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,KAAK,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,IAAI,CAAC"}
@@ -1,6 +1,61 @@
1
+ /**
2
+ * Minimal request type containing properties around route information.
3
+ * Works for Fastify 3, 4 and presumably 5.
4
+ *
5
+ * Based on https://github.com/fastify/fastify/blob/ce3811f5f718be278bbcd4392c615d64230065a6/types/request.d.ts
6
+ */
7
+ interface MinimalFastifyRequest extends Record<string, any> {
8
+ method?: string;
9
+ routeOptions?: {
10
+ url?: string;
11
+ };
12
+ routerPath?: string;
13
+ }
14
+ /**
15
+ * Minimal reply type containing properties needed for error handling.
16
+ *
17
+ * Based on https://github.com/fastify/fastify/blob/ce3811f5f718be278bbcd4392c615d64230065a6/types/reply.d.ts
18
+ */
19
+ interface MinimalFastifyReply extends Record<string, any> {
20
+ statusCode: number;
21
+ }
1
22
  interface Fastify {
2
23
  register: (plugin: any) => void;
3
- addHook: (hook: string, handler: (request: any, reply: any, error: Error) => void) => void;
24
+ addHook: (hook: string, handler: (...params: unknown[]) => void) => void;
25
+ }
26
+ interface FastifyHandlerOptions {
27
+ /**
28
+ * Callback method deciding whether error should be captured and sent to Sentry
29
+ *
30
+ * @param error Captured Fastify error
31
+ * @param request Fastify request (or any object containing at least method, routeOptions.url, and routerPath)
32
+ * @param reply Fastify reply (or any object containing at least statusCode)
33
+ *
34
+ * @example
35
+ *
36
+ * ```javascript
37
+ * setupFastifyErrorHandler(app, {
38
+ * shouldHandleError(_error, _request, reply) {
39
+ * return reply.statusCode >= 400;
40
+ * },
41
+ * });
42
+ * ```
43
+ *
44
+ * If using TypeScript, you can cast the request and reply to get full type safety.
45
+ *
46
+ * ```typescript
47
+ * import type { FastifyRequest, FastifyReply } from 'fastify';
48
+ *
49
+ * setupFastifyErrorHandler(app, {
50
+ * shouldHandleError(error, minimalRequest, minimalReply) {
51
+ * const request = minimalRequest as FastifyRequest;
52
+ * const reply = minimalReply as FastifyReply;
53
+ * return reply.statusCode >= 500;
54
+ * },
55
+ * });
56
+ * ```
57
+ */
58
+ shouldHandleError: (error: Error, request: MinimalFastifyRequest, reply: MinimalFastifyReply) => boolean;
4
59
  }
5
60
  export declare const instrumentFastify: ((options?: unknown) => void) & {
6
61
  id: string;
@@ -26,6 +81,7 @@ export declare const fastifyIntegration: () => import("@sentry/core").Integratio
26
81
  * Add an Fastify error handler to capture errors to Sentry.
27
82
  *
28
83
  * @param fastify The Fastify instance to which to add the error handler
84
+ * @param options Configuration options for the handler
29
85
  *
30
86
  * @example
31
87
  * ```javascript
@@ -41,6 +97,6 @@ export declare const fastifyIntegration: () => import("@sentry/core").Integratio
41
97
  * app.listen({ port: 3000 });
42
98
  * ```
43
99
  */
44
- export declare function setupFastifyErrorHandler(fastify: Fastify): void;
100
+ export declare function setupFastifyErrorHandler(fastify: Fastify, options?: Partial<FastifyHandlerOptions>): void;
45
101
  export {};
46
102
  //# sourceMappingURL=fastify.d.ts.map
@@ -23,6 +23,8 @@ export interface BaseNodeOptions {
23
23
  tracePropagationTargets?: TracePropagationTargets;
24
24
  /**
25
25
  * Sets profiling sample rate when @sentry/profiling-node is installed
26
+ *
27
+ * @deprecated
26
28
  */
27
29
  profilesSampleRate?: number;
28
30
  /**
@@ -35,8 +37,24 @@ export interface BaseNodeOptions {
35
37
  *
36
38
  * @returns A sample rate between 0 and 1 (0 drops the profile, 1 guarantees it will be sent). Returning `true` is
37
39
  * equivalent to returning 1 and returning `false` is equivalent to returning 0.
40
+ *
41
+ * @deprecated
38
42
  */
39
43
  profilesSampler?: (samplingContext: SamplingContext) => number | boolean;
44
+ /**
45
+ * Sets profiling session sample rate - only evaluated once per SDK initialization.
46
+ * @default 0
47
+ */
48
+ profileSessionSampleRate?: number;
49
+ /**
50
+ * Set the lifecycle of the profiler.
51
+ *
52
+ * - `manual`: The profiler will be manually started and stopped.
53
+ * - `trace`: The profiler will be automatically started when when a span is sampled and stopped when there are no more sampled spans.
54
+ *
55
+ * @default 'manual'
56
+ */
57
+ profileLifecycle?: 'manual' | 'trace';
40
58
  /** Sets an optional server name (device name) */
41
59
  serverName?: string;
42
60
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/node",
3
- "version": "9.7.0",
3
+ "version": "9.9.0",
4
4
  "description": "Sentry Node SDK using OpenTelemetry for performance instrumentation",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
@@ -96,8 +96,8 @@
96
96
  "@opentelemetry/sdk-trace-base": "^1.30.1",
97
97
  "@opentelemetry/semantic-conventions": "^1.30.0",
98
98
  "@prisma/instrumentation": "6.5.0",
99
- "@sentry/core": "9.7.0",
100
- "@sentry/opentelemetry": "9.7.0",
99
+ "@sentry/core": "9.9.0",
100
+ "@sentry/opentelemetry": "9.9.0",
101
101
  "import-in-the-middle": "^1.13.0"
102
102
  },
103
103
  "devDependencies": {