@sentry/node 9.15.0 → 9.16.1
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.
- package/build/cjs/integrations/anr/index.js +1 -1
- package/build/cjs/integrations/context.js +1 -0
- package/build/cjs/integrations/context.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +130 -126
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/cjs/integrations/http/index.js +30 -24
- package/build/cjs/integrations/http/index.js.map +1 -1
- package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/build/cjs/integrations/tracing/express-v5/instrumentation.js +4 -2
- package/build/cjs/integrations/tracing/express-v5/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/index.js +2 -4
- package/build/cjs/integrations/tracing/index.js.map +1 -1
- package/build/cjs/integrations/tracing/prisma.js +2 -7
- package/build/cjs/integrations/tracing/prisma.js.map +1 -1
- package/build/cjs/integrations/winston.js +2 -2
- package/build/cjs/integrations/winston.js.map +1 -1
- package/build/esm/integrations/anr/index.js +1 -1
- package/build/esm/integrations/anr/worker-script.js +2 -2
- package/build/esm/integrations/context.js +1 -0
- package/build/esm/integrations/context.js.map +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +131 -127
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/esm/integrations/http/index.js +30 -24
- package/build/esm/integrations/http/index.js.map +1 -1
- package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
- package/build/esm/integrations/local-variables/worker-script.js +2 -2
- package/build/esm/integrations/tracing/express-v5/instrumentation.js +4 -2
- package/build/esm/integrations/tracing/express-v5/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/index.js +2 -4
- package/build/esm/integrations/tracing/index.js.map +1 -1
- package/build/esm/integrations/tracing/prisma.js +2 -7
- package/build/esm/integrations/tracing/prisma.js.map +1 -1
- package/build/esm/integrations/winston.js +2 -2
- package/build/esm/integrations/winston.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/integrations/context.d.ts.map +1 -1
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +9 -13
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/http/index.d.ts +8 -0
- package/build/types/integrations/http/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/express-v5/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/prisma.d.ts.map +1 -1
- package/build/types/integrations/winston.d.ts +3 -3
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +9 -13
- package/build/types-ts3.8/integrations/http/index.d.ts +11 -0
- package/build/types-ts3.8/integrations/winston.d.ts +3 -3
- package/package.json +4 -4
- package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js +0 -130
- package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +0 -1
- package/build/cjs/integrations/http/utils.js +0 -44
- package/build/cjs/integrations/http/utils.js.map +0 -1
- package/build/cjs/integrations/http/vendor/getRequestInfo.js +0 -130
- package/build/cjs/integrations/http/vendor/getRequestInfo.js.map +0 -1
- package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js +0 -128
- package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +0 -1
- package/build/esm/integrations/http/utils.js +0 -42
- package/build/esm/integrations/http/utils.js.map +0 -1
- package/build/esm/integrations/http/vendor/getRequestInfo.js +0 -128
- package/build/esm/integrations/http/vendor/getRequestInfo.js.map +0 -1
- package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +0 -17
- package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts.map +0 -1
- package/build/types/integrations/http/vendor/getRequestInfo.d.ts +0 -21
- package/build/types/integrations/http/vendor/getRequestInfo.d.ts.map +0 -1
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +0 -20
- package/build/types-ts3.8/integrations/http/vendor/getRequestInfo.d.ts +0 -21
|
@@ -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 * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed and we want to avoid capturing it.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * @param request Contains the {@type RequestOptions} object used to make the outgoing request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => 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;\n}\n"],"names":[],"mappings":";;;;;;;;;AAgBA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B,MAAM,oBAAA,GAAuB,oDAAoD;;AA4FjF,MAAM,8BAA+B,GAAE,sBAAsB,CAAC,CAAC,EAAA,gBAAA,CAAA,mBAAA,CAAA,EAAA,MAAA;AACA,EAAA,OAAA,IAAA,mCAAA,EAAA;AACA,CAAA,CAAA;;AAEA,MAAA,oBAAA,GAAA,sBAAA;AACA,EAAA,CAAA,EAAA,gBAAA,CAAA,OAAA,CAAA;AACA,EAAA,OAAA,IAAA;AACA,IAAA,OAAA,IAAA,yBAAA,CAAA,OAAA,CAAA;AACA,GAAA;AACA,CAAA;;AAEA,MAAA,kBAAA,GAAA,sBAAA,CAAA,gBAAA,EAAA,MAAA,IAAA;AACA,EAAA,MAAA,eAAA,GAAA,IAAA,mBAAA,CAAA,MAAA,CAAA;;AAEA;AACA,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AA,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';\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 * Do not capture spans for incoming HTTP requests with the given status codes.\n * By default, spans with 404 status code are ignored.\n * Expects an array of status codes or a range of status codes, e.g. [[300,399], 404] would ignore 3xx and 404 status codes.\n *\n * @default `[404]`\n */\n dropSpansForIncomingRequestStatusCodes?: (number | [number, number])[];\n\n /**\n * Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.\n * This can be useful for long running requests where the body is not needed and we want to avoid capturing it.\n *\n * @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * @param request Contains the {@type RequestOptions} object used to make the outgoing request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => 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 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 const dropSpansForIncomingRequestStatusCodes = options.dropSpansForIncomingRequestStatusCodes ?? [404];\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is Sentry-specific instrumentation for request isolation and breadcrumbs\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 // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n },\n processEvent(event) {\n // Drop transaction if it has a status code that should be ignored\n if (event.type === 'transaction') {\n const statusCode = event.contexts?.trace?.data?.['http.response.status_code'];\n if (\n typeof statusCode === 'number' &&\n dropSpansForIncomingRequestStatusCodes.some(code => {\n if (typeof code === 'number') {\n return code === statusCode;\n }\n\n const [min, max] = code;\n return statusCode >= min && statusCode <= max;\n })\n ) {\n return null;\n }\n }\n\n return event;\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":";;;;;;;;AAeA,MAAM,gBAAA,GAAmB,MAAM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AAA;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;;;;"}
|
|
@@ -4,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 = '
|
|
7
|
+
const base64WorkerScript = 'LyohIEBzZW50cnkvbm9kZSA5LjE2LjEgKDE2MDM4NjYpIHwgaHR0cHM6Ly9naXRodWIuY29tL2dldHNlbnRyeS9zZW50cnktamF2YXNjcmlwdCAqLwppbXBvcnR7U2Vzc2lvbiBhcyBlfWZyb20ibm9kZTppbnNwZWN0b3IvcHJvbWlzZXMiO2ltcG9ydHt3b3JrZXJEYXRhIGFzIHR9ZnJvbSJub2RlOndvcmtlcl90aHJlYWRzIjtjb25zdCBuPSI5LjE2LjEiLG89Z2xvYmFsVGhpcztjb25zdCBpPSJ1bmRlZmluZWQiPT10eXBlb2YgX19TRU5UUllfREVCVUdfX3x8X19TRU5UUllfREVCVUdfXyxhPVsiZGVidWciLCJpbmZvIiwid2FybiIsImVycm9yIiwibG9nIiwiYXNzZXJ0IiwidHJhY2UiXSxzPXt9O2Z1bmN0aW9uIGMoZSl7aWYoISgiY29uc29sZSJpbiBvKSlyZXR1cm4gZSgpO2NvbnN0IHQ9by5jb25zb2xlLG49e30saT1PYmplY3Qua2V5cyhzKTtpLmZvckVhY2goKGU9Pntjb25zdCBvPXNbZV07bltlXT10W2VdLHRbZV09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
9
9
|
function log(...args) {
|
|
10
10
|
logger.log('[LocalVariables]', ...args);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @sentry/node 9.
|
|
2
|
-
import{Session as e}from"node:inspector/promises";import{workerData as t}from"node:worker_threads";const n="9.
|
|
1
|
+
/*! @sentry/node 9.16.1 (1603866) | 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="9.16.1",o=globalThis;const i="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,a=["debug","info","warn","error","log","assert","trace"],s={};function c(e){if(!("console"in o))return e();const t=o.console,n={},i=Object.keys(s);i.forEach((e=>{const o=s[e];n[e]=t[e],t[e]=o}));try{return e()}finally{i.forEach((e=>{t[e]=n[e]}))}}!function(e,t,i=o){const a=i.__SENTRY__=i.__SENTRY__||{},s=a[n]=a[n]||{};s[e]||(s[e]=t())}("logger",(function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return i?a.forEach((n=>{t[n]=(...t)=>{e&&c((()=>{o.console[n](`Sentry Logger [${n}]:`,...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);
|
|
@@ -128,16 +128,18 @@ class ExpressInstrumentationV5 extends InstrumentationBase {
|
|
|
128
128
|
// remove duplicate slashes to normalize route
|
|
129
129
|
.replace(/\/{2,}/g, '/');
|
|
130
130
|
|
|
131
|
+
const actualRoute = route.length > 0 ? route : undefined;
|
|
132
|
+
|
|
131
133
|
const attributes = {
|
|
132
134
|
// eslint-disable-next-line deprecation/deprecation
|
|
133
|
-
[SEMATTRS_HTTP_ROUTE]:
|
|
135
|
+
[SEMATTRS_HTTP_ROUTE]: actualRoute,
|
|
134
136
|
};
|
|
135
137
|
const metadata = getLayerMetadata(route, layer, layerPath);
|
|
136
138
|
const type = metadata.attributes[AttributeNames.EXPRESS_TYPE] ;
|
|
137
139
|
|
|
138
140
|
const rpcMetadata = getRPCMetadata(context.active());
|
|
139
141
|
if (rpcMetadata?.type === RPCType.HTTP) {
|
|
140
|
-
rpcMetadata.route =
|
|
142
|
+
rpcMetadata.route = actualRoute;
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
// verify against the config if the layer should be ignored
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/express-v5/instrumentation.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/member-ordering */\n/* eslint-disable guard-for-in */\n/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable prefer-rest-params */\n/* eslint-disable @typescript-eslint/no-this-alias */\n/* eslint-disable jsdoc/require-jsdoc */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */\n\n/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Attributes } from '@opentelemetry/api';\nimport { context, diag, SpanStatusCode, trace } from '@opentelemetry/api';\nimport { getRPCMetadata, RPCType } from '@opentelemetry/core';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\nimport type * as express from 'express';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { ExpressLayerType } from './enums/ExpressLayerType';\nimport type { ExpressLayer, ExpressRouter, PatchedRequest } from './internal-types';\nimport { _LAYERS_STORE_PROPERTY, kLayerPatched } from './internal-types';\nimport type { ExpressInstrumentationConfig, ExpressRequestInfo } from './types';\nimport { asErrorAndMessage, getLayerMetadata, getLayerPath, isLayerIgnored, storeLayerPath } from './utils';\n\nexport const PACKAGE_VERSION = '0.1.0';\nexport const PACKAGE_NAME = '@sentry/instrumentation-express-v5';\n\n/** Express instrumentation for OpenTelemetry */\nexport class ExpressInstrumentationV5 extends InstrumentationBase<ExpressInstrumentationConfig> {\n constructor(config: ExpressInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'express',\n ['>=5.0.0'],\n moduleExports => this._setup(moduleExports),\n moduleExports => this._tearDown(moduleExports),\n ),\n ];\n }\n\n private _setup(moduleExports: any) {\n const routerProto = moduleExports.Router.prototype;\n // patch express.Router.route\n if (isWrapped(routerProto.route)) {\n this._unwrap(routerProto, 'route');\n }\n this._wrap(routerProto, 'route', this._getRoutePatch());\n // patch express.Router.use\n if (isWrapped(routerProto.use)) {\n this._unwrap(routerProto, 'use');\n }\n this._wrap(routerProto, 'use', this._getRouterUsePatch() as any);\n // patch express.Application.use\n if (isWrapped(moduleExports.application.use)) {\n this._unwrap(moduleExports.application, 'use');\n }\n this._wrap(moduleExports.application, 'use', this._getAppUsePatch() as any);\n return moduleExports;\n }\n\n private _tearDown(moduleExports: any) {\n if (moduleExports === undefined) return;\n const routerProto = moduleExports.Router.prototype;\n this._unwrap(routerProto, 'route');\n this._unwrap(routerProto, 'use');\n this._unwrap(moduleExports.application, 'use');\n }\n\n /**\n * Get the patch for Router.route function\n */\n private _getRoutePatch() {\n const instrumentation = this;\n return function (original: express.Router['route']) {\n return function route_trace(this: ExpressRouter, ...args: Parameters<typeof original>) {\n const route = original.apply(this, args);\n const layer = this.stack[this.stack.length - 1] as ExpressLayer;\n instrumentation._applyPatch(layer, getLayerPath(args));\n return route;\n };\n };\n }\n\n /**\n * Get the patch for Router.use function\n */\n private _getRouterUsePatch() {\n const instrumentation = this;\n return function (original: express.Router['use']) {\n return function use(this: express.Application, ...args: Parameters<typeof original>) {\n const route = original.apply(this, args);\n const layer = this.stack[this.stack.length - 1] as ExpressLayer;\n instrumentation._applyPatch(layer, getLayerPath(args));\n return route;\n };\n };\n }\n\n /**\n * Get the patch for Application.use function\n */\n private _getAppUsePatch() {\n const instrumentation = this;\n return function (original: express.Application['use']) {\n return function use(\n // In express 5.x the router is stored in `router` whereas in 4.x it's stored in `_router`\n this: { _router?: ExpressRouter; router?: ExpressRouter },\n ...args: Parameters<typeof original>\n ) {\n // if we access app.router in express 4.x we trigger an assertion error\n // This property existed in v3, was removed in v4 and then re-added in v5\n const router = this.router;\n const route = original.apply(this, args);\n if (router) {\n const layer = router.stack[router.stack.length - 1] as ExpressLayer;\n instrumentation._applyPatch(layer, getLayerPath(args));\n }\n return route;\n };\n };\n }\n\n /** Patch each express layer to create span and propagate context */\n private _applyPatch(this: ExpressInstrumentationV5, layer: ExpressLayer, layerPath?: string) {\n const instrumentation = this;\n // avoid patching multiple times the same layer\n if (layer[kLayerPatched] === true) return;\n layer[kLayerPatched] = true;\n\n this._wrap(layer, 'handle', original => {\n // TODO: instrument error handlers\n if (original.length === 4) return original;\n\n const patched = function (this: ExpressLayer, req: PatchedRequest, res: express.Response) {\n storeLayerPath(req, layerPath);\n const route = (req[_LAYERS_STORE_PROPERTY] as string[])\n .filter(path => path !== '/' && path !== '/*')\n .join('')\n // remove duplicate slashes to normalize route\n .replace(/\\/{2,}/g, '/');\n\n const attributes: Attributes = {\n // eslint-disable-next-line deprecation/deprecation\n [SEMATTRS_HTTP_ROUTE]: route.length > 0 ? route : '/',\n };\n const metadata = getLayerMetadata(route, layer, layerPath);\n const type = metadata.attributes[AttributeNames.EXPRESS_TYPE] as ExpressLayerType;\n\n const rpcMetadata = getRPCMetadata(context.active());\n if (rpcMetadata?.type === RPCType.HTTP) {\n rpcMetadata.route = route || '/';\n }\n\n // verify against the config if the layer should be ignored\n if (isLayerIgnored(metadata.name, type, instrumentation.getConfig())) {\n if (type === ExpressLayerType.MIDDLEWARE) {\n (req[_LAYERS_STORE_PROPERTY] as string[]).pop();\n }\n return original.apply(this, arguments);\n }\n\n if (trace.getSpan(context.active()) === undefined) {\n return original.apply(this, arguments);\n }\n\n const spanName = instrumentation._getSpanName(\n {\n request: req,\n layerType: type,\n route,\n },\n metadata.name,\n );\n const span = instrumentation.tracer.startSpan(spanName, {\n attributes: Object.assign(attributes, metadata.attributes),\n });\n\n const { requestHook } = instrumentation.getConfig();\n if (requestHook) {\n safeExecuteInTheMiddle(\n () =>\n requestHook(span, {\n request: req,\n layerType: type,\n route,\n }),\n e => {\n if (e) {\n diag.error('express instrumentation: request hook failed', e);\n }\n },\n true,\n );\n }\n\n let spanHasEnded = false;\n if (metadata.attributes[AttributeNames.EXPRESS_TYPE] !== ExpressLayerType.MIDDLEWARE) {\n span.end();\n spanHasEnded = true;\n }\n // listener for response.on('finish')\n const onResponseFinish = () => {\n if (spanHasEnded === false) {\n spanHasEnded = true;\n span.end();\n }\n };\n\n // verify we have a callback\n const args = Array.from(arguments);\n const callbackIdx = args.findIndex(arg => typeof arg === 'function');\n if (callbackIdx >= 0) {\n arguments[callbackIdx] = function () {\n // express considers anything but an empty value, \"route\" or \"router\"\n // passed to its callback to be an error\n const maybeError = arguments[0];\n const isError = ![undefined, null, 'route', 'router'].includes(maybeError);\n if (!spanHasEnded && isError) {\n const [error, message] = asErrorAndMessage(maybeError);\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message,\n });\n }\n\n if (spanHasEnded === false) {\n spanHasEnded = true;\n req.res?.removeListener('finish', onResponseFinish);\n span.end();\n }\n if (!(req.route && isError)) {\n (req[_LAYERS_STORE_PROPERTY] as string[]).pop();\n }\n const callback = args[callbackIdx] as Function;\n return callback.apply(this, arguments);\n };\n }\n\n try {\n return original.apply(this, arguments);\n } catch (anyError) {\n const [error, message] = asErrorAndMessage(anyError);\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message,\n });\n throw anyError;\n } finally {\n /**\n * At this point if the callback wasn't called, that means either the\n * layer is asynchronous (so it will call the callback later on) or that\n * the layer directly end the http response, so we'll hook into the \"finish\"\n * event to handle the later case.\n */\n if (!spanHasEnded) {\n res.once('finish', onResponseFinish);\n }\n }\n };\n\n // `handle` isn't just a regular function in some cases. It also contains\n // some properties holding metadata and state so we need to proxy them\n // through through patched function\n // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1950\n // Also some apps/libs do their own patching before OTEL and have these properties\n // in the proptotype. So we use a `for...in` loop to get own properties and also\n // any enumerable prop in the prototype chain\n // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2271\n for (const key in original) {\n Object.defineProperty(patched, key, {\n get() {\n return original[key];\n },\n set(value) {\n original[key] = value;\n },\n });\n }\n return patched;\n });\n }\n\n _getSpanName(info: ExpressRequestInfo, defaultName: string) {\n const { spanNameHook } = this.getConfig();\n\n if (!(spanNameHook instanceof Function)) {\n return defaultName;\n }\n\n try {\n return spanNameHook(info, defaultName) ?? defaultName;\n } catch (err) {\n diag.error('express instrumentation: error calling span name rewrite hook', err);\n return defaultName;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AA6CO,MAAM,eAAgB,GAAE;AACxB,MAAM,YAAa,GAAE;;AAE5B;AACO,MAAM,wBAAA,SAAiC,mBAAmB,CAA+B;AAChG,EAAE,WAAW,CAAC,MAAM,GAAiC,EAAE,EAAE;AACzD,IAAI,KAAK,CAAC,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC;AAChD;;AAEA,EAAE,IAAI,GAAG;AACT,IAAI,OAAO;AACX,MAAM,IAAI,mCAAmC;AAC7C,QAAQ,SAAS;AACjB,QAAQ,CAAC,SAAS,CAAC;AACnB,QAAQ,iBAAiB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;AACnD,QAAQ,iBAAiB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;AACtD,OAAO;AACP,KAAK;AACL;;AAEA,GAAU,MAAM,CAAC,aAAa,EAAO;AACrC,IAAI,MAAM,WAAY,GAAE,aAAa,CAAC,MAAM,CAAC,SAAS;AACtD;AACA,IAAI,IAAI,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;AACtC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC;AACxC;AACA,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;AAC3D;AACA,IAAI,IAAI,SAAS,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;AACpC,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC;AACtC;AACA,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,kBAAkB,IAAU;AACpE;AACA,IAAI,IAAI,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;AAClD,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,EAAE,KAA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AAG,EAAE;AAClB,MAAM,IAAI,CAAC,KAAK,CAAC,+DAA+D,EAAE,GAAG,CAAC;AACtF,MAAM,OAAO,WAAW;AACxB;AACA;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sources":["../../../../../src/integrations/tracing/express-v5/instrumentation.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/member-ordering */\n/* eslint-disable guard-for-in */\n/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable prefer-rest-params */\n/* eslint-disable @typescript-eslint/no-this-alias */\n/* eslint-disable jsdoc/require-jsdoc */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\n/* eslint-disable @typescript-eslint/explicit-member-accessibility */\n\n/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Attributes } from '@opentelemetry/api';\nimport { context, diag, SpanStatusCode, trace } from '@opentelemetry/api';\nimport { getRPCMetadata, RPCType } from '@opentelemetry/core';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\nimport type * as express from 'express';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { ExpressLayerType } from './enums/ExpressLayerType';\nimport type { ExpressLayer, ExpressRouter, PatchedRequest } from './internal-types';\nimport { _LAYERS_STORE_PROPERTY, kLayerPatched } from './internal-types';\nimport type { ExpressInstrumentationConfig, ExpressRequestInfo } from './types';\nimport { asErrorAndMessage, getLayerMetadata, getLayerPath, isLayerIgnored, storeLayerPath } from './utils';\n\nexport const PACKAGE_VERSION = '0.1.0';\nexport const PACKAGE_NAME = '@sentry/instrumentation-express-v5';\n\n/** Express instrumentation for OpenTelemetry */\nexport class ExpressInstrumentationV5 extends InstrumentationBase<ExpressInstrumentationConfig> {\n constructor(config: ExpressInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n init() {\n return [\n new InstrumentationNodeModuleDefinition(\n 'express',\n ['>=5.0.0'],\n moduleExports => this._setup(moduleExports),\n moduleExports => this._tearDown(moduleExports),\n ),\n ];\n }\n\n private _setup(moduleExports: any) {\n const routerProto = moduleExports.Router.prototype;\n // patch express.Router.route\n if (isWrapped(routerProto.route)) {\n this._unwrap(routerProto, 'route');\n }\n this._wrap(routerProto, 'route', this._getRoutePatch());\n // patch express.Router.use\n if (isWrapped(routerProto.use)) {\n this._unwrap(routerProto, 'use');\n }\n this._wrap(routerProto, 'use', this._getRouterUsePatch() as any);\n // patch express.Application.use\n if (isWrapped(moduleExports.application.use)) {\n this._unwrap(moduleExports.application, 'use');\n }\n this._wrap(moduleExports.application, 'use', this._getAppUsePatch() as any);\n return moduleExports;\n }\n\n private _tearDown(moduleExports: any) {\n if (moduleExports === undefined) return;\n const routerProto = moduleExports.Router.prototype;\n this._unwrap(routerProto, 'route');\n this._unwrap(routerProto, 'use');\n this._unwrap(moduleExports.application, 'use');\n }\n\n /**\n * Get the patch for Router.route function\n */\n private _getRoutePatch() {\n const instrumentation = this;\n return function (original: express.Router['route']) {\n return function route_trace(this: ExpressRouter, ...args: Parameters<typeof original>) {\n const route = original.apply(this, args);\n const layer = this.stack[this.stack.length - 1] as ExpressLayer;\n instrumentation._applyPatch(layer, getLayerPath(args));\n return route;\n };\n };\n }\n\n /**\n * Get the patch for Router.use function\n */\n private _getRouterUsePatch() {\n const instrumentation = this;\n return function (original: express.Router['use']) {\n return function use(this: express.Application, ...args: Parameters<typeof original>) {\n const route = original.apply(this, args);\n const layer = this.stack[this.stack.length - 1] as ExpressLayer;\n instrumentation._applyPatch(layer, getLayerPath(args));\n return route;\n };\n };\n }\n\n /**\n * Get the patch for Application.use function\n */\n private _getAppUsePatch() {\n const instrumentation = this;\n return function (original: express.Application['use']) {\n return function use(\n // In express 5.x the router is stored in `router` whereas in 4.x it's stored in `_router`\n this: { _router?: ExpressRouter; router?: ExpressRouter },\n ...args: Parameters<typeof original>\n ) {\n // if we access app.router in express 4.x we trigger an assertion error\n // This property existed in v3, was removed in v4 and then re-added in v5\n const router = this.router;\n const route = original.apply(this, args);\n if (router) {\n const layer = router.stack[router.stack.length - 1] as ExpressLayer;\n instrumentation._applyPatch(layer, getLayerPath(args));\n }\n return route;\n };\n };\n }\n\n /** Patch each express layer to create span and propagate context */\n private _applyPatch(this: ExpressInstrumentationV5, layer: ExpressLayer, layerPath?: string) {\n const instrumentation = this;\n // avoid patching multiple times the same layer\n if (layer[kLayerPatched] === true) return;\n layer[kLayerPatched] = true;\n\n this._wrap(layer, 'handle', original => {\n // TODO: instrument error handlers\n if (original.length === 4) return original;\n\n const patched = function (this: ExpressLayer, req: PatchedRequest, res: express.Response) {\n storeLayerPath(req, layerPath);\n const route = (req[_LAYERS_STORE_PROPERTY] as string[])\n .filter(path => path !== '/' && path !== '/*')\n .join('')\n // remove duplicate slashes to normalize route\n .replace(/\\/{2,}/g, '/');\n\n const actualRoute = route.length > 0 ? route : undefined;\n\n const attributes: Attributes = {\n // eslint-disable-next-line deprecation/deprecation\n [SEMATTRS_HTTP_ROUTE]: actualRoute,\n };\n const metadata = getLayerMetadata(route, layer, layerPath);\n const type = metadata.attributes[AttributeNames.EXPRESS_TYPE] as ExpressLayerType;\n\n const rpcMetadata = getRPCMetadata(context.active());\n if (rpcMetadata?.type === RPCType.HTTP) {\n rpcMetadata.route = actualRoute;\n }\n\n // verify against the config if the layer should be ignored\n if (isLayerIgnored(metadata.name, type, instrumentation.getConfig())) {\n if (type === ExpressLayerType.MIDDLEWARE) {\n (req[_LAYERS_STORE_PROPERTY] as string[]).pop();\n }\n return original.apply(this, arguments);\n }\n\n if (trace.getSpan(context.active()) === undefined) {\n return original.apply(this, arguments);\n }\n\n const spanName = instrumentation._getSpanName(\n {\n request: req,\n layerType: type,\n route,\n },\n metadata.name,\n );\n const span = instrumentation.tracer.startSpan(spanName, {\n attributes: Object.assign(attributes, metadata.attributes),\n });\n\n const { requestHook } = instrumentation.getConfig();\n if (requestHook) {\n safeExecuteInTheMiddle(\n () =>\n requestHook(span, {\n request: req,\n layerType: type,\n route,\n }),\n e => {\n if (e) {\n diag.error('express instrumentation: request hook failed', e);\n }\n },\n true,\n );\n }\n\n let spanHasEnded = false;\n if (metadata.attributes[AttributeNames.EXPRESS_TYPE] !== ExpressLayerType.MIDDLEWARE) {\n span.end();\n spanHasEnded = true;\n }\n // listener for response.on('finish')\n const onResponseFinish = () => {\n if (spanHasEnded === false) {\n spanHasEnded = true;\n span.end();\n }\n };\n\n // verify we have a callback\n const args = Array.from(arguments);\n const callbackIdx = args.findIndex(arg => typeof arg === 'function');\n if (callbackIdx >= 0) {\n arguments[callbackIdx] = function () {\n // express considers anything but an empty value, \"route\" or \"router\"\n // passed to its callback to be an error\n const maybeError = arguments[0];\n const isError = ![undefined, null, 'route', 'router'].includes(maybeError);\n if (!spanHasEnded && isError) {\n const [error, message] = asErrorAndMessage(maybeError);\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message,\n });\n }\n\n if (spanHasEnded === false) {\n spanHasEnded = true;\n req.res?.removeListener('finish', onResponseFinish);\n span.end();\n }\n if (!(req.route && isError)) {\n (req[_LAYERS_STORE_PROPERTY] as string[]).pop();\n }\n const callback = args[callbackIdx] as Function;\n return callback.apply(this, arguments);\n };\n }\n\n try {\n return original.apply(this, arguments);\n } catch (anyError) {\n const [error, message] = asErrorAndMessage(anyError);\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message,\n });\n throw anyError;\n } finally {\n /**\n * At this point if the callback wasn't called, that means either the\n * layer is asynchronous (so it will call the callback later on) or that\n * the layer directly end the http response, so we'll hook into the \"finish\"\n * event to handle the later case.\n */\n if (!spanHasEnded) {\n res.once('finish', onResponseFinish);\n }\n }\n };\n\n // `handle` isn't just a regular function in some cases. It also contains\n // some properties holding metadata and state so we need to proxy them\n // through through patched function\n // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1950\n // Also some apps/libs do their own patching before OTEL and have these properties\n // in the proptotype. So we use a `for...in` loop to get own properties and also\n // any enumerable prop in the prototype chain\n // ref: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2271\n for (const key in original) {\n Object.defineProperty(patched, key, {\n get() {\n return original[key];\n },\n set(value) {\n original[key] = value;\n },\n });\n }\n return patched;\n });\n }\n\n _getSpanName(info: ExpressRequestInfo, defaultName: string) {\n const { spanNameHook } = this.getConfig();\n\n if (!(spanNameHook instanceof Function)) {\n return defaultName;\n }\n\n try {\n return spanNameHook(info, defaultName) ?? defaultName;\n } catch (err) {\n diag.error('express instrumentation: error calling span name rewrite hook', err);\n return defaultName;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AA6CO,MAAM,eAAgB,GAAE;AACxB,MAAM,YAAa,GAAE;;AAE5B;AACO,MAAM,wBAAA,SAAiC,mBAAmB,CAA+B;AAChG,EAAE,WAAW,CAAC,MAAM,GAAiC,EAAE,EAAE;AACzD,IAAI,KAAK,CAAC,YAAY,EAAE,eAAe,EAAE,MAAM,CAAC;AAChD;;AAEA,EAAE,IAAI,GAAG;AACT,IAAI,OAAO;AACX,MAAM,IAAI,mCAAmC;AAC7C,QAAQ,SAAS;AACjB,QAAQ,CAAC,SAAS,CAAC;AACnB,QAAQ,iBAAiB,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;AACnD,QAAQ,iBAAiB,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;AACtD,OAAO;AACP,KAA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;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,KAAK,MAAM,GAAI,IAAG,QAAQ,EAAE;AAClC,QAAQ,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE;AAC5C,UAAU,GAAG,GAAG;AAChB,YAAY,OAAO,QAAQ,CAAC,GAAG,CAAC;AAChC,WAAW;AACX,UAAU,GAAG,CAAC,KAAK,EAAE;AACrB,YAAY,QAAQ,CAAC,GAAG,CAAA,GAAI,KAAK;AACjC,WAAW;AACX,SAAS,CAAC;AACV;AACA,MAAM,OAAO,OAAO;AACpB,KAAK,CAAC;AACN;;AAEA,EAAE,YAAY,CAAC,IAAI,EAAsB,WAAW,EAAU;AAC9D,IAAI,MAAM,EAAE,YAAa,EAAA,GAAI,IAAI,CAAC,SAAS,EAAE;;AAE7C,IAAI,IAAI,EAAE,wBAAwB,QAAQ,CAAC,EAAE;AAC7C,MAAM,OAAO,WAAW;AACxB;;AAEA,IAAI,IAAI;AACR,MAAM,OAAO,YAAY,CAAC,IAAI,EAAE,WAAW,CAAA,IAAK,WAAW;AAC3D,KAAM,CAAA,OAAO,GAAG,EAAE;AAClB,MAAM,IAAI,CAAC,KAAK,CAAC,+DAA+D,EAAE,GAAG,CAAC;AACtF,MAAM,OAAO,WAAW;AACxB;AACA;AACA;;;;"}
|
|
@@ -14,6 +14,7 @@ import { instrumentMongoose, mongooseIntegration } from './mongoose.js';
|
|
|
14
14
|
import { instrumentMysql, mysqlIntegration } from './mysql.js';
|
|
15
15
|
import { instrumentMysql2, mysql2Integration } from './mysql2.js';
|
|
16
16
|
import { instrumentPostgres, postgresIntegration } from './postgres.js';
|
|
17
|
+
import { prismaIntegration } from './prisma.js';
|
|
17
18
|
import { instrumentRedis, redisIntegration } from './redis.js';
|
|
18
19
|
import { instrumentTedious, tediousIntegration } from './tedious.js';
|
|
19
20
|
import { instrumentVercelAi, vercelAIIntegration } from './vercelai/index.js';
|
|
@@ -32,10 +33,7 @@ function getAutoPerformanceIntegrations() {
|
|
|
32
33
|
mysql2Integration(),
|
|
33
34
|
redisIntegration(),
|
|
34
35
|
postgresIntegration(),
|
|
35
|
-
|
|
36
|
-
// See https://github.com/prisma/prisma/issues/23410
|
|
37
|
-
// TODO v8: Figure out a better solution for this, maybe only disable in ESM mode?
|
|
38
|
-
// prismaIntegration(),
|
|
36
|
+
prismaIntegration(),
|
|
39
37
|
hapiIntegration(),
|
|
40
38
|
koaIntegration(),
|
|
41
39
|
connectIntegration(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { instrumentOtelHttp } from '../http';\nimport { amqplibIntegration, instrumentAmqplib } from './amqplib';\nimport { connectIntegration, instrumentConnect } from './connect';\nimport { expressIntegration, instrumentExpress, instrumentExpressV5 } from './express';\nimport { fastifyIntegration, instrumentFastify } from './fastify';\nimport { genericPoolIntegration, instrumentGenericPool } from './genericPool';\nimport { graphqlIntegration, instrumentGraphql } from './graphql';\nimport { hapiIntegration, instrumentHapi } from './hapi';\nimport { instrumentKafka, kafkaIntegration } from './kafka';\nimport { instrumentKoa, koaIntegration } from './koa';\nimport { instrumentLruMemoizer, lruMemoizerIntegration } from './lrumemoizer';\nimport { instrumentMongo, mongoIntegration } from './mongo';\nimport { instrumentMongoose, mongooseIntegration } from './mongoose';\nimport { instrumentMysql, mysqlIntegration } from './mysql';\nimport { instrumentMysql2, mysql2Integration } from './mysql2';\nimport { instrumentPostgres, postgresIntegration } from './postgres';\nimport { instrumentRedis, redisIntegration } from './redis';\nimport { instrumentTedious, tediousIntegration } from './tedious';\nimport { instrumentVercelAi, vercelAIIntegration } from './vercelai';\n\n/**\n * With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.\n */\nexport function getAutoPerformanceIntegrations(): Integration[] {\n return [\n expressIntegration(),\n fastifyIntegration(),\n graphqlIntegration(),\n mongoIntegration(),\n mongooseIntegration(),\n mysqlIntegration(),\n mysql2Integration(),\n redisIntegration(),\n postgresIntegration(),\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/tracing/index.ts"],"sourcesContent":["import type { Integration } from '@sentry/core';\nimport { instrumentOtelHttp } from '../http';\nimport { amqplibIntegration, instrumentAmqplib } from './amqplib';\nimport { connectIntegration, instrumentConnect } from './connect';\nimport { expressIntegration, instrumentExpress, instrumentExpressV5 } from './express';\nimport { fastifyIntegration, instrumentFastify } from './fastify';\nimport { genericPoolIntegration, instrumentGenericPool } from './genericPool';\nimport { graphqlIntegration, instrumentGraphql } from './graphql';\nimport { hapiIntegration, instrumentHapi } from './hapi';\nimport { instrumentKafka, kafkaIntegration } from './kafka';\nimport { instrumentKoa, koaIntegration } from './koa';\nimport { instrumentLruMemoizer, lruMemoizerIntegration } from './lrumemoizer';\nimport { instrumentMongo, mongoIntegration } from './mongo';\nimport { instrumentMongoose, mongooseIntegration } from './mongoose';\nimport { instrumentMysql, mysqlIntegration } from './mysql';\nimport { instrumentMysql2, mysql2Integration } from './mysql2';\nimport { instrumentPostgres, postgresIntegration } from './postgres';\nimport { prismaIntegration } from './prisma';\nimport { instrumentRedis, redisIntegration } from './redis';\nimport { instrumentTedious, tediousIntegration } from './tedious';\nimport { instrumentVercelAi, vercelAIIntegration } from './vercelai';\n\n/**\n * With OTEL, all performance integrations will be added, as OTEL only initializes them when the patched package is actually required.\n */\nexport function getAutoPerformanceIntegrations(): Integration[] {\n return [\n expressIntegration(),\n fastifyIntegration(),\n graphqlIntegration(),\n mongoIntegration(),\n mongooseIntegration(),\n mysqlIntegration(),\n mysql2Integration(),\n redisIntegration(),\n postgresIntegration(),\n prismaIntegration(),\n hapiIntegration(),\n koaIntegration(),\n connectIntegration(),\n tediousIntegration(),\n genericPoolIntegration(),\n kafkaIntegration(),\n amqplibIntegration(),\n lruMemoizerIntegration(),\n vercelAIIntegration(),\n ];\n}\n\n/**\n * Get a list of methods to instrument OTEL, when preload instrumentation.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getOpenTelemetryInstrumentationToPreload(): (((options?: any) => void) & { id: string })[] {\n return [\n instrumentOtelHttp,\n instrumentExpress,\n instrumentExpressV5,\n instrumentConnect,\n instrumentFastify,\n instrumentHapi,\n instrumentKafka,\n instrumentKoa,\n instrumentLruMemoizer,\n instrumentMongo,\n instrumentMongoose,\n instrumentMysql,\n instrumentMysql2,\n instrumentPostgres,\n instrumentHapi,\n instrumentGraphql,\n instrumentRedis,\n instrumentTedious,\n instrumentGenericPool,\n instrumentAmqplib,\n instrumentVercelAi,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;AACO,SAAS,8BAA8B,GAAkB;AAChE,EAAE,OAAO;AACT,IAAI,kBAAkB,EAAE;AACxB,IAAI,kBAAkB,EAAE;AACxB,IAAI,kBAAkB,EAAE;AACxB,IAAI,gBAAgB,EAAE;AACtB,IAAI,mBAAmB,EAAE;AACzB,IAAI,gBAAgB,EAAE;AACtB,IAAI,iBAAiB,EAAE;AACvB,IAAI,gBAAgB,EAAE;AACtB,IAAI,mBAAmB,EAAE;AACzB,IAAI,iBAAiB,EAAE;AACvB,IAAI,eAAe,EAAE;AACrB,IAAI,cAAc,EAAE;AACpB,IAAI,kBAAkB,EAAE;AACxB,IAAI,kBAAkB,EAAE;AACxB,IAAI,sBAAsB,EAAE;AAC5B,IAAI,gBAAgB,EAAE;AACtB,IAAI,kBAAkB,EAAE;AACxB,IAAI,sBAAsB,EAAE;AAC5B,IAAI,mBAAmB,EAAE;AACzB,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAmD;AAC3G,EAAE,OAAO;AACT,IAAI,kBAAkB;AACtB,IAAI,iBAAiB;AACrB,IAAI,mBAAmB;AACvB,IAAI,iBAAiB;AACrB,IAAI,iBAAiB;AACrB,IAAI,cAAc;AAClB,IAAI,eAAe;AACnB,IAAI,aAAa;AACjB,IAAI,qBAAqB;AACzB,IAAI,eAAe;AACnB,IAAI,kBAAkB;AACtB,IAAI,eAAe;AACnB,IAAI,gBAAgB;AACpB,IAAI,kBAAkB;AACtB,IAAI,cAAc;AAClB,IAAI,iBAAiB;AACrB,IAAI,eAAe;AACnB,IAAI,iBAAiB;AACrB,IAAI,qBAAqB;AACzB,IAAI,iBAAiB;AACrB,IAAI,kBAAkB;AACtB,GAAG;AACH;;;;"}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { PrismaInstrumentation } from '@prisma/instrumentation';
|
|
2
2
|
import { defineIntegration, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, consoleSandbox } from '@sentry/core';
|
|
3
3
|
import { generateInstrumentOnce } from '../../otel/instrument.js';
|
|
4
4
|
|
|
5
5
|
const INTEGRATION_NAME = 'Prisma';
|
|
6
6
|
|
|
7
|
-
const EsmInteropPrismaInstrumentation =
|
|
8
|
-
// @ts-expect-error We need to do the following for interop reasons
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
10
|
-
prismaInstrumentation.default?.PrismaInstrumentation || prismaInstrumentation.PrismaInstrumentation;
|
|
11
|
-
|
|
12
7
|
function isPrismaV6TracingHelper(helper) {
|
|
13
8
|
return !!helper && typeof helper === 'object' && 'dispatchEngineSpans' in helper;
|
|
14
9
|
}
|
|
@@ -25,7 +20,7 @@ function getPrismaTracingHelper() {
|
|
|
25
20
|
return prismaTracingHelper;
|
|
26
21
|
}
|
|
27
22
|
|
|
28
|
-
class SentryPrismaInteropInstrumentation extends
|
|
23
|
+
class SentryPrismaInteropInstrumentation extends PrismaInstrumentation {
|
|
29
24
|
constructor() {
|
|
30
25
|
super();
|
|
31
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.js","sources":["../../../../src/integrations/tracing/prisma.ts"],"sourcesContent":["import type { Instrumentation } from '@opentelemetry/instrumentation';\
|
|
1
|
+
{"version":3,"file":"prisma.js","sources":["../../../../src/integrations/tracing/prisma.ts"],"sourcesContent":["import type { Instrumentation } from '@opentelemetry/instrumentation';\nimport { PrismaInstrumentation } from '@prisma/instrumentation';\nimport { consoleSandbox, defineIntegration, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { PrismaV5TracingHelper } from './prisma/vendor/v5-tracing-helper';\nimport type { PrismaV6TracingHelper } from './prisma/vendor/v6-tracing-helper';\n\nconst INTEGRATION_NAME = 'Prisma';\n\ntype CompatibilityLayerTraceHelper = PrismaV5TracingHelper & PrismaV6TracingHelper;\n\nfunction isPrismaV6TracingHelper(helper: unknown): helper is PrismaV6TracingHelper {\n return !!helper && typeof helper === 'object' && 'dispatchEngineSpans' in helper;\n}\n\nfunction getPrismaTracingHelper(): unknown | undefined {\n const prismaInstrumentationObject = (globalThis as Record<string, unknown>).PRISMA_INSTRUMENTATION;\n const prismaTracingHelper =\n prismaInstrumentationObject &&\n typeof prismaInstrumentationObject === 'object' &&\n 'helper' in prismaInstrumentationObject\n ? prismaInstrumentationObject.helper\n : undefined;\n\n return prismaTracingHelper;\n}\n\nclass SentryPrismaInteropInstrumentation extends PrismaInstrumentation {\n public constructor() {\n super();\n }\n\n public enable(): void {\n super.enable();\n\n // The PrismaIntegration (super class) defines a global variable `global[\"PRISMA_INSTRUMENTATION\"]` when `enable()` is called. This global variable holds a \"TracingHelper\" which Prisma uses internally to create tracing data. It's their way of not depending on OTEL with their main package. The sucky thing is, prisma broke the interface of the tracing helper with the v6 major update. This means that if you use Prisma 5 with the v6 instrumentation (or vice versa) Prisma just blows up, because tries to call methods on the helper that no longer exist.\n // Because we actually want to use the v6 instrumentation and not blow up in Prisma 5 user's faces, what we're doing here is backfilling the v5 method (`createEngineSpan`) with a noop so that no longer crashes when it attempts to call that function.\n // We still won't fully emit all the spans, but this could potentially be implemented in the future.\n const prismaTracingHelper = getPrismaTracingHelper();\n\n let emittedWarning = false;\n\n if (isPrismaV6TracingHelper(prismaTracingHelper)) {\n (prismaTracingHelper as CompatibilityLayerTraceHelper).createEngineSpan = () => {\n consoleSandbox(() => {\n if (!emittedWarning) {\n emittedWarning = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[Sentry] The Sentry SDK supports tracing with Prisma version 5 only with limited capabilities. For full tracing capabilities pass `prismaInstrumentation` for version 5 to the Sentry `prismaIntegration`. Read more: https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/',\n );\n }\n });\n };\n }\n }\n}\n\nexport const instrumentPrisma = generateInstrumentOnce<{ prismaInstrumentation?: Instrumentation }>(\n INTEGRATION_NAME,\n options => {\n // Use a passed instrumentation instance to support older Prisma versions\n if (options?.prismaInstrumentation) {\n return options.prismaInstrumentation;\n }\n\n return new SentryPrismaInteropInstrumentation();\n },\n);\n\n/**\n * Adds Sentry tracing instrumentation for the [prisma](https://www.npmjs.com/package/prisma) library.\n * For more information, see the [`prismaIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/).\n *\n * NOTE: By default, this integration works with Prisma version 6.\n * To get performance instrumentation for other Prisma versions,\n * 1. Install the `@prisma/instrumentation` package with the desired version.\n * 1. Pass a `new PrismaInstrumentation()` instance as exported from `@prisma/instrumentation` to the `prismaInstrumentation` option of this integration:\n *\n * ```js\n * import { PrismaInstrumentation } from '@prisma/instrumentation'\n *\n * Sentry.init({\n * integrations: [\n * prismaIntegration({\n * // Override the default instrumentation that Sentry uses\n * prismaInstrumentation: new PrismaInstrumentation()\n * })\n * ]\n * })\n * ```\n *\n * The passed instrumentation instance will override the default instrumentation instance the integration would use, while the `prismaIntegration` will still ensure data compatibility for the various Prisma versions.\n * 1. Depending on your Prisma version (prior to version 6), add `previewFeatures = [\"tracing\"]` to the client generator block of your Prisma schema:\n *\n * ```\n * generator client {\n * provider = \"prisma-client-js\"\n * previewFeatures = [\"tracing\"]\n * }\n * ```\n */\nexport const prismaIntegration = defineIntegration(\n ({\n prismaInstrumentation,\n }: {\n /**\n * Overrides the instrumentation used by the Sentry SDK with the passed in instrumentation instance.\n *\n * NOTE: By default, the Sentry SDK uses the Prisma v6 instrumentation. Use this option if you need performance instrumentation different Prisma versions.\n *\n * For more information refer to the documentation of `prismaIntegration()` or see https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/prisma/\n */\n prismaInstrumentation?: Instrumentation;\n } = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentPrisma({ prismaInstrumentation });\n },\n setup(client) {\n // If no tracing helper exists, we skip any work here\n // this means that prisma is not being used\n if (!getPrismaTracingHelper()) {\n return;\n }\n\n client.on('spanStart', span => {\n const spanJSON = spanToJSON(span);\n if (spanJSON.description?.startsWith('prisma:')) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, 'auto.db.otel.prisma');\n }\n\n // Make sure we use the query text as the span name, for ex. SELECT * FROM \"User\" WHERE \"id\" = $1\n if (spanJSON.description === 'prisma:engine:db_query' && spanJSON.data['db.query.text']) {\n span.updateName(spanJSON.data['db.query.text'] as string);\n }\n\n // In Prisma v5.22+, the `db.system` attribute is automatically set\n // On older versions, this is missing, so we add it here\n if (spanJSON.description === 'prisma:engine:db_query' && !spanJSON.data['db.system']) {\n span.setAttribute('db.system', 'prisma');\n }\n });\n },\n };\n },\n);\n"],"names":[],"mappings":";;;;AAOA,MAAM,gBAAA,GAAmB,QAAQ;;AAIjC,SAAS,uBAAuB,CAAC,MAAM,EAA4C;AACnF,EAAE,OAAO,CAAC,CAAC,MAAA,IAAU,OAAO,MAAO,KAAI,QAAS,IAAG,qBAAsB,IAAG,MAAM;AAClF;;AAEA,SAAS,sBAAsB,GAAwB;AACvD,EAAE,MAAM,2BAA4B,GAAE,CAAC,UAAW,GAA4B,sBAAsB;AACpG,EAAE,MAAM,mBAAoB;AAC5B,IAAI,2BAA4B;AAChC,IAAI,OAAO,2BAA4B,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AAG;AAClB,QAAQ,gBAAgB,CAAC,EAAE,qBAAA,EAAuB,CAAC;AACnD,OAAO;AACP,MAAM,KAAK,CAAC,MAAM,EAAE;AACpB;AACA;AACA,QAAQ,IAAI,CAAC,sBAAsB,EAAE,EAAE;AACvC,UAAU;AACV;;AAEA,QAAQ,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ;AACvC,UAAU,MAAM,QAAS,GAAE,UAAU,CAAC,IAAI,CAAC;AAC3C,UAAU,IAAI,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE;AAC3D,YAAY,IAAI,CAAC,YAAY,CAAC,gCAAgC,EAAE,qBAAqB,CAAC;AACtF;;AAEA;AACA,UAAU,IAAI,QAAQ,CAAC,gBAAgB,wBAAA,IAA4B,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;AACnG,YAAY,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAA,EAAY;AACrE;;AAEA;AACA;AACA,UAAU,IAAI,QAAQ,CAAC,gBAAgB,wBAAA,IAA4B,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;AAChG,YAAY,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC;AACpD;AACA,SAAS,CAAC;AACV,OAAO;AACP,KAAK;AACL,GAAG;AACH;;;;"}
|
|
@@ -27,10 +27,10 @@ const SPLAT_SYMBOL = Symbol.for('splat');
|
|
|
27
27
|
* const winston = require('winston');
|
|
28
28
|
* const Transport = require('winston-transport');
|
|
29
29
|
*
|
|
30
|
-
* const
|
|
30
|
+
* const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport);
|
|
31
31
|
*
|
|
32
32
|
* const logger = winston.createLogger({
|
|
33
|
-
* transports: [
|
|
33
|
+
* transports: [new SentryWinstonTransport()],
|
|
34
34
|
* });
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"winston.js","sources":["../../../src/integrations/winston.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport type { LogSeverityLevel } from '@sentry/core';\nimport { captureLog } from '../logs/capture';\n\nconst DEFAULT_CAPTURED_LEVELS: Array<LogSeverityLevel> = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];\n\n// See: https://github.com/winstonjs/triple-beam\nconst LEVEL_SYMBOL = Symbol.for('level');\nconst MESSAGE_SYMBOL = Symbol.for('message');\nconst SPLAT_SYMBOL = Symbol.for('splat');\n\n/**\n * Options for the Sentry Winston transport.\n */\ninterface WinstonTransportOptions {\n /**\n * Use this option to filter which levels should be captured. By default, all levels are captured.\n *\n * @example\n * ```ts\n * const
|
|
1
|
+
{"version":3,"file":"winston.js","sources":["../../../src/integrations/winston.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport type { LogSeverityLevel } from '@sentry/core';\nimport { captureLog } from '../logs/capture';\n\nconst DEFAULT_CAPTURED_LEVELS: Array<LogSeverityLevel> = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];\n\n// See: https://github.com/winstonjs/triple-beam\nconst LEVEL_SYMBOL = Symbol.for('level');\nconst MESSAGE_SYMBOL = Symbol.for('message');\nconst SPLAT_SYMBOL = Symbol.for('splat');\n\n/**\n * Options for the Sentry Winston transport.\n */\ninterface WinstonTransportOptions {\n /**\n * Use this option to filter which levels should be captured. By default, all levels are captured.\n *\n * @example\n * ```ts\n * const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport, {\n * // Only capture error and warn logs\n * levels: ['error', 'warn'],\n * });\n * ```\n */\n levels?: Array<LogSeverityLevel>;\n}\n\n/**\n * Creates a new Sentry Winston transport that fowards logs to Sentry. Requires `_experiments.enableLogs` to be enabled.\n *\n * Supports Winston 3.x.x.\n *\n * @param TransportClass - The Winston transport class to extend.\n * @returns The extended transport class.\n *\n * @experimental This method will experience breaking changes. This is not yet part of\n * the stable Sentry SDK API and can be changed or removed without warning.\n *\n * @example\n * ```ts\n * const winston = require('winston');\n * const Transport = require('winston-transport');\n *\n * const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport);\n *\n * const logger = winston.createLogger({\n * transports: [new SentryWinstonTransport()],\n * });\n * ```\n */\nexport function createSentryWinstonTransport<TransportStreamInstance extends object>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TransportClass: new (options?: any) => TransportStreamInstance,\n sentryWinstonOptions?: WinstonTransportOptions,\n): typeof TransportClass {\n // @ts-ignore - We know this is safe because SentryWinstonTransport extends TransportClass\n class SentryWinstonTransport extends TransportClass {\n private _levels: Set<LogSeverityLevel>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(options?: any) {\n super(options);\n this._levels = new Set(sentryWinstonOptions?.levels ?? DEFAULT_CAPTURED_LEVELS);\n }\n\n /**\n * Forwards a winston log to the Sentry SDK.\n */\n public log(info: unknown, callback: () => void): void {\n try {\n setImmediate(() => {\n // @ts-ignore - We know this is safe because SentryWinstonTransport extends TransportClass\n this.emit('logged', info);\n });\n\n if (!isObject(info)) {\n return;\n }\n\n const levelFromSymbol = info[LEVEL_SYMBOL];\n\n // See: https://github.com/winstonjs/winston?tab=readme-ov-file#streams-objectmode-and-info-objects\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { level, message, timestamp, ...attributes } = info;\n // Remove all symbols from the remaining attributes\n attributes[LEVEL_SYMBOL] = undefined;\n attributes[MESSAGE_SYMBOL] = undefined;\n attributes[SPLAT_SYMBOL] = undefined;\n\n const logSeverityLevel = WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[levelFromSymbol as string] ?? 'info';\n if (this._levels.has(logSeverityLevel)) {\n captureLog(logSeverityLevel, message as string, {\n ...attributes,\n 'sentry.origin': 'auto.logging.winston',\n });\n }\n } catch {\n // do nothing\n }\n\n if (callback) {\n callback();\n }\n }\n }\n\n return SentryWinstonTransport as typeof TransportClass;\n}\n\nfunction isObject(anything: unknown): anything is Record<string | symbol, unknown> {\n return typeof anything === 'object' && anything != null;\n}\n\n// npm\n// {\n// error: 0,\n// warn: 1,\n// info: 2,\n// http: 3,\n// verbose: 4,\n// debug: 5,\n// silly: 6\n// }\n//\n// syslog\n// {\n// emerg: 0,\n// alert: 1,\n// crit: 2,\n// error: 3,\n// warning: 4,\n// notice: 5,\n// info: 6,\n// debug: 7,\n// }\nconst WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP: Record<string, LogSeverityLevel> = {\n // npm\n silly: 'trace',\n // npm and syslog\n debug: 'debug',\n // npm\n verbose: 'debug',\n // npm\n http: 'debug',\n // npm and syslog\n info: 'info',\n // syslog\n notice: 'info',\n // npm\n warn: 'warn',\n // syslog\n warning: 'warn',\n // npm and syslog\n error: 'error',\n // syslog\n emerg: 'fatal',\n // syslog\n alert: 'fatal',\n // syslog\n crit: 'fatal',\n};\n"],"names":[],"mappings":";;AAIA,MAAM,uBAAuB,GAA4B,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC;;AAE7G;AACA,MAAM,eAAe,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;AACxC,MAAM,iBAAiB,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;AAC5C,MAAM,eAAe,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;;AAExC;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,4BAA4B;AAC5C;AACA,EAAE,cAAc;AAChB,EAAE,oBAAoB;AACtB,EAAyB;AACzB;AACA,EAAE,MAAM,sBAAuB,SAAQ,cAAe,CAAA;;AAEtD;AACA,KAAW,WAAW,CAAC,OAAO,EAAQ;AACtC,MAAM,KAAK,CAAC,OAAO,CAAC;AACpB,MAAM,IAAI,CA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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,uCAAuC,GAAqC;AAClF;AACA,EAAE,KAAK,EAAE,OAAO;AAChB;AACA,EAAE,KAAK,EAAE,OAAO;AAChB;AACA,EAAE,OAAO,EAAE,OAAO;AAClB;AACA,EAAE,IAAI,EAAE,OAAO;AACf;AACA,EAAE,IAAI,EAAE,MAAM;AACd;AACA,EAAE,MAAM,EAAE,MAAM;AAChB;AACA,EAAE,IAAI,EAAE,MAAM;AACd;AACA,EAAE,OAAO,EAAE,MAAM;AACjB;AACA,EAAE,KAAK,EAAE,OAAO;AAChB;AACA,EAAE,KAAK,EAAE,OAAO;AAChB;AACA,EAAE,KAAK,EAAE,OAAO;AAChB;AACA,EAAE,IAAI,EAAE,OAAO;AACf,CAAC;;;;"}
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"9.
|
|
1
|
+
{"type":"module","version":"9.16.1","sideEffects":false}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/integrations/context.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,KAAK,EACV,UAAU,EAIV,aAAa,EAId,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,aAAa,+BAAsB,CAAC;AACjD,eAAO,MAAM,YAAY,8BAAqB,CAAC;AAU/C,UAAU,oBAAoB;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,cAAc;IACtB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/integrations/context.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,KAAK,EACV,UAAU,EAIV,aAAa,EAId,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,aAAa,+BAAsB,CAAC;AACjD,eAAO,MAAM,YAAY,8BAAqB,CAAC;AAU/C,UAAU,oBAAoB;IAC5B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,cAAc;IACtB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,MAAM,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA0ED;;GAEG;AACH,eAAO,MAAM,sBAAsB,8EAA6C,CAAC;AAmFjF;;GAEG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAc1C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI,GAAG,aAAa,CAoCtF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type
|
|
3
|
+
import type * as http from 'node:http';
|
|
4
4
|
import type { EventEmitter } from 'node:stream';
|
|
5
5
|
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
6
6
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
@@ -29,7 +29,7 @@ export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
|
|
|
29
29
|
* @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.
|
|
30
30
|
* @param request Contains the {@type RequestOptions} object used to make the outgoing request.
|
|
31
31
|
*/
|
|
32
|
-
ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;
|
|
32
|
+
ignoreOutgoingRequests?: (url: string, request: http.RequestOptions) => boolean;
|
|
33
33
|
/**
|
|
34
34
|
* Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.
|
|
35
35
|
* This can be useful for long running requests where the body is not needed and we want to avoid capturing it.
|
|
@@ -37,7 +37,7 @@ export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
|
|
|
37
37
|
* @param url Contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.
|
|
38
38
|
* @param request Contains the {@type RequestOptions} object used to make the outgoing request.
|
|
39
39
|
*/
|
|
40
|
-
ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;
|
|
40
|
+
ignoreIncomingRequestBody?: (url: string, request: http.RequestOptions) => boolean;
|
|
41
41
|
/**
|
|
42
42
|
* 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.
|
|
43
43
|
* Read more about Release Health: https://docs.sentry.io/product/releases/health/
|
|
@@ -69,20 +69,16 @@ export declare class SentryHttpInstrumentation extends InstrumentationBase<Sentr
|
|
|
69
69
|
constructor(config?: SentryHttpInstrumentationOptions);
|
|
70
70
|
/** @inheritdoc */
|
|
71
71
|
init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition];
|
|
72
|
-
/** Get the instrumentation for the http module. */
|
|
73
|
-
private _getHttpInstrumentation;
|
|
74
|
-
/** Get the instrumentation for the https module. */
|
|
75
|
-
private _getHttpsInstrumentation;
|
|
76
72
|
/**
|
|
77
|
-
*
|
|
73
|
+
* This is triggered when an outgoing request finishes.
|
|
74
|
+
* It has access to the final request and response objects.
|
|
78
75
|
*/
|
|
79
|
-
private
|
|
76
|
+
private _onOutgoingRequestFinish;
|
|
80
77
|
/**
|
|
81
|
-
* Patch
|
|
78
|
+
* Patch a server.emit function to handle process isolation for incoming requests.
|
|
79
|
+
* This will only patch the emit function if it was not already patched.
|
|
82
80
|
*/
|
|
83
|
-
private
|
|
84
|
-
/** Path the outgoing get function for breadcrumbs. */
|
|
85
|
-
private _getPatchOutgoingGetFunction;
|
|
81
|
+
private _patchServerEmitOnce;
|
|
86
82
|
}
|
|
87
83
|
/**
|
|
88
84
|
* Starts a session and tracks it in the context of a given isolation scope.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentryHttpInstrumentation.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"SentryHttpInstrumentation.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAEvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAC1G,OAAO,KAAK,EAAmD,KAAK,EAAE,MAAM,cAAc,CAAC;AAwB3F,MAAM,MAAM,gCAAgC,GAAG,qBAAqB,GAAG;IACrE;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;;OAMG;IACH,8BAA8B,CAAC,EAAE,OAAO,CAAC;IAEzC;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,KAAK,OAAO,CAAC;IAEhF;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,KAAK,OAAO,CAAC;IAEnF;;;;;OAKG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAE1C;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAKF;;;;;;;;;;;;GAYG;AACH,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,gCAAgC,CAAC;gBAC/E,MAAM,GAAE,gCAAqC;IAIhE,kBAAkB;IACX,IAAI,IAAI,CAAC,mCAAmC,EAAE,mCAAmC,CAAC;IAkFzF;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;CAkF7B;AAgKD;;;;;;;;GAQG;AAEH,wBAAgB,oBAAoB,CAAC,EACnC,qBAAqB,EACrB,QAAQ,EACR,sBAAsB,GACvB,EAAE;IACD,qBAAqB,EAAE,KAAK,CAAC;IAC7B,QAAQ,EAAE,YAAY,CAAC;IACvB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,GAAG,IAAI,CAsDP"}
|
|
@@ -54,6 +54,14 @@ interface HttpOptions {
|
|
|
54
54
|
* You can use it to filter on additional properties like method, headers, etc.
|
|
55
55
|
*/
|
|
56
56
|
ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Do not capture spans for incoming HTTP requests with the given status codes.
|
|
59
|
+
* By default, spans with 404 status code are ignored.
|
|
60
|
+
* Expects an array of status codes or a range of status codes, e.g. [[300,399], 404] would ignore 3xx and 404 status codes.
|
|
61
|
+
*
|
|
62
|
+
* @default `[404]`
|
|
63
|
+
*/
|
|
64
|
+
dropSpansForIncomingRequestStatusCodes?: (number | [number, number])[];
|
|
57
65
|
/**
|
|
58
66
|
* Do not capture the request body for incoming HTTP requests to URLs where the given callback returns `true`.
|
|
59
67
|
* This can be useful for long running requests where the body is not needed and we want to avoid capturing it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/index.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CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;IAEhF;;;;;;OAMG;IACH,sCAAsC,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;IAEvE;;;;;;OAMG;IACH,yBAAyB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC;IAE9E;;;OAGG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC;;OAEG;IACH,eAAe,CAAC,EAAE;QAChB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,GAAG,gCAAgC,KAAK,IAAI,CAAC;QAC1F,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,gCAAgC,GAAG,cAAc,KAAK,IAAI,CAAC;QACjG,2BAA2B,CAAC,EAAE,CAC5B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,aAAa,GAAG,gCAAgC,EACzD,QAAQ,EAAE,gCAAgC,GAAG,cAAc,KACxD,IAAI,CAAC;QAEV;;;WAGG;QACH,mBAAmB,CAAC,EAAE,qBAAqB,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5E,CAAC;CACH;AASD,eAAO,MAAM,kBAAkB;;CAe7B,CAAC;AAEH,+BAA+B;AAC/B,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,EAAE,aAAa,GAAE,OAAO,CAAC,iBAAiB,CAAM,GAAG,OAAO,CAIpH;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,2EA4C1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/instrumentation.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,mBAAmB,EACnB,mCAAmC,EAGpC,MAAM,gCAAgC,CAAC;AAOxC,OAAO,KAAK,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGhF,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,YAAY,uCAAuC,CAAC;AAEjE,gDAAgD;AAChD,qBAAa,wBAAyB,SAAQ,mBAAmB,CAAC,4BAA4B,CAAC;gBACjF,MAAM,GAAE,4BAAiC;IAIrD,IAAI;IAWJ,OAAO,CAAC,MAAM;IAoBd,OAAO,CAAC,SAAS;IAQjB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB,oEAAoE;IACpE,OAAO,CAAC,WAAW;
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/express-v5/instrumentation.ts"],"names":[],"mappings":"AA8BA,OAAO,EACL,mBAAmB,EACnB,mCAAmC,EAGpC,MAAM,gCAAgC,CAAC;AAOxC,OAAO,KAAK,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGhF,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,YAAY,uCAAuC,CAAC;AAEjE,gDAAgD;AAChD,qBAAa,wBAAyB,SAAQ,mBAAmB,CAAC,4BAA4B,CAAC;gBACjF,MAAM,GAAE,4BAAiC;IAIrD,IAAI;IAWJ,OAAO,CAAC,MAAM;IAoBd,OAAO,CAAC,SAAS;IAQjB;;OAEG;IACH,OAAO,CAAC,cAAc;IAYtB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB,oEAAoE;IACpE,OAAO,CAAC,WAAW;IAmKnB,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM;CAc3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAsBhD;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,EAAE,CAsB9D;AAED;;GAEG;AAEH,wBAAgB,wCAAwC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CAwBzG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/prisma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../../../src/integrations/tracing/prisma.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AA0DtE,eAAO,MAAM,gBAAgB;;;;CAU5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,iBAAiB;IAI1B;;;;;;OAMG;;oDAmCN,CAAC"}
|
|
@@ -8,7 +8,7 @@ interface WinstonTransportOptions {
|
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
11
|
-
* const
|
|
11
|
+
* const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport, {
|
|
12
12
|
* // Only capture error and warn logs
|
|
13
13
|
* levels: ['error', 'warn'],
|
|
14
14
|
* });
|
|
@@ -32,10 +32,10 @@ interface WinstonTransportOptions {
|
|
|
32
32
|
* const winston = require('winston');
|
|
33
33
|
* const Transport = require('winston-transport');
|
|
34
34
|
*
|
|
35
|
-
* const
|
|
35
|
+
* const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport);
|
|
36
36
|
*
|
|
37
37
|
* const logger = winston.createLogger({
|
|
38
|
-
* transports: [
|
|
38
|
+
* transports: [new SentryWinstonTransport()],
|
|
39
39
|
* });
|
|
40
40
|
* ```
|
|
41
41
|
*/
|