@sentry/node
Advanced tools
@@ -7,8 +7,5 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const INTEGRATION_NAME = "Http"; | ||
| const instrumentSentryHttp = nodeCore.generateInstrumentOnce( | ||
| `${INTEGRATION_NAME}.sentry`, | ||
| (options) => { | ||
| return new nodeCore.SentryHttpInstrumentation(options); | ||
| } | ||
| ); | ||
| const instrumentSentryHttp = Object.assign(nodeCore.instrumentHttpOutgoingRequests, { | ||
| id: `${INTEGRATION_NAME}.sentry` | ||
| }); | ||
| const httpIntegration = core.defineIntegration((options = {}) => { | ||
@@ -62,3 +59,3 @@ const spans = options.spans ?? true; | ||
| }; | ||
| instrumentSentryHttp(sentryHttpInstrumentationOptions); | ||
| nodeCore.instrumentHttpOutgoingRequests(sentryHttpInstrumentationOptions); | ||
| }, | ||
@@ -65,0 +62,0 @@ processEvent(event) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"http.js","sources":["../../../src/integrations/http.ts"],"sourcesContent":["import type { RequestOptions } from 'node:http';\nimport type { HttpClientRequest, HttpIncomingMessage, HttpServerResponse, Span } from '@sentry/core';\nimport {\n defineIntegration,\n hasSpansEnabled,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n stripDataUrlContent,\n getRequestUrlFromClientRequest,\n} from '@sentry/core';\nimport type {\n NodeClient,\n SentryHttpInstrumentationOptions,\n HttpServerIntegrationOptions,\n HttpServerSpansIntegrationOptions,\n} from '@sentry/node-core';\nimport {\n generateInstrumentOnce,\n httpServerIntegration,\n httpServerSpansIntegration,\n SentryHttpInstrumentation,\n} from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Http' as const;\n\n// TODO(v11): Consolidate all the various HTTP integration options into one,\n// and deprecate the duplicated and aliased options.\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 * Whether to inject trace propagation headers (sentry-trace, baggage, traceparent) into outgoing HTTP requests.\n *\n * When set to `false`, Sentry will not inject any trace propagation headers, but will still create breadcrumbs\n * (if `breadcrumbs` is enabled). This is useful when `skipOpenTelemetrySetup: true` is configured and you want\n * to avoid duplicate trace headers being injected by both Sentry and OpenTelemetry's HttpInstrumentation.\n *\n * @default `true`\n */\n tracePropagation?: boolean;\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: HttpIncomingMessage) => boolean;\n\n /**\n * A hook that can be used to mutate the span for incoming requests.\n * This is triggered after the span is created, but before it is recorded.\n */\n incomingRequestSpanHook?: (span: Span, request: HttpIncomingMessage, response: HttpServerResponse) => void;\n\n /**\n * Whether to automatically ignore common static asset requests like favicon.ico, robots.txt, etc.\n * This helps reduce noise in your transactions.\n *\n * @default `true`\n */\n ignoreStaticAssets?: boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests with the given status codes.\n * By default, spans with some 3xx and 4xx status codes are ignored (see @default).\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 `[[401, 404], [301, 303], [305, 399]]`\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 incoming request.\n * @param request Contains the {@type RequestOptions} object used to make the incoming request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Controls the maximum size of incoming HTTP request bodies attached to events.\n *\n * Available options:\n * - 'none': No request bodies will be attached\n * - 'small': Request bodies up to 1,000 bytes will be attached\n * - 'medium': Request bodies up to 10,000 bytes will be attached (default)\n * - 'always': Request bodies will always be attached\n *\n * Note that even with 'always' setting, bodies exceeding 1MB will never be attached\n * for performance and security reasons.\n *\n * @default 'medium'\n */\n maxIncomingRequestBodySize?: 'none' | 'small' | 'medium' | 'always';\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: HttpIncomingMessage | HttpClientRequest) => void;\n responseHook?: (span: Span, response: HttpIncomingMessage | HttpServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: HttpIncomingMessage | HttpClientRequest,\n response: HttpIncomingMessage | HttpServerResponse,\n ) => void;\n };\n}\n\nexport const instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(\n `${INTEGRATION_NAME}.sentry`,\n options => {\n return new SentryHttpInstrumentation(options);\n },\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 spans = options.spans ?? true;\n const disableIncomingRequestSpans = options.disableIncomingRequestSpans;\n const enableServerSpans = spans && !disableIncomingRequestSpans;\n\n const serverOptions = {\n sessions: options.trackIncomingRequestsAsSessions,\n sessionFlushingDelayMS: options.sessionFlushingDelayMS,\n ignoreRequestBody: options.ignoreIncomingRequestBody,\n maxRequestBodySize: options.maxIncomingRequestBodySize,\n } satisfies HttpServerIntegrationOptions;\n\n const serverSpansOptions: HttpServerSpansIntegrationOptions = {\n ignoreIncomingRequests: options.ignoreIncomingRequests,\n ignoreStaticAssets: options.ignoreStaticAssets,\n ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes,\n instrumentation: options.instrumentation,\n onSpanCreated: options.incomingRequestSpanHook,\n };\n\n const server = httpServerIntegration(serverOptions);\n const serverSpans = httpServerSpansIntegration(serverSpansOptions);\n\n return {\n name: INTEGRATION_NAME,\n setup(client: NodeClient) {\n const clientOptions = client.getOptions();\n\n if (enableServerSpans && hasSpansEnabled(clientOptions)) {\n serverSpans.setup(client);\n }\n },\n setupOnce() {\n server.setupOnce();\n\n const sentryHttpInstrumentationOptions: SentryHttpInstrumentationOptions = {\n breadcrumbs: options.breadcrumbs,\n spans,\n propagateTraceInOutgoingRequests: options.tracePropagation ?? true,\n createSpansForOutgoingRequests: spans,\n ignoreOutgoingRequests: options.ignoreOutgoingRequests,\n outgoingRequestHook: (span: Span, request: HttpClientRequest) => {\n // Sanitize data URLs to prevent long base64 strings in span attributes\n const url = getRequestUrlFromClientRequest(request);\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n // TODO(v11): Update these to the Sentry semantic attributes.\n // https://getsentry.github.io/sentry-conventions/attributes/\n span.setAttribute('http.url', sanitizedUrl);\n span.setAttribute(SEMANTIC_ATTRIBUTE_URL_FULL, sanitizedUrl);\n span.updateName(`${request.method || 'GET'} ${sanitizedUrl}`);\n }\n options.instrumentation?.requestHook?.(span, request);\n },\n outgoingResponseHook: options.instrumentation?.responseHook,\n outgoingRequestApplyCustomAttributes: options.instrumentation?.applyCustomAttributesOnSpan,\n };\n\n // This is Sentry-specific instrumentation for outgoing request\n // breadcrumbs & trace propagation. It uses the diagnostic channels on\n // node versions that support it, falling back to monkey-patching when\n // needed.\n instrumentSentryHttp(sentryHttpInstrumentationOptions);\n },\n processEvent(event) {\n // Always run this, even if spans are disabled\n // The reason being that e.g. the remix integration disables span\n // creation here but still wants to use the ignore status codes option\n return serverSpans.processEvent(event);\n },\n };\n});\n"],"names":["generateInstrumentOnce","SentryHttpInstrumentation","defineIntegration","httpServerIntegration","httpServerSpansIntegration","hasSpansEnabled","getRequestUrlFromClientRequest","stripDataUrlContent","SEMANTIC_ATTRIBUTE_URL_FULL"],"mappings":";;;;;AAsBA,MAAM,gBAAA,GAAmB,MAAA;AA0IlB,MAAM,oBAAA,GAAuBA,+BAAA;AAAA,EAClC,GAAG,gBAAgB,CAAA,OAAA,CAAA;AAAA,EACnB,CAAA,OAAA,KAAW;AACT,IAAA,OAAO,IAAIC,mCAA0B,OAAO,CAAA;AAAA,EAC9C;AACF;AAMO,MAAM,eAAA,GAAkBC,sBAAA,CAAkB,CAAC,OAAA,GAAuB,EAAC,KAAM;AAC9E,EAAA,MAAM,KAAA,GAAQ,QAAQ,KAAA,IAAS,IAAA;AAC/B,EAAA,MAAM,8BAA8B,OAAA,CAAQ,2BAAA;AAC5C,EAAA,MAAM,iBAAA,GAAoB,SAAS,CAAC,2BAAA;AAEpC,EAAA,MAAM,aAAA,GAA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AC3B,YAAA,MAAM,YAAA,GAAeC,yBAAoB,GAAG,CAAA;AAG5C,YAAA,IAAA,CAAK,YAAA,CAAa,YAAY,YAAY,CAAA;AAC1C,YAAA,IAAA,CAAK,YAAA,CAAaC,kCAA6B,YAAY,CAAA;AAC3D,YAAA,IAAA,CAAK,WAAW,CAAA,EAAG,OAAA,CAAQ,UAAU,KAAK,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE,CAAA;AAAA,UAC9D;AACA,UAAA,OAAA,CAAQ,eAAA,EAAiB,WAAA,GAAc,IAAA,EAAM,OAAO,CAAA;AAAA,QACtD,CAAA;AAAA,QACA,oBAAA,EAAsB,QAAQ,eAAA,EAAiB,YAAA;AAAA,QAC/C,oCAAA,EAAsC,QAAQ,eAAA,EAAiB;AAAA,OACjE;AAMA,MAAA,oBAAA,CAAqB,gCAAgC,CAAA;AAAA,IACvD,CAAA;AAAA,IACA,aAAa,KAAA,EAAO;AAIlB,MAAA,OAAO,WAAA,CAAY,aAAa,KAAK,CAAA;AAAA,IACvC;AAAA,GACF;AACF,CAAC;;;;;"} | ||
| {"version":3,"file":"http.js","sources":["../../../src/integrations/http.ts"],"sourcesContent":["import type { RequestOptions } from 'node:http';\nimport type { HttpClientRequest, HttpIncomingMessage, HttpServerResponse, Span } from '@sentry/core';\nimport {\n defineIntegration,\n hasSpansEnabled,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n stripDataUrlContent,\n getRequestUrlFromClientRequest,\n} from '@sentry/core';\nimport type {\n NodeClient,\n SentryHttpInstrumentationOptions,\n HttpServerIntegrationOptions,\n HttpServerSpansIntegrationOptions,\n} from '@sentry/node-core';\nimport { httpServerIntegration, httpServerSpansIntegration, instrumentHttpOutgoingRequests } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Http' as const;\n\n// TODO(v11): Consolidate all the various HTTP integration options into one,\n// and deprecate the duplicated and aliased options.\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 * Whether to inject trace propagation headers (sentry-trace, baggage, traceparent) into outgoing HTTP requests.\n *\n * When set to `false`, Sentry will not inject any trace propagation headers, but will still create breadcrumbs\n * (if `breadcrumbs` is enabled). This is useful when `skipOpenTelemetrySetup: true` is configured and you want\n * to avoid duplicate trace headers being injected by both Sentry and OpenTelemetry's HttpInstrumentation.\n *\n * @default `true`\n */\n tracePropagation?: boolean;\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: HttpIncomingMessage) => boolean;\n\n /**\n * A hook that can be used to mutate the span for incoming requests.\n * This is triggered after the span is created, but before it is recorded.\n */\n incomingRequestSpanHook?: (span: Span, request: HttpIncomingMessage, response: HttpServerResponse) => void;\n\n /**\n * Whether to automatically ignore common static asset requests like favicon.ico, robots.txt, etc.\n * This helps reduce noise in your transactions.\n *\n * @default `true`\n */\n ignoreStaticAssets?: boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests with the given status codes.\n * By default, spans with some 3xx and 4xx status codes are ignored (see @default).\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 `[[401, 404], [301, 303], [305, 399]]`\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 incoming request.\n * @param request Contains the {@type RequestOptions} object used to make the incoming request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Controls the maximum size of incoming HTTP request bodies attached to events.\n *\n * Available options:\n * - 'none': No request bodies will be attached\n * - 'small': Request bodies up to 1,000 bytes will be attached\n * - 'medium': Request bodies up to 10,000 bytes will be attached (default)\n * - 'always': Request bodies will always be attached\n *\n * Note that even with 'always' setting, bodies exceeding 1MB will never be attached\n * for performance and security reasons.\n *\n * @default 'medium'\n */\n maxIncomingRequestBodySize?: 'none' | 'small' | 'medium' | 'always';\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: HttpIncomingMessage | HttpClientRequest) => void;\n responseHook?: (span: Span, response: HttpIncomingMessage | HttpServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: HttpIncomingMessage | HttpClientRequest,\n response: HttpIncomingMessage | HttpServerResponse,\n ) => void;\n };\n}\n\nexport const instrumentSentryHttp = Object.assign(instrumentHttpOutgoingRequests, {\n id: `${INTEGRATION_NAME}.sentry`,\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 spans = options.spans ?? true;\n const disableIncomingRequestSpans = options.disableIncomingRequestSpans;\n const enableServerSpans = spans && !disableIncomingRequestSpans;\n\n const serverOptions = {\n sessions: options.trackIncomingRequestsAsSessions,\n sessionFlushingDelayMS: options.sessionFlushingDelayMS,\n ignoreRequestBody: options.ignoreIncomingRequestBody,\n maxRequestBodySize: options.maxIncomingRequestBodySize,\n } satisfies HttpServerIntegrationOptions;\n\n const serverSpansOptions: HttpServerSpansIntegrationOptions = {\n ignoreIncomingRequests: options.ignoreIncomingRequests,\n ignoreStaticAssets: options.ignoreStaticAssets,\n ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes,\n instrumentation: options.instrumentation,\n onSpanCreated: options.incomingRequestSpanHook,\n };\n\n const server = httpServerIntegration(serverOptions);\n const serverSpans = httpServerSpansIntegration(serverSpansOptions);\n\n return {\n name: INTEGRATION_NAME,\n setup(client: NodeClient) {\n const clientOptions = client.getOptions();\n\n if (enableServerSpans && hasSpansEnabled(clientOptions)) {\n serverSpans.setup(client);\n }\n },\n setupOnce() {\n server.setupOnce();\n\n const sentryHttpInstrumentationOptions: SentryHttpInstrumentationOptions = {\n breadcrumbs: options.breadcrumbs,\n spans,\n propagateTraceInOutgoingRequests: options.tracePropagation ?? true,\n createSpansForOutgoingRequests: spans,\n ignoreOutgoingRequests: options.ignoreOutgoingRequests,\n outgoingRequestHook: (span: Span, request: HttpClientRequest) => {\n // Sanitize data URLs to prevent long base64 strings in span attributes\n const url = getRequestUrlFromClientRequest(request);\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n // TODO(v11): Update these to the Sentry semantic attributes.\n // https://getsentry.github.io/sentry-conventions/attributes/\n span.setAttribute('http.url', sanitizedUrl);\n span.setAttribute(SEMANTIC_ATTRIBUTE_URL_FULL, sanitizedUrl);\n span.updateName(`${request.method || 'GET'} ${sanitizedUrl}`);\n }\n options.instrumentation?.requestHook?.(span, request);\n },\n outgoingResponseHook: options.instrumentation?.responseHook,\n outgoingRequestApplyCustomAttributes: options.instrumentation?.applyCustomAttributesOnSpan,\n };\n\n // This is Sentry-specific instrumentation for outgoing request\n // breadcrumbs & trace propagation. It uses the diagnostic channels on\n // node versions that support it, falling back to monkey-patching when\n // needed.\n instrumentHttpOutgoingRequests(sentryHttpInstrumentationOptions);\n },\n processEvent(event) {\n // Always run this, even if spans are disabled\n // The reason being that e.g. the remix integration disables span\n // creation here but still wants to use the ignore status codes option\n return serverSpans.processEvent(event);\n },\n };\n});\n"],"names":["instrumentHttpOutgoingRequests","defineIntegration","httpServerIntegration","httpServerSpansIntegration","hasSpansEnabled","getRequestUrlFromClientRequest","stripDataUrlContent","SEMANTIC_ATTRIBUTE_URL_FULL"],"mappings":";;;;;AAiBA,MAAM,gBAAA,GAAmB,MAAA;AA0IlB,MAAM,oBAAA,GAAuB,MAAA,CAAO,MAAA,CAAOA,uCAAA,EAAgC;AAAA,EAChF,EAAA,EAAI,GAAG,gBAAgB,CAAA,OAAA;AACzB,CAAC;AAMM,MAAM,eAAA,GAAkBC,sBAAA,CAAkB,CAAC,OAAA,GAAuB,EAAC,KAAM;AAC9E,EAAA,MAAM,KAAA,GAAQ,QAAQ,KAAA,IAAS,IAAA;AAC/B,EAAA,MAAM,8BAA8B,OAAA,CAAQ,2BAAA;AAC5C,EAAA,MAAM,iBAAA,GAAoB,SAAS,CAAC,2BAAA;AAEpC,EAAA,MAAM,aAAA,GAAgB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3B,YAAA,MAAM,YAAA,GAAeC,yBAAoB,GAAG,CAAA;AAG5C,YAAA,IAAA,CAAK,YAAA,CAAa,YAAY,YAAY,CAAA;AAC1C,YAAA,IAAA,CAAK,YAAA,CAAaC,kCAA6B,YAAY,CAAA;AAC3D,YAAA,IAAA,CAAK,WAAW,CAAA,EAAG,OAAA,CAAQ,UAAU,KAAK,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE,CAAA;AAAA,UAC9D;AACA,UAAA,OAAA,CAAQ,eAAA,EAAiB,WAAA,GAAc,IAAA,EAAM,OAAO,CAAA;AAAA,QACtD,CAAA;AAAA,QACA,oBAAA,EAAsB,QAAQ,eAAA,EAAiB,YAAA;AAAA,QAC/C,oCAAA,EAAsC,QAAQ,eAAA,EAAiB;AAAA,OACjE;AAMA,MAAAP,uCAAA,CAA+B,gCAAgC,CAAA;AAAA,IACjE,CAAA;AAAA,IACA,aAAa,KAAA,EAAO;AAIlB,MAAA,OAAO,WAAA,CAAY,aAAa,KAAK,CAAA;AAAA,IACvC;AAAA,GACF;AACF,CAAC;;;;;"} |
@@ -6,2 +6,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const nodeCore = require('@sentry/node-core'); | ||
| const serverUtils = require('@sentry/server-utils'); | ||
@@ -15,3 +16,3 @@ const INTEGRATION_NAME = "Graphql"; | ||
| const _graphqlIntegration = ((options = {}) => { | ||
| return { | ||
| return core.extendIntegration(serverUtils.graphqlIntegration(getOptionsWithDefaults(options)), { | ||
| name: INTEGRATION_NAME, | ||
@@ -21,3 +22,3 @@ setupOnce() { | ||
| } | ||
| }; | ||
| }); | ||
| }); | ||
@@ -24,0 +25,0 @@ const graphqlIntegration = core.defineIntegration(_graphqlIntegration); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/graphql/index.ts"],"sourcesContent":["import { GraphQLInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\ninterface GraphqlOptions {\n /**\n * Do not create spans for resolvers.\n *\n * Defaults to true.\n */\n ignoreResolveSpans?: boolean;\n\n /**\n * Don't create spans for the execution of the default resolver on object properties.\n *\n * When a resolver function is not defined on the schema for a field, graphql will\n * use the default resolver which just looks for a property with that name on the object.\n * If the property is not a function, it's not very interesting to trace.\n * This option can reduce noise and number of spans created.\n *\n * Defaults to true.\n */\n ignoreTrivialResolveSpans?: boolean;\n\n /**\n * If this is enabled, a http.server root span containing this span will automatically be renamed to include the operation name.\n * Set this to `false` if you do not want this behavior, and want to keep the default http.server span name.\n *\n * Defaults to true.\n */\n useOperationNameForRootSpan?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Graphql' as const;\n\nexport const instrumentGraphql = generateInstrumentOnce(\n INTEGRATION_NAME,\n GraphQLInstrumentation,\n (_options: GraphqlOptions) => getOptionsWithDefaults(_options),\n);\n\nconst _graphqlIntegration = ((options: GraphqlOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // We set defaults here, too, because otherwise we'd update the instrumentation config\n // to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`\n // when being called the second time\n instrumentGraphql(getOptionsWithDefaults(options));\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.\n *\n * For more information, see the [`graphqlIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).\n *\n * @param {GraphqlOptions} options Configuration options for the GraphQL integration.\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.graphqlIntegration()],\n * });\n */\nexport const graphqlIntegration = defineIntegration(_graphqlIntegration);\n\nfunction getOptionsWithDefaults(options?: GraphqlOptions): GraphqlOptions {\n return {\n ignoreResolveSpans: true,\n ignoreTrivialResolveSpans: true,\n useOperationNameForRootSpan: true,\n ...options,\n };\n}\n"],"names":["generateInstrumentOnce","GraphQLInstrumentation","defineIntegration"],"mappings":";;;;;;AAkCA,MAAM,gBAAA,GAAmB,SAAA;AAElB,MAAM,iBAAA,GAAoBA,+BAAA;AAAA,EAC/B,gBAAA;AAAA,EACAC,sCAAA;AAAA,EACA,CAAC,QAAA,KAA6B,sBAAA,CAAuB,QAAQ;AAC/D;AAEA,MAAM,mBAAA,IAAuB,CAAC,OAAA,GAA0B,EAAC,KAAM;AAC7D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAIV,MAAA,iBAAA,CAAkB,sBAAA,CAAuB,OAAO,CAAC,CAAA;AAAA,IACnD;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,kBAAA,GAAqBC,uBAAkB,mBAAmB;AAEvE,SAAS,uBAAuB,OAAA,EAA0C;AACxE,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,IAAA;AAAA,IACpB,yBAAA,EAA2B,IAAA;AAAA,IAC3B,2BAAA,EAA6B,IAAA;AAAA,IAC7B,GAAG;AAAA,GACL;AACF;;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/graphql/index.ts"],"sourcesContent":["import { GraphQLInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, extendIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { graphqlIntegration as graphqlChannelIntegration } from '@sentry/server-utils';\n\ninterface GraphqlOptions {\n /**\n * Do not create spans for resolvers.\n *\n * Defaults to true.\n */\n ignoreResolveSpans?: boolean;\n\n /**\n * Don't create spans for the execution of the default resolver on object properties.\n *\n * When a resolver function is not defined on the schema for a field, graphql will\n * use the default resolver which just looks for a property with that name on the object.\n * If the property is not a function, it's not very interesting to trace.\n * This option can reduce noise and number of spans created.\n *\n * Defaults to true.\n */\n ignoreTrivialResolveSpans?: boolean;\n\n /**\n * If this is enabled, a http.server root span containing this span will automatically be renamed to include the operation name.\n * Set this to `false` if you do not want this behavior, and want to keep the default http.server span name.\n *\n * Defaults to true.\n */\n useOperationNameForRootSpan?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Graphql' as const;\n\nexport const instrumentGraphql = generateInstrumentOnce(\n INTEGRATION_NAME,\n GraphQLInstrumentation,\n (_options: GraphqlOptions) => getOptionsWithDefaults(_options),\n);\n\nconst _graphqlIntegration = ((options: GraphqlOptions = {}) => {\n // The diagnostics_channel subscription (graphql >= 17) lives in server-utils so it is shared\n // across server runtimes; we extend it here to also run the vendored OTel patcher for graphql < 17.\n // Both paths read the same `ignoreResolveSpans` / `ignoreTrivialResolveSpans` options.\n return extendIntegration(graphqlChannelIntegration(getOptionsWithDefaults(options)), {\n name: INTEGRATION_NAME,\n setupOnce() {\n // We set defaults here, too, because otherwise we'd update the instrumentation config\n // to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`\n // when being called the second time\n instrumentGraphql(getOptionsWithDefaults(options));\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.\n *\n * For more information, see the [`graphqlIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).\n *\n * @param {GraphqlOptions} options Configuration options for the GraphQL integration.\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.graphqlIntegration()],\n * });\n */\nexport const graphqlIntegration = defineIntegration(_graphqlIntegration);\n\nfunction getOptionsWithDefaults(options?: GraphqlOptions): GraphqlOptions {\n return {\n ignoreResolveSpans: true,\n ignoreTrivialResolveSpans: true,\n useOperationNameForRootSpan: true,\n ...options,\n };\n}\n"],"names":["generateInstrumentOnce","GraphQLInstrumentation","extendIntegration","graphqlChannelIntegration","defineIntegration"],"mappings":";;;;;;;AAmCA,MAAM,gBAAA,GAAmB,SAAA;AAElB,MAAM,iBAAA,GAAoBA,+BAAA;AAAA,EAC/B,gBAAA;AAAA,EACAC,sCAAA;AAAA,EACA,CAAC,QAAA,KAA6B,sBAAA,CAAuB,QAAQ;AAC/D;AAEA,MAAM,mBAAA,IAAuB,CAAC,OAAA,GAA0B,EAAC,KAAM;AAI7D,EAAA,OAAOC,sBAAA,CAAkBC,8BAAA,CAA0B,sBAAA,CAAuB,OAAO,CAAC,CAAA,EAAG;AAAA,IACnF,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAIV,MAAA,iBAAA,CAAkB,sBAAA,CAAuB,OAAO,CAAC,CAAA;AAAA,IACnD;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAiBO,MAAM,kBAAA,GAAqBC,uBAAkB,mBAAmB;AAEvE,SAAS,uBAAuB,OAAA,EAA0C;AACxE,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,IAAA;AAAA,IACpB,yBAAA,EAA2B,IAAA;AAAA,IAC3B,2BAAA,EAA6B,IAAA;AAAA,IAC7B,GAAG;AAAA,GACL;AACF;;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/graphql/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-graphql\n * - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0\n * - Types from `graphql` package inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n * - Span lifecycle migrated from the OpenTelemetry tracer to the @sentry/core span API\n * - `auto.graphql.otel.graphql` origin baked into the execute span (previously set via a Sentry responseHook)\n * - The generic `responseHook` config was removed; its Sentry-specific logic (error status + root span renaming\n * via `useOperationNameForRootSpan`) is now applied directly when the execution result is handled\n */\n\n/* oxlint-disable max-lines */\n\nimport {\n isWrapped,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport type {\n DefinitionNode,\n DocumentNode,\n ExecutionArgs,\n ExecutionResult,\n GraphQLError,\n GraphQLFieldResolver,\n GraphQLSchema,\n GraphQLTypeResolver,\n OperationDefinitionNode,\n ParseOptions,\n PromiseOrValue,\n Source,\n TypeInfo,\n ValidationRule,\n} from './graphql-types';\nimport type { Maybe } from './graphql-types';\nimport { SpanNames } from './enum';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { OTEL_GRAPHQL_DATA_SYMBOL } from './symbols';\n\nimport {\n type executeFunctionWithObj,\n type executeArgumentsArray,\n type executeType,\n type parseType,\n type validateType,\n type OtelExecutionArgs,\n type ObjectWithGraphQLData,\n OPERATION_NOT_SUPPORTED,\n} from './internal-types';\nimport { addSpanSource, endSpan, getOperation, isPromise, wrapFieldResolver, wrapFields } from './utils';\n\nimport type { Span, SpanAttributeValue } from '@sentry/core';\nimport {\n getRootSpan,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n spanToJSON,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';\nimport type { GraphQLInstrumentationConfig, GraphQLInstrumentationParsedConfig } from './types';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-graphql';\n\nconst ORIGIN = 'auto.graphql.otel.graphql';\n\nconst DEFAULT_CONFIG: GraphQLInstrumentationParsedConfig = {\n ignoreResolveSpans: false,\n};\n\nconst supportedVersions = ['>=14.0.0 <17'];\n\nexport class GraphQLInstrumentation extends InstrumentationBase<GraphQLInstrumentationParsedConfig> {\n constructor(config: GraphQLInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, { ...DEFAULT_CONFIG, ...config });\n }\n\n override setConfig(config: GraphQLInstrumentationConfig = {}) {\n super.setConfig({ ...DEFAULT_CONFIG, ...config });\n }\n\n protected init() {\n const module = new InstrumentationNodeModuleDefinition('graphql', supportedVersions);\n module.files.push(this._addPatchingExecute());\n module.files.push(this._addPatchingParser());\n module.files.push(this._addPatchingValidate());\n\n return module;\n }\n\n private _addPatchingExecute(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/execution/execute.js',\n supportedVersions,\n // cannot make it work with appropriate type as execute function has 2\n //types and/cannot import function but only types\n (moduleExports: any) => {\n if (isWrapped(moduleExports.execute)) {\n this._unwrap(moduleExports, 'execute');\n }\n this._wrap(moduleExports, 'execute', this._patchExecute(moduleExports.defaultFieldResolver));\n return moduleExports;\n },\n moduleExports => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'execute');\n }\n },\n );\n }\n\n private _addPatchingParser(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/language/parser.js',\n supportedVersions,\n (moduleExports: { parse: parseType; [key: string]: any }) => {\n if (isWrapped(moduleExports.parse)) {\n this._unwrap(moduleExports, 'parse');\n }\n this._wrap(moduleExports, 'parse', this._patchParse());\n return moduleExports;\n },\n (moduleExports: { parse: parseType; [key: string]: any }) => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'parse');\n }\n },\n );\n }\n\n private _addPatchingValidate(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/validation/validate.js',\n supportedVersions,\n moduleExports => {\n if (isWrapped(moduleExports.validate)) {\n this._unwrap(moduleExports, 'validate');\n }\n this._wrap(moduleExports, 'validate', this._patchValidate());\n return moduleExports;\n },\n moduleExports => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'validate');\n }\n },\n );\n }\n\n private _patchExecute(defaultFieldResolved: GraphQLFieldResolver<any, any>): (original: executeType) => executeType {\n const instrumentation = this;\n return function execute(original) {\n return function patchExecute(this: executeType): PromiseOrValue<ExecutionResult> {\n let processedArgs: OtelExecutionArgs;\n\n // case when apollo server is used for example\n if (arguments.length >= 2) {\n const args = arguments as unknown as executeArgumentsArray;\n processedArgs = instrumentation._wrapExecuteArgs(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4],\n args[5],\n args[6],\n args[7],\n defaultFieldResolved,\n );\n } else {\n const args = arguments[0] as ExecutionArgs;\n processedArgs = instrumentation._wrapExecuteArgs(\n args.schema,\n args.document,\n args.rootValue,\n args.contextValue,\n args.variableValues,\n args.operationName,\n args.fieldResolver,\n args.typeResolver,\n defaultFieldResolved,\n );\n }\n\n const operation = getOperation(processedArgs.document, processedArgs.operationName);\n\n const span = instrumentation._createExecuteSpan(operation, processedArgs);\n\n processedArgs.contextValue[OTEL_GRAPHQL_DATA_SYMBOL] = {\n source: processedArgs.document\n ? processedArgs.document || (processedArgs.document as ObjectWithGraphQLData)[OTEL_GRAPHQL_DATA_SYMBOL]\n : undefined,\n span,\n fields: {},\n };\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<PromiseOrValue<ExecutionResult>>(\n () => {\n return (original as executeFunctionWithObj).apply(this, [processedArgs]);\n },\n (err, result) => {\n instrumentation._handleExecutionResult(span, err, result);\n },\n );\n });\n };\n };\n }\n\n private _handleExecutionResult(span: Span, err?: Error, result?: PromiseOrValue<ExecutionResult>) {\n if (result === undefined || err) {\n endSpan(span, err);\n return;\n }\n\n if (isPromise(result)) {\n result.then(\n resultData => {\n this._updateSpanFromResult(span, resultData);\n endSpan(span);\n },\n error => {\n endSpan(span, error);\n },\n );\n } else {\n this._updateSpanFromResult(span, result);\n endSpan(span);\n }\n }\n\n /**\n * Applies Sentry-specific span mutations based on the GraphQL execution result:\n * - Marks the execute span as errored if the result contains errors (and no status was set yet)\n * - Optionally renames the containing root span to include the GraphQL operation name(s)\n */\n private _updateSpanFromResult(span: Span, result: ExecutionResult): void {\n // We want to ensure spans are marked as errored if there are errors in the result\n // We only do that if the span is not already marked with a status\n if (result.errors?.length && !spanToJSON(span).status) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n }\n\n if (!this.getConfig().useOperationNameForRootSpan) {\n return;\n }\n\n const attributes = spanToJSON(span).data;\n\n // If operation.name is not set, we fall back to use operation.type only\n const operationType = attributes[AttributeNames.OPERATION_TYPE];\n const operationName = attributes[AttributeNames.OPERATION_NAME];\n\n if (!operationType) {\n return;\n }\n\n const rootSpan = getRootSpan(span);\n const rootSpanAttributes = spanToJSON(rootSpan).data;\n\n const existingOperations = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION] || [];\n\n const newOperation = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n\n // We keep track of each operation on the root span\n // This can either be a string, or an array of strings (if there are multiple operations)\n if (Array.isArray(existingOperations)) {\n (existingOperations as string[]).push(newOperation);\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, existingOperations);\n } else if (typeof existingOperations === 'string') {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);\n } else {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, newOperation);\n }\n\n if (!spanToJSON(rootSpan).data['original-description']) {\n rootSpan.setAttribute('original-description', spanToJSON(rootSpan).description);\n }\n // Important for e.g. @sentry/aws-serverless because this would otherwise overwrite the name again\n rootSpan.updateName(\n `${spanToJSON(rootSpan).data['original-description']} (${getGraphqlOperationNamesFromAttribute(\n existingOperations,\n )})`,\n );\n }\n\n private _patchParse(): (original: parseType) => parseType {\n const instrumentation = this;\n return function parse(original) {\n return function patchParse(this: parseType, source: string | Source, options?: ParseOptions): DocumentNode {\n return instrumentation._parse(this, original, source, options);\n };\n };\n }\n\n private _patchValidate(): (original: validateType) => validateType {\n const instrumentation = this;\n return function validate(original: validateType) {\n return function patchValidate(\n this: validateType,\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules?: ReadonlyArray<ValidationRule>,\n options?: { maxErrors?: number },\n typeInfo?: TypeInfo,\n ): ReadonlyArray<GraphQLError> {\n return instrumentation._validate(this, original, schema, documentAST, rules, typeInfo, options);\n };\n };\n }\n\n private _parse(obj: parseType, original: parseType, source: string | Source, options?: ParseOptions): DocumentNode {\n const span = startInactiveSpan({ name: SpanNames.PARSE });\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<DocumentNode & ObjectWithGraphQLData>(\n () => {\n return original.call(obj, source, options);\n },\n (err, result) => {\n if (result) {\n const operation = getOperation(result);\n if (!operation) {\n span.updateName(SpanNames.SCHEMA_PARSE);\n } else if (result.loc) {\n addSpanSource(span, result.loc);\n }\n }\n endSpan(span, err);\n },\n );\n });\n }\n\n private _validate(\n obj: validateType,\n original: validateType,\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules?: ReadonlyArray<ValidationRule>,\n typeInfo?: TypeInfo,\n options?: { maxErrors?: number },\n ): ReadonlyArray<GraphQLError> {\n const span = startInactiveSpan({ name: SpanNames.VALIDATE });\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<ReadonlyArray<GraphQLError>>(\n () => {\n return original.call(obj, schema, documentAST, rules, options, typeInfo);\n },\n (err, _errors) => {\n if (!documentAST.loc) {\n span.updateName(SpanNames.SCHEMA_VALIDATE);\n }\n endSpan(span, err);\n },\n );\n });\n }\n\n private _createExecuteSpan(operation: DefinitionNode | undefined, processedArgs: ExecutionArgs): Span {\n const span = startInactiveSpan({\n name: SpanNames.EXECUTE,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN },\n });\n if (operation) {\n const { operation: operationType, name: nameNode } = operation as OperationDefinitionNode;\n\n span.setAttribute(AttributeNames.OPERATION_TYPE, operationType);\n\n const operationName = nameNode?.value;\n\n // https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/instrumentation/graphql/\n // > The span name MUST be of the format <graphql.operation.type> <graphql.operation.name> provided that graphql.operation.type and graphql.operation.name are available.\n // > If graphql.operation.name is not available, the span SHOULD be named <graphql.operation.type>.\n if (operationName) {\n span.setAttribute(AttributeNames.OPERATION_NAME, operationName);\n span.updateName(`${operationType} ${operationName}`);\n } else {\n span.updateName(operationType);\n }\n } else {\n let operationName = ' ';\n if (processedArgs.operationName) {\n operationName = ` \"${processedArgs.operationName}\" `;\n }\n operationName = OPERATION_NOT_SUPPORTED.replace('$operationName$', operationName);\n span.setAttribute(AttributeNames.OPERATION_NAME, operationName);\n }\n\n if (processedArgs.document?.loc) {\n addSpanSource(span, processedArgs.document.loc);\n }\n\n return span;\n }\n\n private _wrapExecuteArgs(\n schema: GraphQLSchema,\n document: DocumentNode,\n rootValue: any,\n contextValue: any,\n variableValues: Maybe<{ [key: string]: any }>,\n operationName: Maybe<string>,\n fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,\n typeResolver: Maybe<GraphQLTypeResolver<any, any>>,\n defaultFieldResolved: GraphQLFieldResolver<any, any>,\n ): OtelExecutionArgs {\n if (!contextValue) {\n // oxlint-disable-next-line no-param-reassign\n contextValue = {};\n }\n\n if (contextValue[OTEL_GRAPHQL_DATA_SYMBOL] || this.getConfig().ignoreResolveSpans) {\n return {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n };\n }\n\n const isUsingDefaultResolver = fieldResolver == null;\n // follows graphql implementation here:\n // https://github.com/graphql/graphql-js/blob/0b7daed9811731362c71900e12e5ea0d1ecc7f1f/src/execution/execute.ts#L494\n const fieldResolverForExecute = fieldResolver ?? defaultFieldResolved;\n // oxlint-disable-next-line no-param-reassign\n fieldResolver = wrapFieldResolver(() => this.getConfig(), fieldResolverForExecute, isUsingDefaultResolver);\n\n if (schema) {\n wrapFields(schema.getQueryType() as any, () => this.getConfig());\n wrapFields(schema.getMutationType() as any, () => this.getConfig());\n }\n\n return {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n };\n }\n}\n\n// copy from packages/opentelemetry/utils\nfunction getGraphqlOperationNamesFromAttribute(attr: SpanAttributeValue): string {\n if (Array.isArray(attr)) {\n // oxlint-disable-next-line typescript/require-array-sort-compare\n const sorted = attr.slice().sort();\n\n // Up to 5 items, we just add all of them\n if (sorted.length <= 5) {\n return sorted.join(', ');\n } else {\n // Else, we add the first 5 and the diff of other operations\n return `${sorted.slice(0, 5).join(', ')}, +${sorted.length - 5}`;\n }\n }\n\n return `${attr}`;\n}\n"],"names":["InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","InstrumentationNodeModuleFile","isWrapped","instrumentation","getOperation","OTEL_GRAPHQL_DATA_SYMBOL","withActiveSpan","safeExecuteInTheMiddle","endSpan","isPromise","spanToJSON","SPAN_STATUS_ERROR","AttributeNames","getRootSpan","SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION","startInactiveSpan","SpanNames","addSpanSource","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","OPERATION_NOT_SUPPORTED","wrapFieldResolver","wrapFields"],"mappings":";;;;;;;;;;;;AAsEA,MAAM,YAAA,GAAe,iCAAA;AAErB,MAAM,MAAA,GAAS,2BAAA;AAEf,MAAM,cAAA,GAAqD;AAAA,EACzD,kBAAA,EAAoB;AACtB,CAAA;AAEA,MAAM,iBAAA,GAAoB,CAAC,cAAc,CAAA;AAElC,MAAM,+BAA+BA,mCAAA,CAAwD;AAAA,EAClG,WAAA,CAAY,MAAA,GAAuC,EAAC,EAAG;AACrD,IAAA,KAAA,CAAM,cAAcC,gBAAA,EAAa,EAAE,GAAG,cAAA,EAAgB,GAAG,QAAQ,CAAA;AAAA,EACnE;AAAA,EAES,SAAA,CAAU,MAAA,GAAuC,EAAC,EAAG;AAC5D,IAAA,KAAA,CAAM,UAAU,EAAE,GAAG,cAAA,EAAgB,GAAG,QAAQ,CAAA;AAAA,EAClD;AAA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ACF;AAEA,IAAA,MAAM,yBAAyB,aAAA,IAAiB,IAAA;AAGhD,IAAA,MAAM,0BAA0B,aAAA,IAAiB,oBAAA;AAEjD,IAAA,aAAA,GAAgBe,wBAAkB,MAAM,IAAA,CAAK,SAAA,EAAU,EAAG,yBAAyB,sBAAsB,CAAA;AAEzG,IAAA,IAAI,MAAA,EAAQ;AACV,MAAAC,gBAAA,CAAW,OAAO,YAAA,EAAa,EAAU,MAAM,IAAA,CAAK,WAAW,CAAA;AAC/D,MAAAA,gBAAA,CAAW,OAAO,eAAA,EAAgB,EAAU,MAAM,IAAA,CAAK,WAAW,CAAA;AAAA,IACpE;AAEA,IAAA,OAAO;AAAA,MACL,MAAA;AAAA,MACA,QAAA;AAAA,MACA,SAAA;AAAA,MACA,YAAA;AAAA,MACA,cAAA;AAAA,MACA,aAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;AAGA,SAAS,sCAAsC,IAAA,EAAkC;AAC/E,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG;AAEvB,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,EAAM,CAAE,IAAA,EAAK;AAGjC,IAAA,IAAI,MAAA,CAAO,UAAU,CAAA,EAAG;AACtB,MAAA,OAAO,MAAA,CAAO,KAAK,IAAI,CAAA;AAAA,IACzB,CAAA,MAAO;AAEL,MAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,GAAA,EAAM,MAAA,CAAO,MAAA,GAAS,CAAC,CAAA,CAAA;AAAA,IAChE;AAAA,EACF;AAEA,EAAA,OAAO,GAAG,IAAI,CAAA,CAAA;AAChB;;;;"} | ||
| {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/graphql/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-graphql\n * - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0\n * - Types from `graphql` package inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n * - Span lifecycle migrated from the OpenTelemetry tracer to the @sentry/core span API\n * - `auto.graphql.otel.graphql` origin baked into the execute span (previously set via a Sentry responseHook)\n * - The generic `responseHook` config was removed; its Sentry-specific logic (error status + root span renaming\n * via `useOperationNameForRootSpan`) is now applied directly when the execution result is handled\n */\n\n/* oxlint-disable max-lines */\n\nimport {\n isWrapped,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport type {\n DefinitionNode,\n DocumentNode,\n ExecutionArgs,\n ExecutionResult,\n GraphQLError,\n GraphQLFieldResolver,\n GraphQLSchema,\n GraphQLTypeResolver,\n OperationDefinitionNode,\n ParseOptions,\n PromiseOrValue,\n Source,\n TypeInfo,\n ValidationRule,\n} from './graphql-types';\nimport type { Maybe } from './graphql-types';\nimport { SpanNames } from './enum';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { OTEL_GRAPHQL_DATA_SYMBOL } from './symbols';\n\nimport {\n type executeFunctionWithObj,\n type executeArgumentsArray,\n type executeType,\n type parseType,\n type validateType,\n type OtelExecutionArgs,\n type ObjectWithGraphQLData,\n OPERATION_NOT_SUPPORTED,\n} from './internal-types';\nimport { addSpanSource, endSpan, getOperation, isPromise, wrapFieldResolver, wrapFields } from './utils';\n\nimport type { Span, SpanAttributeValue } from '@sentry/core';\nimport {\n getRootSpan,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n spanToJSON,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';\nimport type { GraphQLInstrumentationConfig, GraphQLInstrumentationParsedConfig } from './types';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-graphql';\n\nconst ORIGIN = 'auto.graphql.otel.graphql';\n\nconst DEFAULT_CONFIG: GraphQLInstrumentationParsedConfig = {\n ignoreResolveSpans: false,\n};\n\nconst supportedVersions = ['>=14.0.0 <17'];\n\nexport class GraphQLInstrumentation extends InstrumentationBase<GraphQLInstrumentationParsedConfig> {\n constructor(config: GraphQLInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, { ...DEFAULT_CONFIG, ...config });\n }\n\n override setConfig(config: GraphQLInstrumentationConfig = {}) {\n super.setConfig({ ...DEFAULT_CONFIG, ...config });\n }\n\n protected init() {\n const module = new InstrumentationNodeModuleDefinition('graphql', supportedVersions);\n module.files.push(this._addPatchingExecute());\n module.files.push(this._addPatchingParser());\n module.files.push(this._addPatchingValidate());\n\n return module;\n }\n\n private _addPatchingExecute(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/execution/execute.js',\n supportedVersions,\n // cannot make it work with appropriate type as execute function has 2\n //types and/cannot import function but only types\n (moduleExports: any) => {\n if (isWrapped(moduleExports.execute)) {\n this._unwrap(moduleExports, 'execute');\n }\n this._wrap(moduleExports, 'execute', this._patchExecute(moduleExports.defaultFieldResolver));\n return moduleExports;\n },\n moduleExports => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'execute');\n }\n },\n );\n }\n\n private _addPatchingParser(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/language/parser.js',\n supportedVersions,\n (moduleExports: { parse: parseType; [key: string]: any }) => {\n if (isWrapped(moduleExports.parse)) {\n this._unwrap(moduleExports, 'parse');\n }\n this._wrap(moduleExports, 'parse', this._patchParse());\n return moduleExports;\n },\n (moduleExports: { parse: parseType; [key: string]: any }) => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'parse');\n }\n },\n );\n }\n\n private _addPatchingValidate(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/validation/validate.js',\n supportedVersions,\n moduleExports => {\n if (isWrapped(moduleExports.validate)) {\n this._unwrap(moduleExports, 'validate');\n }\n this._wrap(moduleExports, 'validate', this._patchValidate());\n return moduleExports;\n },\n moduleExports => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'validate');\n }\n },\n );\n }\n\n private _patchExecute(defaultFieldResolved: GraphQLFieldResolver<any, any>): (original: executeType) => executeType {\n const instrumentation = this;\n return function execute(original) {\n return function patchExecute(this: executeType): PromiseOrValue<ExecutionResult> {\n let processedArgs: OtelExecutionArgs;\n\n // case when apollo server is used for example\n if (arguments.length >= 2) {\n const args = arguments as unknown as executeArgumentsArray;\n processedArgs = instrumentation._wrapExecuteArgs(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4],\n args[5],\n args[6],\n args[7],\n defaultFieldResolved,\n );\n } else {\n const args = arguments[0] as ExecutionArgs;\n processedArgs = instrumentation._wrapExecuteArgs(\n args.schema,\n args.document,\n args.rootValue,\n args.contextValue,\n args.variableValues,\n args.operationName,\n args.fieldResolver,\n args.typeResolver,\n defaultFieldResolved,\n );\n }\n\n const operation = getOperation(processedArgs.document, processedArgs.operationName);\n\n const span = instrumentation._createExecuteSpan(operation, processedArgs);\n\n processedArgs.contextValue[OTEL_GRAPHQL_DATA_SYMBOL] = {\n source: processedArgs.document\n ? processedArgs.document || (processedArgs.document as ObjectWithGraphQLData)[OTEL_GRAPHQL_DATA_SYMBOL]\n : undefined,\n span,\n fields: {},\n };\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<PromiseOrValue<ExecutionResult>>(\n () => {\n return (original as executeFunctionWithObj).apply(this, [processedArgs]);\n },\n (err, result) => {\n instrumentation._handleExecutionResult(span, err, result);\n },\n );\n });\n };\n };\n }\n\n private _handleExecutionResult(span: Span, err?: Error, result?: PromiseOrValue<ExecutionResult>) {\n if (result === undefined || err) {\n endSpan(span, err);\n return;\n }\n\n if (isPromise(result)) {\n result.then(\n resultData => {\n this._updateSpanFromResult(span, resultData);\n endSpan(span);\n },\n error => {\n endSpan(span, error);\n },\n );\n } else {\n this._updateSpanFromResult(span, result);\n endSpan(span);\n }\n }\n\n /**\n * Applies Sentry-specific span mutations based on the GraphQL execution result:\n * - Marks the execute span as errored if the result contains errors (and no status was set yet)\n * - Optionally renames the containing root span to include the GraphQL operation name(s)\n */\n private _updateSpanFromResult(span: Span, result: ExecutionResult): void {\n // We want to ensure spans are marked as errored if there are errors in the result\n // We only do that if the span is not already marked with a status\n if (result.errors?.length && !spanToJSON(span).status) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n }\n\n if (!this.getConfig().useOperationNameForRootSpan) {\n return;\n }\n\n const attributes = spanToJSON(span).data;\n\n // If operation.name is not set, we fall back to use operation.type only\n const operationType = attributes[AttributeNames.OPERATION_TYPE];\n const operationName = attributes[AttributeNames.OPERATION_NAME];\n\n if (!operationType) {\n return;\n }\n\n const rootSpan = getRootSpan(span);\n const rootSpanAttributes = spanToJSON(rootSpan).data;\n\n const existingOperations = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION] || [];\n\n const newOperation = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n\n // We keep track of each operation on the root span\n // This can either be a string, or an array of strings (if there are multiple operations)\n if (Array.isArray(existingOperations)) {\n (existingOperations as string[]).push(newOperation);\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, existingOperations);\n } else if (typeof existingOperations === 'string') {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);\n } else {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, newOperation);\n }\n\n if (!spanToJSON(rootSpan).data['original-description']) {\n rootSpan.setAttribute('original-description', spanToJSON(rootSpan).description);\n }\n // Important for e.g. @sentry/aws-serverless because this would otherwise overwrite the name again\n rootSpan.updateName(\n `${spanToJSON(rootSpan).data['original-description']} (${getGraphqlOperationNamesFromAttribute(\n existingOperations,\n )})`,\n );\n }\n\n private _patchParse(): (original: parseType) => parseType {\n const instrumentation = this;\n return function parse(original) {\n return function patchParse(this: parseType, source: string | Source, options?: ParseOptions): DocumentNode {\n return instrumentation._parse(this, original, source, options);\n };\n };\n }\n\n private _patchValidate(): (original: validateType) => validateType {\n const instrumentation = this;\n return function validate(original: validateType) {\n return function patchValidate(\n this: validateType,\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules?: ReadonlyArray<ValidationRule>,\n options?: { maxErrors?: number },\n typeInfo?: TypeInfo,\n ): ReadonlyArray<GraphQLError> {\n return instrumentation._validate(this, original, schema, documentAST, rules, typeInfo, options);\n };\n };\n }\n\n private _parse(obj: parseType, original: parseType, source: string | Source, options?: ParseOptions): DocumentNode {\n const span = startInactiveSpan({ name: SpanNames.PARSE });\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<DocumentNode & ObjectWithGraphQLData>(\n () => {\n return original.call(obj, source, options);\n },\n (err, result) => {\n if (result) {\n const operation = getOperation(result);\n if (!operation) {\n span.updateName(SpanNames.SCHEMA_PARSE);\n } else if (result.loc) {\n addSpanSource(span, result.loc);\n }\n }\n endSpan(span, err);\n },\n );\n });\n }\n\n private _validate(\n obj: validateType,\n original: validateType,\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules?: ReadonlyArray<ValidationRule>,\n typeInfo?: TypeInfo,\n options?: { maxErrors?: number },\n ): ReadonlyArray<GraphQLError> {\n const span = startInactiveSpan({ name: SpanNames.VALIDATE });\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<ReadonlyArray<GraphQLError>>(\n () => {\n return original.call(obj, schema, documentAST, rules, options, typeInfo);\n },\n (err, _errors) => {\n if (!documentAST.loc) {\n span.updateName(SpanNames.SCHEMA_VALIDATE);\n }\n endSpan(span, err);\n },\n );\n });\n }\n\n private _createExecuteSpan(operation: DefinitionNode | undefined, processedArgs: OtelExecutionArgs): Span {\n const span = startInactiveSpan({\n name: SpanNames.EXECUTE,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN },\n });\n if (operation) {\n const { operation: operationType, name: nameNode } = operation as OperationDefinitionNode;\n\n span.setAttribute(AttributeNames.OPERATION_TYPE, operationType);\n\n const operationName = nameNode?.value;\n\n // https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/instrumentation/graphql/\n // > The span name MUST be of the format <graphql.operation.type> <graphql.operation.name> provided that graphql.operation.type and graphql.operation.name are available.\n // > If graphql.operation.name is not available, the span SHOULD be named <graphql.operation.type>.\n if (operationName) {\n span.setAttribute(AttributeNames.OPERATION_NAME, operationName);\n span.updateName(`${operationType} ${operationName}`);\n } else {\n span.updateName(operationType);\n }\n } else {\n let operationName = ' ';\n if (processedArgs.operationName) {\n operationName = ` \"${processedArgs.operationName}\" `;\n }\n operationName = OPERATION_NOT_SUPPORTED.replace('$operationName$', operationName);\n span.setAttribute(AttributeNames.OPERATION_NAME, operationName);\n }\n\n if (processedArgs.document?.loc) {\n addSpanSource(span, processedArgs.document.loc);\n }\n\n return span;\n }\n\n private _wrapExecuteArgs(\n schema: GraphQLSchema,\n document: DocumentNode,\n rootValue: any,\n contextValue: any,\n variableValues: Maybe<{ [key: string]: any }>,\n operationName: Maybe<string>,\n fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,\n typeResolver: Maybe<GraphQLTypeResolver<any, any>>,\n defaultFieldResolved: GraphQLFieldResolver<any, any>,\n ): OtelExecutionArgs {\n if (!contextValue) {\n // oxlint-disable-next-line no-param-reassign\n contextValue = {};\n }\n\n if (contextValue[OTEL_GRAPHQL_DATA_SYMBOL] || this.getConfig().ignoreResolveSpans) {\n return {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n };\n }\n\n const isUsingDefaultResolver = fieldResolver == null;\n // follows graphql implementation here:\n // https://github.com/graphql/graphql-js/blob/0b7daed9811731362c71900e12e5ea0d1ecc7f1f/src/execution/execute.ts#L494\n const fieldResolverForExecute = fieldResolver ?? defaultFieldResolved;\n // oxlint-disable-next-line no-param-reassign\n fieldResolver = wrapFieldResolver(() => this.getConfig(), fieldResolverForExecute, isUsingDefaultResolver);\n\n if (schema) {\n wrapFields(schema.getQueryType() as any, () => this.getConfig());\n wrapFields(schema.getMutationType() as any, () => this.getConfig());\n }\n\n return {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n };\n }\n}\n\n// copy from packages/opentelemetry/utils\nfunction getGraphqlOperationNamesFromAttribute(attr: SpanAttributeValue): string {\n if (Array.isArray(attr)) {\n // oxlint-disable-next-line typescript/require-array-sort-compare\n const sorted = attr.slice().sort();\n\n // Up to 5 items, we just add all of them\n if (sorted.length <= 5) {\n return sorted.join(', ');\n } else {\n // Else, we add the first 5 and the diff of other operations\n return `${sorted.slice(0, 5).join(', ')}, +${sorted.length - 5}`;\n }\n }\n\n return `${attr}`;\n}\n"],"names":["InstrumentationBase","SDK_VERSION","InstrumentationNodeModuleDefinition","InstrumentationNodeModuleFile","isWrapped","instrumentation","getOperation","OTEL_GRAPHQL_DATA_SYMBOL","withActiveSpan","safeExecuteInTheMiddle","endSpan","isPromise","spanToJSON","SPAN_STATUS_ERROR","AttributeNames","getRootSpan","SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION","startInactiveSpan","SpanNames","addSpanSource","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","OPERATION_NOT_SUPPORTED","wrapFieldResolver","wrapFields"],"mappings":";;;;;;;;;;;;AAsEA,MAAM,YAAA,GAAe,iCAAA;AAErB,MAAM,MAAA,GAAS,2BAAA;AAEf,MAAM,cAAA,GAAqD;AAA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,IAAI,CAAA;AAAA,IACzB,CAAA,MAAO;AAEL,MAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,GAAA,EAAM,MAAA,CAAO,MAAA,GAAS,CAAC,CAAA,CAAA;AAAA,IAChE;AAAA,EACF;AAEA,EAAA,OAAO,GAAG,IAAI,CAAA,CAAA;AAChB;;;;"} |
@@ -12,5 +12,2 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| }; | ||
| const isObjectLike = (value) => { | ||
| return typeof value == "object" && value !== null; | ||
| }; | ||
| function addSpanSource(span, loc, start, end) { | ||
@@ -219,3 +216,3 @@ const source = getSourceFromLocation(loc, start, end); | ||
| const config = getConfig(); | ||
| if (config.ignoreTrivialResolveSpans && isDefaultResolver && (isObjectLike(source) || typeof source === "function")) { | ||
| if (config.ignoreTrivialResolveSpans && isDefaultResolver && (core.isObjectLike(source) || typeof source === "function")) { | ||
| const property = source[info.fieldName]; | ||
@@ -222,0 +219,0 @@ if (typeof property !== "function") { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/graphql/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-graphql\n * - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0\n * - Types from `graphql` package inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n * - Span lifecycle migrated from the OpenTelemetry tracer to the @sentry/core span API\n */\n\nimport type {\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLResolveInfo,\n GraphQLType,\n GraphQLUnionType,\n Location,\n Maybe,\n Token,\n} from './graphql-types';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport { SPAN_STATUS_ERROR, startInactiveSpan, withActiveSpan } from '@sentry/core';\nimport { AllowedOperationTypes, SpanNames, TokenKind } from './enum';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { OTEL_GRAPHQL_DATA_SYMBOL, OTEL_PATCHED_SYMBOL } from './symbols';\nimport type { GraphQLField, GraphQLPath, ObjectWithGraphQLData, OtelPatched } from './internal-types';\nimport type { GraphQLInstrumentationParsedConfig } from './types';\n\nconst OPERATION_VALUES = Object.values(AllowedOperationTypes);\n\n// https://github.com/graphql/graphql-js/blob/main/src/jsutils/isPromise.ts\nexport const isPromise = (value: any): value is Promise<unknown> => {\n return typeof value?.then === 'function';\n};\n\n// https://github.com/graphql/graphql-js/blob/main/src/jsutils/isObjectLike.ts\nconst isObjectLike = (value: unknown): value is { [key: string]: unknown } => {\n return typeof value == 'object' && value !== null;\n};\n\nexport function addSpanSource(span: Span, loc?: Location, start?: number, end?: number): void {\n const source = getSourceFromLocation(loc, start, end);\n span.setAttribute(AttributeNames.SOURCE, source);\n}\n\nfunction createFieldIfNotExists(\n contextValue: any,\n info: GraphQLResolveInfo,\n path: string[],\n): {\n field: GraphQLField;\n spanAdded: boolean;\n} {\n let field = getField(contextValue, path);\n if (field) {\n return { field, spanAdded: false };\n }\n\n const parentSpan = getParentFieldSpan(contextValue, path);\n\n field = {\n span: createResolverSpan(contextValue, info, path, parentSpan),\n };\n\n addField(contextValue, path, field);\n\n return { field, spanAdded: true };\n}\n\nfunction createResolverSpan(contextValue: any, info: GraphQLResolveInfo, path: string[], parentSpan?: Span): Span {\n const attributes: SpanAttributes = {\n [AttributeNames.FIELD_NAME]: info.fieldName,\n [AttributeNames.FIELD_PATH]: path.join('.'),\n [AttributeNames.FIELD_TYPE]: info.returnType.toString(),\n [AttributeNames.PARENT_NAME]: info.parentType.name,\n };\n\n const span = startInactiveSpan({\n name: `${SpanNames.RESOLVE} ${attributes[AttributeNames.FIELD_PATH]}`,\n attributes,\n parentSpan,\n });\n\n const document = contextValue[OTEL_GRAPHQL_DATA_SYMBOL].source;\n const fieldNode = info.fieldNodes.find(fieldNode => fieldNode.kind === 'Field');\n\n if (fieldNode) {\n addSpanSource(span, document.loc, fieldNode.loc?.start, fieldNode.loc?.end);\n }\n\n return span;\n}\n\nexport function endSpan(span: Span, error?: Error): void {\n if (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n}\n\nexport function getOperation(document: DocumentNode, operationName?: Maybe<string>): DefinitionNodeLike | undefined {\n if (!document || !Array.isArray(document.definitions)) {\n return undefined;\n }\n\n if (operationName) {\n return document.definitions\n .filter(definition => OPERATION_VALUES.indexOf(definition?.operation) !== -1)\n .find(definition => operationName === definition?.name?.value);\n } else {\n return document.definitions.find(definition => OPERATION_VALUES.indexOf(definition?.operation) !== -1);\n }\n}\n\ntype DefinitionNodeLike = DocumentNode['definitions'][number];\n\nfunction addField(contextValue: any, path: string[], field: GraphQLField) {\n return (contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path.join('.')] = field);\n}\n\nfunction getField(contextValue: any, path: string[]): GraphQLField {\n return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path.join('.')];\n}\n\nfunction getParentFieldSpan(contextValue: any, path: string[]): Span {\n for (let i = path.length - 1; i > 0; i--) {\n const field = getField(contextValue, path.slice(0, i));\n\n if (field) {\n return field.span;\n }\n }\n\n return getRootSpan(contextValue);\n}\n\nfunction getRootSpan(contextValue: any): Span {\n return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].span;\n}\n\nfunction pathToArray(path: GraphQLPath): string[] {\n const flattened: string[] = [];\n let curr: GraphQLPath | undefined = path;\n while (curr) {\n flattened.push(String(curr.key));\n curr = curr.prev;\n }\n return flattened.reverse();\n}\n\nfunction repeatBreak(i: number): string {\n return repeatChar('\\n', i);\n}\n\nfunction repeatSpace(i: number): string {\n return repeatChar(' ', i);\n}\n\nfunction repeatChar(char: string, to: number): string {\n let text = '';\n for (let i = 0; i < to; i++) {\n text += char;\n }\n return text;\n}\n\nconst KindsToBeRemoved: string[] = [TokenKind.FLOAT, TokenKind.STRING, TokenKind.INT, TokenKind.BLOCK_STRING];\n\nexport function getSourceFromLocation(loc?: Location, inputStart?: number, inputEnd?: number): string {\n let source = '';\n\n if (loc?.startToken) {\n const start = typeof inputStart === 'number' ? inputStart : loc.start;\n const end = typeof inputEnd === 'number' ? inputEnd : loc.end;\n\n let next: Token | null = loc.startToken.next;\n let previousLine: number | undefined = 1;\n while (next) {\n if (next.start < start) {\n next = next.next;\n previousLine = next?.line;\n continue;\n }\n if (next.end > end) {\n next = next.next;\n previousLine = next?.line;\n continue;\n }\n let value = next.value || next.kind;\n let space = '';\n if (KindsToBeRemoved.indexOf(next.kind) >= 0) {\n value = '*';\n }\n if (next.kind === TokenKind.STRING) {\n value = `\"${value}\"`;\n }\n if (next.kind === TokenKind.EOF) {\n value = '';\n }\n if (next.line > previousLine!) {\n source += repeatBreak(next.line - previousLine!);\n previousLine = next.line;\n space = repeatSpace(next.column - 1);\n } else {\n if (next.line === next.prev?.line) {\n space = repeatSpace(next.start - (next.prev?.end || 0));\n }\n }\n source += space + value;\n if (next) {\n next = next.next!;\n }\n }\n }\n\n return source;\n}\n\nexport function wrapFields(\n type: Maybe<GraphQLObjectType & OtelPatched>,\n getConfig: () => GraphQLInstrumentationParsedConfig,\n): void {\n if (!type || (type as any)[OTEL_PATCHED_SYMBOL]) {\n return;\n }\n const fields = type.getFields();\n\n (type as any)[OTEL_PATCHED_SYMBOL] = true;\n\n Object.keys(fields).forEach(key => {\n const field = fields[key];\n\n if (!field) {\n return;\n }\n\n if (field.resolve) {\n field.resolve = wrapFieldResolver(getConfig, field.resolve);\n }\n\n if (field.type) {\n const unwrappedTypes = unwrapType(field.type);\n for (const unwrappedType of unwrappedTypes) {\n wrapFields(unwrappedType as any, getConfig);\n }\n }\n });\n}\n\nfunction unwrapType(type: GraphQLOutputType): readonly GraphQLObjectType[] {\n // unwrap wrapping types (non-nullable and list types)\n if ('ofType' in type) {\n return unwrapType(type.ofType);\n }\n\n // unwrap union types\n if (isGraphQLUnionType(type)) {\n return type.getTypes();\n }\n\n // return object types\n if (isGraphQLObjectType(type)) {\n return [type];\n }\n\n return [];\n}\n\nfunction isGraphQLUnionType(type: GraphQLType): type is GraphQLUnionType {\n return 'getTypes' in type && typeof type.getTypes === 'function';\n}\n\nfunction isGraphQLObjectType(type: GraphQLType): type is GraphQLObjectType {\n return 'getFields' in type && typeof type.getFields === 'function';\n}\n\nconst handleResolveSpanError = (resolveSpan: Span, err: any, shouldEndSpan: boolean) => {\n if (!shouldEndSpan) {\n return;\n }\n resolveSpan.setStatus({\n code: SPAN_STATUS_ERROR,\n message: err.message,\n });\n resolveSpan.end();\n};\n\nconst handleResolveSpanSuccess = (resolveSpan: Span, shouldEndSpan: boolean) => {\n if (!shouldEndSpan) {\n return;\n }\n resolveSpan.end();\n};\n\nexport function wrapFieldResolver<TSource = any, TContext = any, TArgs = any>(\n getConfig: () => GraphQLInstrumentationParsedConfig,\n fieldResolver: Maybe<GraphQLFieldResolver<TSource, TContext, TArgs> & OtelPatched>,\n isDefaultResolver = false,\n): GraphQLFieldResolver<TSource, TContext & ObjectWithGraphQLData, TArgs> & OtelPatched {\n if ((wrappedFieldResolver as OtelPatched)[OTEL_PATCHED_SYMBOL] || typeof fieldResolver !== 'function') {\n return fieldResolver!;\n }\n\n function wrappedFieldResolver(\n this: GraphQLFieldResolver<TSource, TContext, TArgs>,\n source: TSource,\n args: TArgs,\n contextValue: TContext & ObjectWithGraphQLData,\n info: GraphQLResolveInfo,\n ) {\n if (!fieldResolver) {\n return undefined;\n }\n const config = getConfig();\n\n // follows what graphql is doing to decide if this is a trivial resolver\n // for which we don't need to create a resolve span\n if (\n config.ignoreTrivialResolveSpans &&\n isDefaultResolver &&\n (isObjectLike(source) || typeof source === 'function')\n ) {\n const property = (source as any)[info.fieldName];\n // a function execution is not trivial and should be recorder.\n // property which is not a function is just a value and we don't want a \"resolve\" span for it\n if (typeof property !== 'function') {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n }\n\n if (!contextValue[OTEL_GRAPHQL_DATA_SYMBOL]) {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n const path = pathToArray(info?.path);\n\n const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path);\n const span = field.span;\n const shouldEndSpan = spanAdded;\n\n return withActiveSpan(span, () => {\n try {\n const res = fieldResolver.call(this, source, args, contextValue, info);\n if (isPromise(res)) {\n return res.then(\n (r: any) => {\n handleResolveSpanSuccess(span, shouldEndSpan);\n return r;\n },\n (err: Error) => {\n handleResolveSpanError(span, err, shouldEndSpan);\n throw err;\n },\n );\n } else {\n handleResolveSpanSuccess(span, shouldEndSpan);\n return res;\n }\n } catch (err: any) {\n handleResolveSpanError(span, err, shouldEndSpan);\n throw err;\n }\n });\n }\n\n (wrappedFieldResolver as OtelPatched)[OTEL_PATCHED_SYMBOL] = true;\n\n return wrappedFieldResolver;\n}\n"],"names":["AllowedOperationTypes","AttributeNames","startInactiveSpan","SpanNames","OTEL_GRAPHQL_DATA_SYMBOL","fieldNode","SPAN_STATUS_ERROR","TokenKind","OTEL_PATCHED_SYMBOL","withActiveSpan"],"mappings":";;;;;;;AAgCA,MAAM,gBAAA,GAAmB,MAAA,CAAO,MAAA,CAAOA,2BAAqB,CAAA;AAGrD,MAAM,SAAA,GAAY,CAAC,KAAA,KAA0C;AAClE,EAAA,OAAO,OAAO,OAAO,IAAA,KAAS,UAAA;AAChC;AAGA,MAAM,YAAA,GAAe,CAAC,KAAA,KAAwD;AAC5E,EAAA,OAAO,OAAO,KAAA,IAAS,QAAA,IAAY,KAAA,KAAU,IAAA;AAC/C,CAAA;AAEO,SAAS,aAAA,CAAc,IAAA,EAAY,GAAA,EAAgB,KAAA,EAAgB,GAAA,EAAoB;AAC5F,EAAA,MAAM,MAAA,GAAS,qBAAA,CAAsB,GAAA,EAAK,KAAA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O,WAAA,CAAY,IAAA,EAAM,IAAI,CAAA;AAEnC,IAAA,MAAM,EAAE,KAAA,EAAO,SAAA,KAAc,sBAAA,CAAuB,YAAA,EAAc,MAAM,IAAI,CAAA;AAC5E,IAAA,MAAM,OAAO,KAAA,CAAM,IAAA;AACnB,IAAA,MAAM,aAAA,GAAgB,SAAA;AAEtB,IAAA,OAAOK,mBAAA,CAAe,MAAM,MAAM;AAChC,MAAA,IAAI;AACF,QAAA,MAAM,MAAM,aAAA,CAAc,IAAA,CAAK,MAAM,MAAA,EAAQ,IAAA,EAAM,cAAc,IAAI,CAAA;AACrE,QAAA,IAAI,SAAA,CAAU,GAAG,CAAA,EAAG;AAClB,UAAA,OAAO,GAAA,CAAI,IAAA;AAAA,YACT,CAAC,CAAA,KAAW;AACV,cAAA,wBAAA,CAAyB,MAAM,aAAa,CAAA;AAC5C,cAAA,OAAO,CAAA;AAAA,YACT,CAAA;AAAA,YACA,CAAC,GAAA,KAAe;AACd,cAAA,sBAAA,CAAuB,IAAA,EAAM,KAAK,aAAa,CAAA;AAC/C,cAAA,MAAM,GAAA;AAAA,YACR;AAAA,WACF;AAAA,QACF,CAAA,MAAO;AACL,UAAA,wBAAA,CAAyB,MAAM,aAAa,CAAA;AAC5C,UAAA,OAAO,GAAA;AAAA,QACT;AAAA,MACF,SAAS,GAAA,EAAU;AACjB,QAAA,sBAAA,CAAuB,IAAA,EAAM,KAAK,aAAa,CAAA;AAC/C,QAAA,MAAM,GAAA;AAAA,MACR;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAEA,EAAC,oBAAA,CAAqCD,2BAAmB,CAAA,GAAI,IAAA;AAE7D,EAAA,OAAO,oBAAA;AACT;;;;;;;;;;"} | ||
| {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/graphql/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-graphql\n * - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0\n * - Types from `graphql` package inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n * - Span lifecycle migrated from the OpenTelemetry tracer to the @sentry/core span API\n */\n\nimport type {\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLResolveInfo,\n GraphQLType,\n GraphQLUnionType,\n Location,\n Maybe,\n Token,\n} from './graphql-types';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport { isObjectLike, SPAN_STATUS_ERROR, startInactiveSpan, withActiveSpan } from '@sentry/core';\nimport { AllowedOperationTypes, SpanNames, TokenKind } from './enum';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { OTEL_GRAPHQL_DATA_SYMBOL, OTEL_PATCHED_SYMBOL } from './symbols';\nimport type { GraphQLField, GraphQLPath, ObjectWithGraphQLData, OtelPatched } from './internal-types';\nimport type { GraphQLInstrumentationParsedConfig } from './types';\n\nconst OPERATION_VALUES = Object.values(AllowedOperationTypes);\n\n// https://github.com/graphql/graphql-js/blob/main/src/jsutils/isPromise.ts\nexport const isPromise = (value: any): value is Promise<unknown> => {\n return typeof value?.then === 'function';\n};\n\nexport function addSpanSource(span: Span, loc?: Location, start?: number, end?: number): void {\n const source = getSourceFromLocation(loc, start, end);\n span.setAttribute(AttributeNames.SOURCE, source);\n}\n\nfunction createFieldIfNotExists(\n contextValue: any,\n info: GraphQLResolveInfo,\n path: string[],\n): {\n field: GraphQLField;\n spanAdded: boolean;\n} {\n let field = getField(contextValue, path);\n if (field) {\n return { field, spanAdded: false };\n }\n\n const parentSpan = getParentFieldSpan(contextValue, path);\n\n field = {\n span: createResolverSpan(contextValue, info, path, parentSpan),\n };\n\n addField(contextValue, path, field);\n\n return { field, spanAdded: true };\n}\n\nfunction createResolverSpan(contextValue: any, info: GraphQLResolveInfo, path: string[], parentSpan?: Span): Span {\n const attributes: SpanAttributes = {\n [AttributeNames.FIELD_NAME]: info.fieldName,\n [AttributeNames.FIELD_PATH]: path.join('.'),\n [AttributeNames.FIELD_TYPE]: info.returnType.toString(),\n [AttributeNames.PARENT_NAME]: info.parentType.name,\n };\n\n const span = startInactiveSpan({\n name: `${SpanNames.RESOLVE} ${attributes[AttributeNames.FIELD_PATH]}`,\n attributes,\n parentSpan,\n });\n\n const document = contextValue[OTEL_GRAPHQL_DATA_SYMBOL].source;\n const fieldNode = info.fieldNodes.find(fieldNode => fieldNode.kind === 'Field');\n\n if (fieldNode) {\n addSpanSource(span, document.loc, fieldNode.loc?.start, fieldNode.loc?.end);\n }\n\n return span;\n}\n\nexport function endSpan(span: Span, error?: Error): void {\n if (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n}\n\nexport function getOperation(document: DocumentNode, operationName?: Maybe<string>): DefinitionNodeLike | undefined {\n if (!document || !Array.isArray(document.definitions)) {\n return undefined;\n }\n\n if (operationName) {\n return document.definitions\n .filter(definition => OPERATION_VALUES.indexOf(definition?.operation) !== -1)\n .find(definition => operationName === definition?.name?.value);\n } else {\n return document.definitions.find(definition => OPERATION_VALUES.indexOf(definition?.operation) !== -1);\n }\n}\n\ntype DefinitionNodeLike = DocumentNode['definitions'][number];\n\nfunction addField(contextValue: any, path: string[], field: GraphQLField) {\n return (contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path.join('.')] = field);\n}\n\nfunction getField(contextValue: any, path: string[]): GraphQLField {\n return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path.join('.')];\n}\n\nfunction getParentFieldSpan(contextValue: any, path: string[]): Span {\n for (let i = path.length - 1; i > 0; i--) {\n const field = getField(contextValue, path.slice(0, i));\n\n if (field) {\n return field.span;\n }\n }\n\n return getRootSpan(contextValue);\n}\n\nfunction getRootSpan(contextValue: any): Span {\n return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].span;\n}\n\nfunction pathToArray(path: GraphQLPath): string[] {\n const flattened: string[] = [];\n let curr: GraphQLPath | undefined = path;\n while (curr) {\n flattened.push(String(curr.key));\n curr = curr.prev;\n }\n return flattened.reverse();\n}\n\nfunction repeatBreak(i: number): string {\n return repeatChar('\\n', i);\n}\n\nfunction repeatSpace(i: number): string {\n return repeatChar(' ', i);\n}\n\nfunction repeatChar(char: string, to: number): string {\n let text = '';\n for (let i = 0; i < to; i++) {\n text += char;\n }\n return text;\n}\n\nconst KindsToBeRemoved: string[] = [TokenKind.FLOAT, TokenKind.STRING, TokenKind.INT, TokenKind.BLOCK_STRING];\n\nexport function getSourceFromLocation(loc?: Location, inputStart?: number, inputEnd?: number): string {\n let source = '';\n\n if (loc?.startToken) {\n const start = typeof inputStart === 'number' ? inputStart : loc.start;\n const end = typeof inputEnd === 'number' ? inputEnd : loc.end;\n\n let next: Token | null = loc.startToken.next;\n let previousLine: number | undefined = 1;\n while (next) {\n if (next.start < start) {\n next = next.next;\n previousLine = next?.line;\n continue;\n }\n if (next.end > end) {\n next = next.next;\n previousLine = next?.line;\n continue;\n }\n let value = next.value || next.kind;\n let space = '';\n if (KindsToBeRemoved.indexOf(next.kind) >= 0) {\n value = '*';\n }\n if (next.kind === TokenKind.STRING) {\n value = `\"${value}\"`;\n }\n if (next.kind === TokenKind.EOF) {\n value = '';\n }\n if (next.line > previousLine!) {\n source += repeatBreak(next.line - previousLine!);\n previousLine = next.line;\n space = repeatSpace(next.column - 1);\n } else {\n if (next.line === next.prev?.line) {\n space = repeatSpace(next.start - (next.prev?.end || 0));\n }\n }\n source += space + value;\n if (next) {\n next = next.next!;\n }\n }\n }\n\n return source;\n}\n\nexport function wrapFields(\n type: Maybe<GraphQLObjectType & OtelPatched>,\n getConfig: () => GraphQLInstrumentationParsedConfig,\n): void {\n if (!type || (type as any)[OTEL_PATCHED_SYMBOL]) {\n return;\n }\n const fields = type.getFields();\n\n (type as any)[OTEL_PATCHED_SYMBOL] = true;\n\n Object.keys(fields).forEach(key => {\n const field = fields[key];\n\n if (!field) {\n return;\n }\n\n if (field.resolve) {\n // The shared structural types narrow the resolver context to `ObjectWithGraphQLData`; cast back\n // to the field's own resolver type (behavior is unchanged — this is a type-only adjustment).\n field.resolve = wrapFieldResolver(getConfig, field.resolve) as GraphQLFieldResolver;\n }\n\n if (field.type) {\n const unwrappedTypes = unwrapType(field.type);\n for (const unwrappedType of unwrappedTypes) {\n wrapFields(unwrappedType as any, getConfig);\n }\n }\n });\n}\n\nfunction unwrapType(type: GraphQLOutputType): readonly GraphQLObjectType[] {\n // unwrap wrapping types (non-nullable and list types)\n if ('ofType' in type) {\n // The structural index signature widens `ofType` to `unknown`, so narrow it back explicitly.\n return unwrapType(type.ofType as GraphQLOutputType);\n }\n\n // unwrap union types\n if (isGraphQLUnionType(type)) {\n return type.getTypes();\n }\n\n // return object types\n if (isGraphQLObjectType(type)) {\n return [type];\n }\n\n return [];\n}\n\nfunction isGraphQLUnionType(type: GraphQLType): type is GraphQLUnionType {\n return 'getTypes' in type && typeof type.getTypes === 'function';\n}\n\nfunction isGraphQLObjectType(type: GraphQLType): type is GraphQLObjectType {\n return 'getFields' in type && typeof type.getFields === 'function';\n}\n\nconst handleResolveSpanError = (resolveSpan: Span, err: any, shouldEndSpan: boolean) => {\n if (!shouldEndSpan) {\n return;\n }\n resolveSpan.setStatus({\n code: SPAN_STATUS_ERROR,\n message: err.message,\n });\n resolveSpan.end();\n};\n\nconst handleResolveSpanSuccess = (resolveSpan: Span, shouldEndSpan: boolean) => {\n if (!shouldEndSpan) {\n return;\n }\n resolveSpan.end();\n};\n\nexport function wrapFieldResolver<TSource = any, TContext = any, TArgs = any>(\n getConfig: () => GraphQLInstrumentationParsedConfig,\n fieldResolver: Maybe<GraphQLFieldResolver<TSource, TContext, TArgs> & OtelPatched>,\n isDefaultResolver = false,\n): GraphQLFieldResolver<TSource, TContext & ObjectWithGraphQLData, TArgs> & OtelPatched {\n if ((wrappedFieldResolver as OtelPatched)[OTEL_PATCHED_SYMBOL] || typeof fieldResolver !== 'function') {\n return fieldResolver!;\n }\n\n function wrappedFieldResolver(\n this: GraphQLFieldResolver<TSource, TContext, TArgs>,\n source: TSource,\n args: TArgs,\n contextValue: TContext & ObjectWithGraphQLData,\n info: GraphQLResolveInfo,\n ) {\n if (!fieldResolver) {\n return undefined;\n }\n const config = getConfig();\n\n // follows what graphql is doing to decide if this is a trivial resolver\n // for which we don't need to create a resolve span\n if (\n config.ignoreTrivialResolveSpans &&\n isDefaultResolver &&\n (isObjectLike(source) || typeof source === 'function')\n ) {\n const property = (source as any)[info.fieldName];\n // a function execution is not trivial and should be recorder.\n // property which is not a function is just a value and we don't want a \"resolve\" span for it\n if (typeof property !== 'function') {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n }\n\n if (!contextValue[OTEL_GRAPHQL_DATA_SYMBOL]) {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n const path = pathToArray(info?.path);\n\n const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path);\n const span = field.span;\n const shouldEndSpan = spanAdded;\n\n return withActiveSpan(span, () => {\n try {\n const res = fieldResolver.call(this, source, args, contextValue, info);\n if (isPromise(res)) {\n return res.then(\n (r: any) => {\n handleResolveSpanSuccess(span, shouldEndSpan);\n return r;\n },\n (err: Error) => {\n handleResolveSpanError(span, err, shouldEndSpan);\n throw err;\n },\n );\n } else {\n handleResolveSpanSuccess(span, shouldEndSpan);\n return res;\n }\n } catch (err: any) {\n handleResolveSpanError(span, err, shouldEndSpan);\n throw err;\n }\n });\n }\n\n (wrappedFieldResolver as OtelPatched)[OTEL_PATCHED_SYMBOL] = true;\n\n return wrappedFieldResolver;\n}\n"],"names":["AllowedOperationTypes","AttributeNames","startInactiveSpan","SpanNames","OTEL_GRAPHQL_DATA_SYMBOL","fieldNode","SPAN_STATUS_ERROR","TokenKind","OTEL_PATCHED_SYMBOL","isObjectLike","withActiveSpan"],"mappings":";;;;;;;AAgCA,MAAM,gBAAA,GAAmB,MA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,EACH;AAEA,EAAC,oBAAA,CAAqCF,2BAAmB,CAAA,GAAI,IAAA;AAE7D,EAAA,OAAO,oBAAA;AACT;;;;;;;;;;"} |
@@ -28,3 +28,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| function isCommandObj(value) { | ||
| return typeof value === "object" && value !== null && !isBuffer(value); | ||
| return core.isObjectLike(value) && !isBuffer(value); | ||
| } | ||
@@ -31,0 +31,0 @@ function isBuffer(value) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mongo/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongodb\n * - Upstream version: @opentelemetry/instrumentation-mongodb@0.71.0\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport {\n DB_NAME,\n DB_OPERATION,\n DB_STATEMENT,\n DB_SYSTEM,\n NET_PEER_NAME,\n NET_PEER_PORT,\n} from '@sentry/conventions/attributes';\nimport { ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION, DB_SYSTEM_VALUE_MONGODB } from './semconv';\nimport type { MongodbNamespace, MongoInternalCommand, MongoInternalTopology } from './internal-types';\nimport { MongodbCommandType } from './internal-types';\n\nconst ORIGIN = 'auto.db.otel.mongo';\n\n/**\n * Replaces values in the command object with '?', hiding PII and helping grouping.\n */\nfunction serializeDbStatement(commandObj: Record<string, unknown>): string {\n return JSON.stringify(scrubStatement(commandObj));\n}\n\nfunction scrubStatement(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(element => scrubStatement(element));\n }\n\n if (isCommandObj(value)) {\n const initial: Record<string, unknown> = {};\n return Object.entries(value)\n .map(([key, element]) => [key, scrubStatement(element)])\n .reduce((prev, current) => {\n if (isCommandEntry(current)) {\n prev[current[0]] = current[1];\n }\n return prev;\n }, initial);\n }\n\n // A value like string or number, possibly contains PII, scrub it\n return '?';\n}\n\nfunction isCommandObj(value: Record<string, unknown> | unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !isBuffer(value);\n}\n\nfunction isBuffer(value: unknown): boolean {\n return typeof Buffer !== 'undefined' && Buffer.isBuffer(value);\n}\n\nfunction isCommandEntry(value: [string, unknown] | unknown): value is [string, unknown] {\n return Array.isArray(value);\n}\n\n/**\n * Get the mongodb command type from the object.\n */\nexport function getCommandType(command: MongoInternalCommand): MongodbCommandType {\n if (command.createIndexes !== undefined) {\n return MongodbCommandType.CREATE_INDEXES;\n } else if (command.findandmodify !== undefined) {\n return MongodbCommandType.FIND_AND_MODIFY;\n } else if (command.ismaster !== undefined) {\n return MongodbCommandType.IS_MASTER;\n } else if (command.count !== undefined) {\n return MongodbCommandType.COUNT;\n } else if (command.aggregate !== undefined) {\n return MongodbCommandType.AGGREGATE;\n } else {\n return MongodbCommandType.UNKNOWN;\n }\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v4 connection context.\n */\nexport function getV4SpanAttributes(\n connectionCtx: any,\n ns: MongodbNamespace,\n command?: any,\n operation?: string,\n): SpanAttributes {\n let host, port: undefined | string;\n if (connectionCtx) {\n const hostParts = typeof connectionCtx.address === 'string' ? connectionCtx.address.split(':') : '';\n if (hostParts.length === 2) {\n host = hostParts[0];\n port = hostParts[1];\n }\n }\n let commandObj: Record<string, unknown>;\n if (command?.documents && command.documents[0]) {\n commandObj = command.documents[0];\n } else if (command?.cursors) {\n commandObj = command.cursors;\n } else {\n commandObj = command;\n }\n\n return getSpanAttributes(ns.db, ns.collection, host, port, commandObj, operation);\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v3 topology.\n */\nexport function getV3SpanAttributes(\n ns: string,\n topology: MongoInternalTopology,\n command?: MongoInternalCommand,\n operation?: string | undefined,\n): SpanAttributes {\n let host: undefined | string;\n let port: undefined | string;\n if (topology?.s) {\n host = topology.s.options?.host ?? topology.s.host;\n port = (topology.s.options?.port ?? topology.s.port)?.toString();\n if (host == null || port == null) {\n const address = topology.description?.address;\n if (address) {\n const addressSegments = address.split(':');\n host = addressSegments[0];\n port = addressSegments[1];\n }\n }\n }\n\n // The namespace is a combination of the database name and the name of the\n // collection or index, like so: [database-name].[collection-or-index-name].\n // It could be a string or an instance of MongoDBNamespace, as such we\n // always coerce to a string to extract db and collection.\n const [dbName, dbCollection] = ns.toString().split('.');\n const commandObj = command?.query ?? command?.q ?? command;\n\n return getSpanAttributes(dbName, dbCollection, host, port, commandObj, operation);\n}\n\nfunction getSpanAttributes(\n dbName?: string,\n dbCollection?: string,\n host?: undefined | string,\n port?: undefined | string,\n commandObj?: any,\n operation?: string | undefined,\n): SpanAttributes {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_NAME]: dbName,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_MONGODB_COLLECTION]: dbCollection,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_OPERATION]: operation,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,\n };\n\n if (host && port) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_NAME] = host;\n const portNumber = parseInt(port, 10);\n if (!isNaN(portNumber)) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_PORT] = portNumber;\n }\n }\n\n if (commandObj) {\n try {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[DB_STATEMENT] = serializeDbStatement(commandObj);\n } catch {\n // ignore serialization errors — the statement is best-effort metadata\n }\n }\n\n return attributes;\n}\n\nexport function startMongoSpan(attributes: SpanAttributes): Span {\n return startInactiveSpan({\n // eslint-disable-next-line typescript/no-deprecated\n name: `mongodb.${attributes[DB_OPERATION] || 'command'}`,\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n}\n\n/**\n * Wraps the result handler so it ends the span (with error status on failure) and runs the\n * original callback re-activated under the parent span — mongodb loses the async context when\n * it invokes the callback on a later tick.\n */\nexport function patchEnd(span: Span | undefined, resultHandler: Function): Function {\n const parentSpan = getActiveSpan();\n let spanEnded = false;\n\n return function patchedEnd(this: {}, ...args: unknown[]) {\n if (!spanEnded) {\n spanEnded = true;\n const error = args[0];\n if (span) {\n if (error instanceof Error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n }\n }\n\n return withActiveSpan(parentSpan ?? null, () => resultHandler.apply(this, args));\n };\n}\n\n// The instrumentation only creates spans when there is an active parent span, to avoid emitting\n// orphaned mongodb spans.\nexport function shouldSkipInstrumentation(): boolean {\n return !getActiveSpan();\n}\n"],"names":["MongodbCommandType","attributes","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","DB_SYSTEM","DB_SYSTEM_VALUE_MONGODB","DB_NAME","ATTR_DB_MONGODB_COLLECTION","DB_OPERATION","ATTR_DB_CONNECTION_STRING","NET_PEER_NAME","NET_PEER_PORT","DB_STATEMENT","startInactiveSpan","SPAN_KIND","getActiveSpan","SPAN_STATUS_ERROR","withActiveSpan"],"mappings":";;;;;;;AA+BA,MAAM,MAAA,GAAS,oBAAA;AAKf,SAAS,qBAAqB,UAAA,EAA6C;AACzE,EAAA,OAAO,IAAA,CAAK,SAAA,CAAU,cAAA,CAAe,UAAU,CAAC,CAAA;AAClD;AAEA,SAAS,eAAe,KAAA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KAAK,CAAC,CAAA;AACpB,MAAA,IAAI,IAAA,EAAM;AACR,QAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,UAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAMC,wBAAmB,OAAA,EAAS,KAAA,CAAM,SAAS,CAAA;AAAA,QACpE;AACA,QAAA,IAAA,CAAK,GAAA,EAAI;AAAA,MACX;AAAA,IACF;AAEA,IAAA,OAAOC,mBAAA,CAAe,cAAc,IAAA,EAAM,MAAM,cAAc,KAAA,CAAM,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,EACjF,CAAA;AACF;AAIO,SAAS,yBAAA,GAAqC;AACnD,EAAA,OAAO,CAACF,kBAAA,EAAc;AACxB;;;;;;;;;"} | ||
| {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mongo/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongodb\n * - Upstream version: @opentelemetry/instrumentation-mongodb@0.71.0\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n isObjectLike,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport {\n DB_NAME,\n DB_OPERATION,\n DB_STATEMENT,\n DB_SYSTEM,\n NET_PEER_NAME,\n NET_PEER_PORT,\n} from '@sentry/conventions/attributes';\nimport { ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION, DB_SYSTEM_VALUE_MONGODB } from './semconv';\nimport type { MongodbNamespace, MongoInternalCommand, MongoInternalTopology } from './internal-types';\nimport { MongodbCommandType } from './internal-types';\n\nconst ORIGIN = 'auto.db.otel.mongo';\n\n/**\n * Replaces values in the command object with '?', hiding PII and helping grouping.\n */\nfunction serializeDbStatement(commandObj: Record<string, unknown>): string {\n return JSON.stringify(scrubStatement(commandObj));\n}\n\nfunction scrubStatement(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(element => scrubStatement(element));\n }\n\n if (isCommandObj(value)) {\n const initial: Record<string, unknown> = {};\n return Object.entries(value)\n .map(([key, element]) => [key, scrubStatement(element)])\n .reduce((prev, current) => {\n if (isCommandEntry(current)) {\n prev[current[0]] = current[1];\n }\n return prev;\n }, initial);\n }\n\n // A value like string or number, possibly contains PII, scrub it\n return '?';\n}\n\nfunction isCommandObj(value: Record<string, unknown> | unknown): value is Record<string, unknown> {\n return isObjectLike(value) && !isBuffer(value);\n}\n\nfunction isBuffer(value: unknown): boolean {\n return typeof Buffer !== 'undefined' && Buffer.isBuffer(value);\n}\n\nfunction isCommandEntry(value: [string, unknown] | unknown): value is [string, unknown] {\n return Array.isArray(value);\n}\n\n/**\n * Get the mongodb command type from the object.\n */\nexport function getCommandType(command: MongoInternalCommand): MongodbCommandType {\n if (command.createIndexes !== undefined) {\n return MongodbCommandType.CREATE_INDEXES;\n } else if (command.findandmodify !== undefined) {\n return MongodbCommandType.FIND_AND_MODIFY;\n } else if (command.ismaster !== undefined) {\n return MongodbCommandType.IS_MASTER;\n } else if (command.count !== undefined) {\n return MongodbCommandType.COUNT;\n } else if (command.aggregate !== undefined) {\n return MongodbCommandType.AGGREGATE;\n } else {\n return MongodbCommandType.UNKNOWN;\n }\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v4 connection context.\n */\nexport function getV4SpanAttributes(\n connectionCtx: any,\n ns: MongodbNamespace,\n command?: any,\n operation?: string,\n): SpanAttributes {\n let host, port: undefined | string;\n if (connectionCtx) {\n const hostParts = typeof connectionCtx.address === 'string' ? connectionCtx.address.split(':') : '';\n if (hostParts.length === 2) {\n host = hostParts[0];\n port = hostParts[1];\n }\n }\n let commandObj: Record<string, unknown>;\n if (command?.documents && command.documents[0]) {\n commandObj = command.documents[0];\n } else if (command?.cursors) {\n commandObj = command.cursors;\n } else {\n commandObj = command;\n }\n\n return getSpanAttributes(ns.db, ns.collection, host, port, commandObj, operation);\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v3 topology.\n */\nexport function getV3SpanAttributes(\n ns: string,\n topology: MongoInternalTopology,\n command?: MongoInternalCommand,\n operation?: string | undefined,\n): SpanAttributes {\n let host: undefined | string;\n let port: undefined | string;\n if (topology?.s) {\n host = topology.s.options?.host ?? topology.s.host;\n port = (topology.s.options?.port ?? topology.s.port)?.toString();\n if (host == null || port == null) {\n const address = topology.description?.address;\n if (address) {\n const addressSegments = address.split(':');\n host = addressSegments[0];\n port = addressSegments[1];\n }\n }\n }\n\n // The namespace is a combination of the database name and the name of the\n // collection or index, like so: [database-name].[collection-or-index-name].\n // It could be a string or an instance of MongoDBNamespace, as such we\n // always coerce to a string to extract db and collection.\n const [dbName, dbCollection] = ns.toString().split('.');\n const commandObj = command?.query ?? command?.q ?? command;\n\n return getSpanAttributes(dbName, dbCollection, host, port, commandObj, operation);\n}\n\nfunction getSpanAttributes(\n dbName?: string,\n dbCollection?: string,\n host?: undefined | string,\n port?: undefined | string,\n commandObj?: any,\n operation?: string | undefined,\n): SpanAttributes {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_NAME]: dbName,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_MONGODB_COLLECTION]: dbCollection,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_OPERATION]: operation,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,\n };\n\n if (host && port) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_NAME] = host;\n const portNumber = parseInt(port, 10);\n if (!isNaN(portNumber)) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_PORT] = portNumber;\n }\n }\n\n if (commandObj) {\n try {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[DB_STATEMENT] = serializeDbStatement(commandObj);\n } catch {\n // ignore serialization errors — the statement is best-effort metadata\n }\n }\n\n return attributes;\n}\n\nexport function startMongoSpan(attributes: SpanAttributes): Span {\n return startInactiveSpan({\n // eslint-disable-next-line typescript/no-deprecated\n name: `mongodb.${attributes[DB_OPERATION] || 'command'}`,\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n}\n\n/**\n * Wraps the result handler so it ends the span (with error status on failure) and runs the\n * original callback re-activated under the parent span — mongodb loses the async context when\n * it invokes the callback on a later tick.\n */\nexport function patchEnd(span: Span | undefined, resultHandler: Function): Function {\n const parentSpan = getActiveSpan();\n let spanEnded = false;\n\n return function patchedEnd(this: {}, ...args: unknown[]) {\n if (!spanEnded) {\n spanEnded = true;\n const error = args[0];\n if (span) {\n if (error instanceof Error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n }\n }\n\n return withActiveSpan(parentSpan ?? null, () => resultHandler.apply(this, args));\n };\n}\n\n// The instrumentation only creates spans when there is an active parent span, to avoid emitting\n// orphaned mongodb spans.\nexport function shouldSkipInstrumentation(): boolean {\n return !getActiveSpan();\n}\n"],"names":["isObjectLike","MongodbCommandType","attributes","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","DB_SYSTEM","DB_SYSTEM_VALUE_MONGODB","DB_NAME","ATTR_DB_MONGODB_COLLECTION","DB_OPERATION","ATTR_DB_CONNECTION_STRING","NET_PEER_NAME","NET_PEER_PORT","DB_STATEMENT","startInactiveSpan","SPAN_KIND","getActiveSpan","SPAN_STATUS_ERROR","withActiveSpan"],"mappings":";;;;;;;AAgCA,MAAM,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hB,EAAA,OAAO,SAAS,cAAwB,IAAA,EAAiB;AACvD,IAAA,IAAI,CAAC,SAAA,EAAW;AACd,MAAA,SAAA,GAAY,IAAA;AACZ,MAAA,MAAM,KAAA,GAAQ,KAAK,CAAC,CAAA;AACpB,MAAA,IAAI,IAAA,EAAM;AACR,QAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,UAAA,IAAA,CAAK,UAAU,EAAE,IAAA,EAAMC,wBAAmB,OAAA,EAAS,KAAA,CAAM,SAAS,CAAA;AAAA,QACpE;AACA,QAAA,IAAA,CAAK,GAAA,EAAI;AAAA,MACX;AAAA,IACF;AAEA,IAAA,OAAOC,mBAAA,CAAe,cAAc,IAAA,EAAM,MAAM,cAAc,KAAA,CAAM,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,EACjF,CAAA;AACF;AAIO,SAAS,yBAAA,GAAqC;AACnD,EAAA,OAAO,CAACF,kBAAA,EAAc;AACxB;;;;;;;;;"} |
@@ -6,2 +6,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const nodeCore = require('@sentry/node-core'); | ||
| const serverUtils = require('@sentry/server-utils'); | ||
@@ -11,3 +12,3 @@ const INTEGRATION_NAME = "Mysql2"; | ||
| const _mysql2Integration = (() => { | ||
| return { | ||
| return core.extendIntegration(serverUtils.mysql2Integration(), { | ||
| name: INTEGRATION_NAME, | ||
@@ -17,3 +18,3 @@ setupOnce() { | ||
| } | ||
| }; | ||
| }); | ||
| }); | ||
@@ -20,0 +21,0 @@ const mysql2Integration = core.defineIntegration(_mysql2Integration); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/mysql2/index.ts"],"sourcesContent":["import { MySQL2Instrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Mysql2' as const;\n\nexport const instrumentMysql2 = generateInstrumentOnce(INTEGRATION_NAME, () => new MySQL2Instrumentation());\n\nconst _mysql2Integration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentMysql2();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.\n *\n * For more information, see the [`mysql2Integration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.mysqlIntegration()],\n * });\n * ```\n */\nexport const mysql2Integration = defineIntegration(_mysql2Integration);\n"],"names":["generateInstrumentOnce","MySQL2Instrumentation","defineIntegration"],"mappings":";;;;;;AAKA,MAAM,gBAAA,GAAmB,QAAA;AAElB,MAAM,mBAAmBA,+BAAA,CAAuB,gBAAA,EAAkB,MAAM,IAAIC,uCAAuB;AAE1G,MAAM,sBAAsB,MAAM;AAChC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,gBAAA,EAAiB;AAAA,IACnB;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,iBAAA,GAAoBC,uBAAkB,kBAAkB;;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/mysql2/index.ts"],"sourcesContent":["import { MySQL2Instrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, extendIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { mysql2Integration as mysql2ChannelIntegration } from '@sentry/server-utils';\n\nconst INTEGRATION_NAME = 'Mysql2' as const;\n\nexport const instrumentMysql2 = generateInstrumentOnce(INTEGRATION_NAME, () => new MySQL2Instrumentation());\n\nconst _mysql2Integration = (() => {\n // The diagnostics_channel subscription (mysql2 >= 3.20.0) lives in server-utils so it is shared\n // across server runtimes; we extend it here to also run the vendored OTel patcher for mysql2 < 3.20.0.\n return extendIntegration(mysql2ChannelIntegration(), {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentMysql2();\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.\n *\n * For more information, see the [`mysql2Integration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.mysqlIntegration()],\n * });\n * ```\n */\nexport const mysql2Integration = defineIntegration(_mysql2Integration);\n"],"names":["generateInstrumentOnce","MySQL2Instrumentation","extendIntegration","mysql2ChannelIntegration","defineIntegration"],"mappings":";;;;;;;AAMA,MAAM,gBAAA,GAAmB,QAAA;AAElB,MAAM,mBAAmBA,+BAAA,CAAuB,gBAAA,EAAkB,MAAM,IAAIC,uCAAuB;AAE1G,MAAM,sBAAsB,MAAM;AAGhC,EAAA,OAAOC,sBAAA,CAAkBC,+BAAyB,EAAG;AAAA,IACnD,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,gBAAA,EAAiB;AAAA,IACnB;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAgBO,MAAM,iBAAA,GAAoBC,uBAAkB,kBAAkB;;;;;"} |
@@ -12,3 +12,3 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| const ORIGIN = "auto.db.otel.mysql2"; | ||
| const supportedVersions = [">=1.4.2 <4"]; | ||
| const supportedVersions = [">=1.4.2 <3.20.0"]; | ||
| class MySQL2Instrumentation extends instrumentation.InstrumentationBase { | ||
@@ -15,0 +15,0 @@ constructor(config = {}) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/mysql2/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mysql2\n * - Upstream version: @opentelemetry/instrumentation-mysql2@0.64.0\n * - Types from 'mysql2' inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport { DB_STATEMENT, DB_SYSTEM } from '@sentry/conventions/attributes';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n} from '@sentry/core';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport type { Connection, FormatFunction, Query, QueryError, QueryOptions } from './mysql2-types';\nimport { DB_SYSTEM_VALUE_MYSQL } from './semconv';\nimport { getConnectionAttributes, getConnectionPrototypeToInstrument, getQueryText, getSpanName, once } from './utils';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-mysql2';\nconst ORIGIN = 'auto.db.otel.mysql2';\n\nconst supportedVersions = ['>=1.4.2 <4'];\n\n// The raw imported `mysql2` module exposes the `format` helper used to render\n// parameterized queries. Typed shallowly since it is only read internally.\ntype MySQL2Module = { format?: FormatFunction; [key: string]: unknown };\n\nexport class MySQL2Instrumentation extends InstrumentationBase<InstrumentationConfig> {\n public constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init(): InstrumentationNodeModuleDefinition[] {\n let format: FormatFunction | undefined;\n function setFormatFunction(moduleExports: MySQL2Module): void {\n if (!format && moduleExports.format) {\n format = moduleExports.format;\n }\n }\n const patch = (ConnectionPrototype: Connection): void => {\n if (isWrapped(ConnectionPrototype.query)) {\n this._unwrap(ConnectionPrototype, 'query');\n }\n this._wrap(ConnectionPrototype, 'query', this._patchQuery(format) as any);\n if (isWrapped(ConnectionPrototype.execute)) {\n this._unwrap(ConnectionPrototype, 'execute');\n }\n this._wrap(ConnectionPrototype, 'execute', this._patchQuery(format) as any);\n };\n const unpatch = (ConnectionPrototype: Connection): void => {\n this._unwrap(ConnectionPrototype, 'query');\n this._unwrap(ConnectionPrototype, 'execute');\n };\n return [\n new InstrumentationNodeModuleDefinition(\n 'mysql2',\n supportedVersions,\n (moduleExports: MySQL2Module) => {\n setFormatFunction(moduleExports);\n return moduleExports;\n },\n () => {},\n [\n new InstrumentationNodeModuleFile(\n 'mysql2/promise.js',\n supportedVersions,\n (moduleExports: MySQL2Module) => {\n setFormatFunction(moduleExports);\n return moduleExports;\n },\n () => {},\n ),\n new InstrumentationNodeModuleFile(\n 'mysql2/lib/connection.js',\n supportedVersions,\n (moduleExports: any) => {\n const ConnectionPrototype: Connection = getConnectionPrototypeToInstrument(moduleExports);\n patch(ConnectionPrototype);\n return moduleExports;\n },\n (moduleExports: any) => {\n if (moduleExports === undefined) return;\n const ConnectionPrototype: Connection = getConnectionPrototypeToInstrument(moduleExports);\n unpatch(ConnectionPrototype);\n },\n ),\n ],\n ),\n ];\n }\n\n private _patchQuery(format: FormatFunction | undefined) {\n const thisPlugin = this;\n return (originalQuery: Function): Function => {\n return function query(\n this: Connection,\n query: string | Query | QueryOptions,\n _valuesOrCallback?: unknown[] | Function,\n _callback?: Function,\n ) {\n let values;\n if (Array.isArray(_valuesOrCallback)) {\n values = _valuesOrCallback;\n } else if (arguments[2]) {\n values = [_valuesOrCallback];\n }\n\n const attributes: SpanAttributes = {\n ...getConnectionAttributes(this.config),\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MYSQL,\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_STATEMENT]: getQueryText(query, format, values),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n\n const span = startInactiveSpan({\n name: getSpanName(query),\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n\n const endSpan = once((err?: QueryError | null) => {\n if (err) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err.message });\n }\n span.end();\n });\n\n if (arguments.length === 1) {\n if (typeof (query as any).onResult === 'function') {\n thisPlugin._wrap(query as any, 'onResult', thisPlugin._patchCallbackQuery(endSpan));\n }\n\n const streamableQuery: Query = originalQuery.apply(this, arguments);\n\n streamableQuery\n .once('error', (err: any) => {\n endSpan(err);\n })\n .once('result', () => {\n endSpan();\n });\n\n return streamableQuery;\n }\n\n if (typeof arguments[1] === 'function') {\n thisPlugin._wrap(arguments, 1, thisPlugin._patchCallbackQuery(endSpan));\n } else if (typeof arguments[2] === 'function') {\n thisPlugin._wrap(arguments, 2, thisPlugin._patchCallbackQuery(endSpan));\n }\n\n return originalQuery.apply(this, arguments);\n };\n };\n }\n\n private _patchCallbackQuery(endSpan: (err?: QueryError | null) => void) {\n return (originalCallback: Function) => {\n return function (...args: [err: QueryError | null, ...rest: unknown[]]) {\n endSpan(args[0]);\n return originalCallback(...args);\n };\n };\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","isWrapped","InstrumentationNodeModuleDefinition","InstrumentationNodeModuleFile","getConnectionPrototypeToInstrument","attributes","getConnectionAttributes","DB_SYSTEM","DB_SYSTEM_VALUE_MYSQL","DB_STATEMENT","getQueryText","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","startInactiveSpan","getSpanName","SPAN_KIND","once","SPAN_STATUS_ERROR"],"mappings":";;;;;;;;;AA4BA,MAAM,YAAA,GAAe,gCAAA;AACrB,MAAM,MAAA,GAAS,qBAAA;AAEf,MAAM,iBAAA,GAAoB,CAAC,YAAY,CAAA;AAMhC,MAAM,8BAA8BA,mCAAA,CAA2C;AAAA,EAC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BAAA,CAAoB,OAAO,CAAC,CAAA;AAAA,QACxE,CAAA,MAAA,IAAW,OAAO,SAAA,CAAU,CAAC,MAAM,UAAA,EAAY;AAC7C,UAAA,UAAA,CAAW,MAAM,SAAA,EAAW,CAAA,EAAG,UAAA,CAAW,mBAAA,CAAoB,OAAO,CAAC,CAAA;AAAA,QACxE;AAEA,QAAA,OAAO,aAAA,CAAc,KAAA,CAAM,IAAA,EAAM,SAAS,CAAA;AAAA,MAC5C,CAAA;AAAA,IACF,CAAA;AAAA,EACF;AAAA,EAEQ,oBAAoB,OAAA,EAA4C;AACtE,IAAA,OAAO,CAAC,gBAAA,KAA+B;AACrC,MAAA,OAAO,YAAa,IAAA,EAAoD;AACtE,QAAA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,gBAAA,CAAiB,GAAG,IAAI,CAAA;AAAA,MACjC,CAAA;AAAA,IACF,CAAA;AAAA,EACF;AACF;;;;"} | ||
| {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/mysql2/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mysql2\n * - Upstream version: @opentelemetry/instrumentation-mysql2@0.64.0\n * - Types from 'mysql2' inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport { DB_STATEMENT, DB_SYSTEM } from '@sentry/conventions/attributes';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n} from '@sentry/core';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport type { Connection, FormatFunction, Query, QueryError, QueryOptions } from './mysql2-types';\nimport { DB_SYSTEM_VALUE_MYSQL } from './semconv';\nimport { getConnectionAttributes, getConnectionPrototypeToInstrument, getQueryText, getSpanName, once } from './utils';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-mysql2';\nconst ORIGIN = 'auto.db.otel.mysql2';\n\n// mysql2 >= 3.20.0 publishes via diagnostics_channel and is instrumented by\n// `subscribeMysql2DiagnosticChannels` instead, so this IITM patcher must not\n// overlap it — otherwise every query would emit two mysql2 spans.\nconst supportedVersions = ['>=1.4.2 <3.20.0'];\n\n// The raw imported `mysql2` module exposes the `format` helper used to render\n// parameterized queries. Typed shallowly since it is only read internally.\ntype MySQL2Module = { format?: FormatFunction; [key: string]: unknown };\n\nexport class MySQL2Instrumentation extends InstrumentationBase<InstrumentationConfig> {\n public constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init(): InstrumentationNodeModuleDefinition[] {\n let format: FormatFunction | undefined;\n function setFormatFunction(moduleExports: MySQL2Module): void {\n if (!format && moduleExports.format) {\n format = moduleExports.format;\n }\n }\n const patch = (ConnectionPrototype: Connection): void => {\n if (isWrapped(ConnectionPrototype.query)) {\n this._unwrap(ConnectionPrototype, 'query');\n }\n this._wrap(ConnectionPrototype, 'query', this._patchQuery(format) as any);\n if (isWrapped(ConnectionPrototype.execute)) {\n this._unwrap(ConnectionPrototype, 'execute');\n }\n this._wrap(ConnectionPrototype, 'execute', this._patchQuery(format) as any);\n };\n const unpatch = (ConnectionPrototype: Connection): void => {\n this._unwrap(ConnectionPrototype, 'query');\n this._unwrap(ConnectionPrototype, 'execute');\n };\n return [\n new InstrumentationNodeModuleDefinition(\n 'mysql2',\n supportedVersions,\n (moduleExports: MySQL2Module) => {\n setFormatFunction(moduleExports);\n return moduleExports;\n },\n () => {},\n [\n new InstrumentationNodeModuleFile(\n 'mysql2/promise.js',\n supportedVersions,\n (moduleExports: MySQL2Module) => {\n setFormatFunction(moduleExports);\n return moduleExports;\n },\n () => {},\n ),\n new InstrumentationNodeModuleFile(\n 'mysql2/lib/connection.js',\n supportedVersions,\n (moduleExports: any) => {\n const ConnectionPrototype: Connection = getConnectionPrototypeToInstrument(moduleExports);\n patch(ConnectionPrototype);\n return moduleExports;\n },\n (moduleExports: any) => {\n if (moduleExports === undefined) return;\n const ConnectionPrototype: Connection = getConnectionPrototypeToInstrument(moduleExports);\n unpatch(ConnectionPrototype);\n },\n ),\n ],\n ),\n ];\n }\n\n private _patchQuery(format: FormatFunction | undefined) {\n const thisPlugin = this;\n return (originalQuery: Function): Function => {\n return function query(\n this: Connection,\n query: string | Query | QueryOptions,\n _valuesOrCallback?: unknown[] | Function,\n _callback?: Function,\n ) {\n let values;\n if (Array.isArray(_valuesOrCallback)) {\n values = _valuesOrCallback;\n } else if (arguments[2]) {\n values = [_valuesOrCallback];\n }\n\n const attributes: SpanAttributes = {\n ...getConnectionAttributes(this.config),\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MYSQL,\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_STATEMENT]: getQueryText(query, format, values),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n\n const span = startInactiveSpan({\n name: getSpanName(query),\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n\n const endSpan = once((err?: QueryError | null) => {\n if (err) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err.message });\n }\n span.end();\n });\n\n if (arguments.length === 1) {\n if (typeof (query as any).onResult === 'function') {\n thisPlugin._wrap(query as any, 'onResult', thisPlugin._patchCallbackQuery(endSpan));\n }\n\n const streamableQuery: Query = originalQuery.apply(this, arguments);\n\n streamableQuery\n .once('error', (err: any) => {\n endSpan(err);\n })\n .once('result', () => {\n endSpan();\n });\n\n return streamableQuery;\n }\n\n if (typeof arguments[1] === 'function') {\n thisPlugin._wrap(arguments, 1, thisPlugin._patchCallbackQuery(endSpan));\n } else if (typeof arguments[2] === 'function') {\n thisPlugin._wrap(arguments, 2, thisPlugin._patchCallbackQuery(endSpan));\n }\n\n return originalQuery.apply(this, arguments);\n };\n };\n }\n\n private _patchCallbackQuery(endSpan: (err?: QueryError | null) => void) {\n return (originalCallback: Function) => {\n return function (...args: [err: QueryError | null, ...rest: unknown[]]) {\n endSpan(args[0]);\n return originalCallback(...args);\n };\n };\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","isWrapped","InstrumentationNodeModuleDefinition","InstrumentationNodeModuleFile","getConnectionPrototypeToInstrument","attributes","getConnectionAttributes","DB_SYSTEM","DB_SYSTEM_VALUE_MYSQL","DB_STATEMENT","getQueryText","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","startInactiveSpan","getSpanName","SPAN_KIND","once","SPAN_STATUS_ERROR"],"mappings":";;;;;;;;;AA4BA,MAAM,YAAA,GAAe,gCAAA;AACrB,MAAM,MAAA,GAAS,qBAAA;AAKf,MAAM,iBAAA,GAAoB,CAAC,iBAAiB,CAAA;AAMrC,MAAM,8BAA8BA,mCAAA,CAA2C;AAAA,EAC7E,WAAA,CAAY,MAAA,GAAgC,EAAC,EAAG;AACrD,IAAA,KAAA,CAAM,YAAA,EAAcC,kBAAa,MAAM,CAAA;AAAA,EACzC;AAAA,EAEU,IAAA,GAA8C;AACtD,IAAA,IAAI,MAAA;AACJ,IAAA,SAAS,kBAAkB,aAAA,EAAmC;AAC5D,MAAA,IAAI,CAAC,MAAA,IAAU,aAAA,CAAc,MAAA,EAAQ;AACnC,QAAA,MAAA,GAAS,aAAA,CAAc,MAAA;AAAA,MACzB;AAAA,IACF;AACA,IAAA,MAAM,KAAA,GAAQ,CAAC,mBAAA,KAA0C;AACvD,MAAA,IAAIC,yBAA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;AACrC,MAAA,OAAO,YAAa,IAAA,EAAoD;AACtE,QAAA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,gBAAA,CAAiB,GAAG,IAAI,CAAA;AAAA,MACjC,CAAA;AAAA,IACF,CAAA;AAAA,EACF;AACF;;;;"} |
@@ -27,9 +27,4 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| instrumentIORedis(); | ||
| instrumentRedisModule(); | ||
| } | ||
| instrumentRedisModule(); | ||
| if (dc.tracingChannel) { | ||
| core.waitForTracingChannelBinding(() => { | ||
| serverUtils.subscribeRedisDiagnosticChannels(dc.tracingChannel, cache.cacheResponseHook); | ||
| }); | ||
| } | ||
| }, | ||
@@ -39,3 +34,3 @@ { id: INTEGRATION_NAME } | ||
| const _redisIntegration = ((options = {}) => { | ||
| return { | ||
| return core.extendIntegration(serverUtils.redisIntegration({ responseHook: cache.cacheResponseHook }), { | ||
| name: INTEGRATION_NAME, | ||
@@ -46,3 +41,3 @@ setupOnce() { | ||
| } | ||
| }; | ||
| }); | ||
| }); | ||
@@ -49,0 +44,0 @@ const redisIntegration = core.defineIntegration(_redisIntegration); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/redis/index.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, waitForTracingChannelBinding } from '@sentry/core';\nimport * as dc from 'node:diagnostics_channel';\nimport { subscribeRedisDiagnosticChannels, type RedisTracingChannelFactory } from '@sentry/server-utils';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { isDiagnosticsChannelInjectionEnabled } from '../../../sdk/diagnosticsChannelInjection';\nimport { cacheResponseHook, type RedisOptions, setRedisOptions } from './cache';\nimport { IORedisInstrumentation } from './vendored/ioredis-instrumentation';\nimport { RedisInstrumentation } from './vendored/redis-instrumentation';\n\n// `cacheResponseHook`/`_redisOptions` live in `./cache` (which has no OTel\n// instrumentation imports) so the orchestrion opt-in can pull the hook without\n// dragging the OTel redis instrumentation in. Re-exported here for tests.\nexport { _redisOptions, cacheResponseHook } from './cache';\n\nconst INTEGRATION_NAME = 'Redis' as const;\n\nconst instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME}.IORedis`, () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME}.Redis`, () => {\n return new RedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\n/**\n * To be able to preload all Redis OTel instrumentations with just one ID\n * (\"Redis\"), all the instrumentations are generated in this one function\n */\nexport const instrumentRedis = Object.assign(\n (): void => {\n // When diagnostics-channel injection is opted in, orchestrion owns ioredis\n // `<5.11.0`, so skip the OTel ioredis monkey-patch to avoid double instrumentation.\n // On Node without `tracingChannel` (<18.19) orchestrion can't run, so keep the\n // OTel patch there — otherwise ioredis `<5.11.0` would not be traced at all.\n if (!isDiagnosticsChannelInjectionEnabled() || !dc.tracingChannel) {\n instrumentIORedis();\n }\n instrumentRedisModule();\n // node-redis >= 5.12.0 and ioredis >= 5.11.0 publish via diagnostics_channel.\n // `bindTracingChannelToSpan` (inside the subscriber) makes the span the active\n // OTel context via `bindStore`, which needs the Sentry OTel context manager to\n // be registered — `initOpenTelemetry()` does that after integration `setupOnce`,\n // so defer to the next tick.\n // Check this here to ensure this does not fail at runtime for Node <= 18.18.0\n if (dc.tracingChannel) {\n waitForTracingChannelBinding(() => {\n subscribeRedisDiagnosticChannels(dc.tracingChannel as RedisTracingChannelFactory, cacheResponseHook);\n });\n }\n\n // todo: implement them gradually\n // new LegacyRedisInstrumentation({}),\n },\n { id: INTEGRATION_NAME },\n);\n\nconst _redisIntegration = ((options: RedisOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n setRedisOptions(options);\n instrumentRedis();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries.\n *\n * For more information, see the [`redisIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.redisIntegration()],\n * });\n * ```\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":["generateInstrumentOnce","IORedisInstrumentation","cacheResponseHook","RedisInstrumentation","isDiagnosticsChannelInjectionEnabled","waitForTracingChannelBinding","subscribeRedisDiagnosticChannels","setRedisOptions","defineIntegration"],"mappings":";;;;;;;;;;;AAeA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,iBAAA,GAAoBA,+BAAA,CAAuB,CAAA,EAAG,gBAAgB,YAAY,MAAM;AACpF,EAAA,OAAO,IAAIC,6CAAA,CAAuB;AAAA,IAChC,YAAA,EAAcC;AAAA,GACf,CAAA;AACH,CAAC,CAAA;AAED,MAAM,qBAAA,GAAwBF,+BAAA,CAAuB,CAAA,EAAG,gBAAgB,UAAU,MAAM;AACtF,EAAA,OAAO,IAAIG,yCAAA,CAAqB;AAAA,IAC9B,YAAA,EAAcD;AAAA,GACf,CAAA;AACH,CAAC,CAAA;AAMM,MAAM,kBAAkB,MAAA,CAAO,MAAA;AAAA,EACpC,MAAY;AAKV,IAAA,IAAI,CAACE,gEAAA,EAAqC,IAAK,CAAC,GAAG,cAAA,EAAgB;AACjE,MAAA,iBAAA,EAAkB;AAAA,IACpB;AACA,IAAA,qBAAA,EAAsB;AAOtB,IAAA,IAAI,GAAG,cAAA,EAAgB;AACrB,MAAAC,iCAAA,CAA6B,MAAM;AACjC,QAAAC,4CAAA,CAAiC,EAAA,CAAG,gBAA8CJ,uBAAiB,CAAA;AAAA,MACrG,CAAC,CAAA;AAAA,IACH;AAAA,EAIF,CAAA;AAAA,EACA,EAAE,IAAI,gBAAA;AACR;AAEA,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAAwB,EAAC,KAAM;AACzD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAAK,qBAAA,CAAgB,OAAO,CAAA;AACvB,MAAA,eAAA,EAAgB;AAAA,IAClB;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,gBAAA,GAAmBC,uBAAkB,iBAAiB;;;;;;;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/redis/index.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, extendIntegration } from '@sentry/core';\nimport * as dc from 'node:diagnostics_channel';\nimport { redisIntegration as redisChannelIntegration } from '@sentry/server-utils';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { isDiagnosticsChannelInjectionEnabled } from '../../../sdk/diagnosticsChannelInjection';\nimport { cacheResponseHook, type RedisOptions, setRedisOptions } from './cache';\nimport { IORedisInstrumentation } from './vendored/ioredis-instrumentation';\nimport { RedisInstrumentation } from './vendored/redis-instrumentation';\n\n// `cacheResponseHook`/`_redisOptions` live in `./cache` (which has no OTel\n// instrumentation imports) so the orchestrion opt-in can pull the hook without\n// dragging the OTel redis instrumentation in. Re-exported here for tests.\nexport { _redisOptions, cacheResponseHook } from './cache';\n\nconst INTEGRATION_NAME = 'Redis' as const;\n\nconst instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME}.IORedis`, () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME}.Redis`, () => {\n return new RedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\n/**\n * To be able to preload all Redis OTel instrumentations with just one ID\n * (\"Redis\"), all the instrumentations are generated in this one function\n */\nexport const instrumentRedis = Object.assign(\n (): void => {\n // When diagnostics-channel injection is opted in, orchestrion fully owns the older\n // ioredis (`<5.11.0`) and redis/node-redis (`<5.12.0`) ranges — commands, connect, and\n // batches — so skip both OTel monkey-patches to avoid double instrumentation. On Node\n // without `tracingChannel` (<18.19) orchestrion can't run, so keep the OTel patches there.\n if (!isDiagnosticsChannelInjectionEnabled() || !dc.tracingChannel) {\n instrumentIORedis();\n instrumentRedisModule();\n }\n\n // todo: implement them gradually\n // new LegacyRedisInstrumentation({}),\n },\n { id: INTEGRATION_NAME },\n);\n\nconst _redisIntegration = ((options: RedisOptions = {}) => {\n // The diagnostics_channel subscription (node-redis >= 5.12.0, ioredis >= 5.11.0) lives in\n // server-utils so it is shared across server runtimes; we extend it here to also run the vendored\n // OTel patchers for older client versions. `cacheResponseHook` reads options set in the extension's\n // `setupOnce` below, but it only runs at command time, by which point those options are set.\n return extendIntegration(redisChannelIntegration({ responseHook: cacheResponseHook }), {\n name: INTEGRATION_NAME,\n setupOnce() {\n setRedisOptions(options);\n instrumentRedis();\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries.\n *\n * For more information, see the [`redisIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.redisIntegration()],\n * });\n * ```\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":["generateInstrumentOnce","IORedisInstrumentation","cacheResponseHook","RedisInstrumentation","isDiagnosticsChannelInjectionEnabled","extendIntegration","redisChannelIntegration","setRedisOptions","defineIntegration"],"mappings":";;;;;;;;;;;AAeA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,iBAAA,GAAoBA,+BAAA,CAAuB,CAAA,EAAG,gBAAgB,YAAY,MAAM;AACpF,EAAA,OAAO,IAAIC,6CAAA,CAAuB;AAAA,IAChC,YAAA,EAAcC;AAAA,GACf,CAAA;AACH,CAAC,CAAA;AAED,MAAM,qBAAA,GAAwBF,+BAAA,CAAuB,CAAA,EAAG,gBAAgB,UAAU,MAAM;AACtF,EAAA,OAAO,IAAIG,yCAAA,CAAqB;AAAA,IAC9B,YAAA,EAAcD;AAAA,GACf,CAAA;AACH,CAAC,CAAA;AAMM,MAAM,kBAAkB,MAAA,CAAO,MAAA;AAAA,EACpC,MAAY;AAKV,IAAA,IAAI,CAACE,gEAAA,EAAqC,IAAK,CAAC,GAAG,cAAA,EAAgB;AACjE,MAAA,iBAAA,EAAkB;AAClB,MAAA,qBAAA,EAAsB;AAAA,IACxB;AAAA,EAIF,CAAA;AAAA,EACA,EAAE,IAAI,gBAAA;AACR;AAEA,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAAwB,EAAC,KAAM;AAKzD,EAAA,OAAOC,uBAAkBC,4BAAA,CAAwB,EAAE,YAAA,EAAcJ,uBAAA,EAAmB,CAAA,EAAG;AAAA,IACrF,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAAK,qBAAA,CAAgB,OAAO,CAAA;AACvB,MAAA,eAAA,EAAgB;AAAA,IAClB;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAiBO,MAAM,gBAAA,GAAmBC,uBAAkB,iBAAiB;;;;;;;;;;"} |
@@ -16,8 +16,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
| return { | ||
| // ioredis is wired here rather than in the shared `channelIntegrations` registry: it needs | ||
| // the node redis cache `responseHook`, and it only partially replaces the composite OTel | ||
| // `Redis` integration (which also covers node-redis and ioredis >=5.11 native diagnostics_channel). | ||
| // So it's added to the integration set but kept OUT of `replacedOtelIntegrationNames` — `Redis` | ||
| // must stay; its ioredis <5.11 monkey-patch is gated off in `redisIntegration` instead. | ||
| integrations: [...integrations, orchestrion.ioredisChannelIntegration({ responseHook: cache.cacheResponseHook })], | ||
| // ioredis and redis are wired separately (not in `channelIntegrations`): they need the node | ||
| // redis cache `responseHook` and only partially replace the composite OTel `Redis` integration, | ||
| // so they're kept OUT of `replacedOtelIntegrationNames` — `Redis` must stay (batch + >=5.11 native DC). | ||
| integrations: [ | ||
| ...integrations, | ||
| orchestrion.ioredisChannelIntegration({ responseHook: cache.cacheResponseHook }), | ||
| orchestrion.redisChannelIntegration({ responseHook: cache.cacheResponseHook }) | ||
| ], | ||
| replacedOtelIntegrationNames, | ||
@@ -24,0 +26,0 @@ register: register.registerDiagnosticsChannelInjection, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"experimentalUseDiagnosticsChannelInjection.js","sources":["../../../src/sdk/experimentalUseDiagnosticsChannelInjection.ts"],"sourcesContent":["import {\n channelIntegrations,\n ioredisChannelIntegration,\n detectOrchestrionSetup,\n} from '@sentry/server-utils/orchestrion';\nimport { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';\nimport { cacheResponseHook } from '../integrations/tracing/redis/cache';\nimport type { DiagnosticsChannelInjection } from './diagnosticsChannelInjection';\nimport { setDiagnosticsChannelInjectionLoader } from './diagnosticsChannelInjection';\n\nexport function diagnosticsChannelInjectionIntegrations(): typeof channelIntegrations {\n return channelIntegrations;\n}\n\n/**\n * EXPERIMENTAL: opt into diagnostics-channel-based auto-instrumentation.\n *\n * Call this BEFORE `Sentry.init()`:\n *\n * ```ts\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.experimentalUseDiagnosticsChannelInjection();\n * Sentry.init({\n * dsn: '__DSN__',\n * // other settings...\n * });\n * ```\n *\n * When this has been called AND span recording is enabled, `Sentry.init()`\n * uses the diagnostics-channel-injection-based integrations instead of the\n * OpenTelemetry ones, and installs the module hooks that inject the channels\n * (so libraries imported after `init()` publish the channel events).\n *\n * This is a standalone function rather than an `init()` option so that a\n * bundler drops all of it (and its transitive deps) when this function isn't\n * called. `init()` reads the loader registered below.\n *\n * An app that DOES call it gets the orchestrion code bundled as intended.\n *\n * In an unbundled (server-side runtime) app this eagerly loads only the small\n * subscriber/channel modules; the heavy code-transform dependencies stay lazy\n * inside `register()` and load only when injection actually runs.\n *\n * @experimental May change or be removed in any release.\n */\nexport function experimentalUseDiagnosticsChannelInjection(): void {\n setDiagnosticsChannelInjectionLoader((): DiagnosticsChannelInjection => {\n // The registry integrations 1:1 replace the OTel integration of the same name.\n const integrations = Object.values(channelIntegrations).map(createIntegration => createIntegration());\n const replacedOtelIntegrationNames = integrations.map(i => i.name);\n\n return {\n // ioredis is wired here rather than in the shared `channelIntegrations` registry: it needs\n // the node redis cache `responseHook`, and it only partially replaces the composite OTel\n // `Redis` integration (which also covers node-redis and ioredis >=5.11 native diagnostics_channel).\n // So it's added to the integration set but kept OUT of `replacedOtelIntegrationNames` — `Redis`\n // must stay; its ioredis <5.11 monkey-patch is gated off in `redisIntegration` instead.\n integrations: [...integrations, ioredisChannelIntegration({ responseHook: cacheResponseHook })],\n replacedOtelIntegrationNames,\n register: registerDiagnosticsChannelInjection,\n detect: detectOrchestrionSetup,\n };\n });\n}\n"],"names":["channelIntegrations","setDiagnosticsChannelInjectionLoader","ioredisChannelIntegration","cacheResponseHook","registerDiagnosticsChannelInjection","detectOrchestrionSetup"],"mappings":";;;;;;;AAUO,SAAS,uCAAA,GAAsE;AACpF,EAAA,OAAOA,+BAAA;AACT;AAkCO,SAAS,0CAAA,GAAmD;AACjE,EAAAC,gEAAA,CAAqC,MAAmC;AAEtE,IAAA,MAAM,YAAA,GAAe,OAAO,MAAA,CAAOD,+BAAmB,EAAE,GAAA,CAAI,CAAA,iBAAA,KAAqB,mBAAmB,CAAA;AACpG,IAAA,MAAM,4BAAA,GAA+B,YAAA,CAAa,GAAA,CAAI,CAAA,CAAA,KAAK,EAAE,IAAI,CAAA;AAEjE,IAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAML,YAAA,EAAc,CAAC,GAAG,YAAA,EAAcE,sCAA0B,EAAE,YAAA,EAAcC,uBAAA,EAAmB,CAAC,CAAA;AAAA,MAC9F,4BAAA;AAAA,MACA,QAAA,EAAUC,4CAAA;AAAA,MACV,MAAA,EAAQC;AAAA,KACV;AAAA,EACF,CAAC,CAAA;AACH;;;;;"} | ||
| {"version":3,"file":"experimentalUseDiagnosticsChannelInjection.js","sources":["../../../src/sdk/experimentalUseDiagnosticsChannelInjection.ts"],"sourcesContent":["import {\n channelIntegrations,\n ioredisChannelIntegration,\n redisChannelIntegration,\n detectOrchestrionSetup,\n} from '@sentry/server-utils/orchestrion';\nimport { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';\nimport { cacheResponseHook } from '../integrations/tracing/redis/cache';\nimport type { DiagnosticsChannelInjection } from './diagnosticsChannelInjection';\nimport { setDiagnosticsChannelInjectionLoader } from './diagnosticsChannelInjection';\n\nexport function diagnosticsChannelInjectionIntegrations(): typeof channelIntegrations {\n return channelIntegrations;\n}\n\n/**\n * EXPERIMENTAL: opt into diagnostics-channel-based auto-instrumentation.\n *\n * Call this BEFORE `Sentry.init()`:\n *\n * ```ts\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.experimentalUseDiagnosticsChannelInjection();\n * Sentry.init({\n * dsn: '__DSN__',\n * // other settings...\n * });\n * ```\n *\n * When this has been called AND span recording is enabled, `Sentry.init()`\n * uses the diagnostics-channel-injection-based integrations instead of the\n * OpenTelemetry ones, and installs the module hooks that inject the channels\n * (so libraries imported after `init()` publish the channel events).\n *\n * This is a standalone function rather than an `init()` option so that a\n * bundler drops all of it (and its transitive deps) when this function isn't\n * called. `init()` reads the loader registered below.\n *\n * An app that DOES call it gets the orchestrion code bundled as intended.\n *\n * In an unbundled (server-side runtime) app this eagerly loads only the small\n * subscriber/channel modules; the heavy code-transform dependencies stay lazy\n * inside `register()` and load only when injection actually runs.\n *\n * @experimental May change or be removed in any release.\n */\nexport function experimentalUseDiagnosticsChannelInjection(): void {\n setDiagnosticsChannelInjectionLoader((): DiagnosticsChannelInjection => {\n // The registry integrations 1:1 replace the OTel integration of the same name.\n const integrations = Object.values(channelIntegrations).map(createIntegration => createIntegration());\n const replacedOtelIntegrationNames = integrations.map(i => i.name);\n\n return {\n // ioredis and redis are wired separately (not in `channelIntegrations`): they need the node\n // redis cache `responseHook` and only partially replace the composite OTel `Redis` integration,\n // so they're kept OUT of `replacedOtelIntegrationNames` — `Redis` must stay (batch + >=5.11 native DC).\n integrations: [\n ...integrations,\n ioredisChannelIntegration({ responseHook: cacheResponseHook }),\n redisChannelIntegration({ responseHook: cacheResponseHook }),\n ],\n replacedOtelIntegrationNames,\n register: registerDiagnosticsChannelInjection,\n detect: detectOrchestrionSetup,\n };\n });\n}\n"],"names":["channelIntegrations","setDiagnosticsChannelInjectionLoader","ioredisChannelIntegration","cacheResponseHook","redisChannelIntegration","registerDiagnosticsChannelInjection","detectOrchestrionSetup"],"mappings":";;;;;;;AAWO,SAAS,uCAAA,GAAsE;AACpF,EAAA,OAAOA,+BAAA;AACT;AAkCO,SAAS,0CAAA,GAAmD;AACjE,EAAAC,gEAAA,CAAqC,MAAmC;AAEtE,IAAA,MAAM,YAAA,GAAe,OAAO,MAAA,CAAOD,+BAAmB,EAAE,GAAA,CAAI,CAAA,iBAAA,KAAqB,mBAAmB,CAAA;AACpG,IAAA,MAAM,4BAAA,GAA+B,YAAA,CAAa,GAAA,CAAI,CAAA,CAAA,KAAK,EAAE,IAAI,CAAA;AAEjE,IAAA,OAAO;AAAA;AAAA;AAAA;AAAA,MAIL,YAAA,EAAc;AAAA,QACZ,GAAG,YAAA;AAAA,QACHE,qCAAA,CAA0B,EAAE,YAAA,EAAcC,uBAAA,EAAmB,CAAA;AAAA,QAC7DC,mCAAA,CAAwB,EAAE,YAAA,EAAcD,uBAAA,EAAmB;AAAA,OAC7D;AAAA,MACA,4BAAA;AAAA,MACA,QAAA,EAAUE,4CAAA;AAAA,MACV,MAAA,EAAQC;AAAA,KACV;AAAA,EACF,CAAC,CAAA;AACH;;;;;"} |
| import { defineIntegration, hasSpansEnabled, getRequestUrlFromClientRequest, stripDataUrlContent, SEMANTIC_ATTRIBUTE_URL_FULL } from '@sentry/core'; | ||
| import { generateInstrumentOnce, SentryHttpInstrumentation, httpServerIntegration, httpServerSpansIntegration } from '@sentry/node-core'; | ||
| import { instrumentHttpOutgoingRequests, httpServerIntegration, httpServerSpansIntegration } from '@sentry/node-core'; | ||
| const INTEGRATION_NAME = "Http"; | ||
| const instrumentSentryHttp = generateInstrumentOnce( | ||
| `${INTEGRATION_NAME}.sentry`, | ||
| (options) => { | ||
| return new SentryHttpInstrumentation(options); | ||
| } | ||
| ); | ||
| const instrumentSentryHttp = Object.assign(instrumentHttpOutgoingRequests, { | ||
| id: `${INTEGRATION_NAME}.sentry` | ||
| }); | ||
| const httpIntegration = defineIntegration((options = {}) => { | ||
@@ -59,3 +56,3 @@ const spans = options.spans ?? true; | ||
| }; | ||
| instrumentSentryHttp(sentryHttpInstrumentationOptions); | ||
| instrumentHttpOutgoingRequests(sentryHttpInstrumentationOptions); | ||
| }, | ||
@@ -62,0 +59,0 @@ processEvent(event) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"http.js","sources":["../../../src/integrations/http.ts"],"sourcesContent":["import type { RequestOptions } from 'node:http';\nimport type { HttpClientRequest, HttpIncomingMessage, HttpServerResponse, Span } from '@sentry/core';\nimport {\n defineIntegration,\n hasSpansEnabled,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n stripDataUrlContent,\n getRequestUrlFromClientRequest,\n} from '@sentry/core';\nimport type {\n NodeClient,\n SentryHttpInstrumentationOptions,\n HttpServerIntegrationOptions,\n HttpServerSpansIntegrationOptions,\n} from '@sentry/node-core';\nimport {\n generateInstrumentOnce,\n httpServerIntegration,\n httpServerSpansIntegration,\n SentryHttpInstrumentation,\n} from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Http' as const;\n\n// TODO(v11): Consolidate all the various HTTP integration options into one,\n// and deprecate the duplicated and aliased options.\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 * Whether to inject trace propagation headers (sentry-trace, baggage, traceparent) into outgoing HTTP requests.\n *\n * When set to `false`, Sentry will not inject any trace propagation headers, but will still create breadcrumbs\n * (if `breadcrumbs` is enabled). This is useful when `skipOpenTelemetrySetup: true` is configured and you want\n * to avoid duplicate trace headers being injected by both Sentry and OpenTelemetry's HttpInstrumentation.\n *\n * @default `true`\n */\n tracePropagation?: boolean;\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: HttpIncomingMessage) => boolean;\n\n /**\n * A hook that can be used to mutate the span for incoming requests.\n * This is triggered after the span is created, but before it is recorded.\n */\n incomingRequestSpanHook?: (span: Span, request: HttpIncomingMessage, response: HttpServerResponse) => void;\n\n /**\n * Whether to automatically ignore common static asset requests like favicon.ico, robots.txt, etc.\n * This helps reduce noise in your transactions.\n *\n * @default `true`\n */\n ignoreStaticAssets?: boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests with the given status codes.\n * By default, spans with some 3xx and 4xx status codes are ignored (see @default).\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 `[[401, 404], [301, 303], [305, 399]]`\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 incoming request.\n * @param request Contains the {@type RequestOptions} object used to make the incoming request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Controls the maximum size of incoming HTTP request bodies attached to events.\n *\n * Available options:\n * - 'none': No request bodies will be attached\n * - 'small': Request bodies up to 1,000 bytes will be attached\n * - 'medium': Request bodies up to 10,000 bytes will be attached (default)\n * - 'always': Request bodies will always be attached\n *\n * Note that even with 'always' setting, bodies exceeding 1MB will never be attached\n * for performance and security reasons.\n *\n * @default 'medium'\n */\n maxIncomingRequestBodySize?: 'none' | 'small' | 'medium' | 'always';\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: HttpIncomingMessage | HttpClientRequest) => void;\n responseHook?: (span: Span, response: HttpIncomingMessage | HttpServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: HttpIncomingMessage | HttpClientRequest,\n response: HttpIncomingMessage | HttpServerResponse,\n ) => void;\n };\n}\n\nexport const instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(\n `${INTEGRATION_NAME}.sentry`,\n options => {\n return new SentryHttpInstrumentation(options);\n },\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 spans = options.spans ?? true;\n const disableIncomingRequestSpans = options.disableIncomingRequestSpans;\n const enableServerSpans = spans && !disableIncomingRequestSpans;\n\n const serverOptions = {\n sessions: options.trackIncomingRequestsAsSessions,\n sessionFlushingDelayMS: options.sessionFlushingDelayMS,\n ignoreRequestBody: options.ignoreIncomingRequestBody,\n maxRequestBodySize: options.maxIncomingRequestBodySize,\n } satisfies HttpServerIntegrationOptions;\n\n const serverSpansOptions: HttpServerSpansIntegrationOptions = {\n ignoreIncomingRequests: options.ignoreIncomingRequests,\n ignoreStaticAssets: options.ignoreStaticAssets,\n ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes,\n instrumentation: options.instrumentation,\n onSpanCreated: options.incomingRequestSpanHook,\n };\n\n const server = httpServerIntegration(serverOptions);\n const serverSpans = httpServerSpansIntegration(serverSpansOptions);\n\n return {\n name: INTEGRATION_NAME,\n setup(client: NodeClient) {\n const clientOptions = client.getOptions();\n\n if (enableServerSpans && hasSpansEnabled(clientOptions)) {\n serverSpans.setup(client);\n }\n },\n setupOnce() {\n server.setupOnce();\n\n const sentryHttpInstrumentationOptions: SentryHttpInstrumentationOptions = {\n breadcrumbs: options.breadcrumbs,\n spans,\n propagateTraceInOutgoingRequests: options.tracePropagation ?? true,\n createSpansForOutgoingRequests: spans,\n ignoreOutgoingRequests: options.ignoreOutgoingRequests,\n outgoingRequestHook: (span: Span, request: HttpClientRequest) => {\n // Sanitize data URLs to prevent long base64 strings in span attributes\n const url = getRequestUrlFromClientRequest(request);\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n // TODO(v11): Update these to the Sentry semantic attributes.\n // https://getsentry.github.io/sentry-conventions/attributes/\n span.setAttribute('http.url', sanitizedUrl);\n span.setAttribute(SEMANTIC_ATTRIBUTE_URL_FULL, sanitizedUrl);\n span.updateName(`${request.method || 'GET'} ${sanitizedUrl}`);\n }\n options.instrumentation?.requestHook?.(span, request);\n },\n outgoingResponseHook: options.instrumentation?.responseHook,\n outgoingRequestApplyCustomAttributes: options.instrumentation?.applyCustomAttributesOnSpan,\n };\n\n // This is Sentry-specific instrumentation for outgoing request\n // breadcrumbs & trace propagation. It uses the diagnostic channels on\n // node versions that support it, falling back to monkey-patching when\n // needed.\n instrumentSentryHttp(sentryHttpInstrumentationOptions);\n },\n processEvent(event) {\n // Always run this, even if spans are disabled\n // The reason being that e.g. the remix integration disables span\n // creation here but still wants to use the ignore status codes option\n return serverSpans.processEvent(event);\n },\n };\n});\n"],"names":[],"mappings":";;;AAsBA,MAAM,gBAAA,GAAmB,MAAA;AA0IlB,MAAM,oBAAA,GAAuB,sBAAA;AAAA,EAClC,GAAG,gBAAgB,CAAA,OAAA,CAAA;AAAA,EACnB,CAAA,OAAA,KAAW;AACT,IAAA,OAAO,IAAI,0BAA0B,OAAO,CAAA;AAAA,EAC9C;AACF;AAMO,MAAM,eAAA,GAAkB,iBAAA,CAAkB,CAAC,OAAA,GAAuB,EAAC,KAAM;AAC9E,EAAA,MAAM,KAAA,GAAQ,QAAQ,KAAA,IAAS,IAAA;AAC/B,EAAA,MAAM,8BAA8B,OAAA,CAAQ,2BAAA;AAC5C,EAAA,MAAM,iBAAA,GAAoB,SAAS,CAAC,2BAAA;AAEpC,EAAA,MAAM,aAAA,GAAgB;AAAA,IACpB,UAAU,OAAA,CAAQ,+BAAA;AAAA,IAClB,wBAAwB,OAAA,CAAQ,sBAAA;AAAA,IAChC,m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AAA;AAC1C,YAAA,IAAA,CAAK,YAAA,CAAa,6BAA6B,YAAY,CAAA;AAC3D,YAAA,IAAA,CAAK,WAAW,CAAA,EAAG,OAAA,CAAQ,UAAU,KAAK,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE,CAAA;AAAA,UAC9D;AACA,UAAA,OAAA,CAAQ,eAAA,EAAiB,WAAA,GAAc,IAAA,EAAM,OAAO,CAAA;AAAA,QACtD,CAAA;AAAA,QACA,oBAAA,EAAsB,QAAQ,eAAA,EAAiB,YAAA;AAAA,QAC/C,oCAAA,EAAsC,QAAQ,eAAA,EAAiB;AAAA,OACjE;AAMA,MAAA,oBAAA,CAAqB,gCAAgC,CAAA;AAAA,IACvD,CAAA;AAAA,IACA,aAAa,KAAA,EAAO;AAIlB,MAAA,OAAO,WAAA,CAAY,aAAa,KAAK,CAAA;AAAA,IACvC;AAAA,GACF;AACF,CAAC;;;;"} | ||
| {"version":3,"file":"http.js","sources":["../../../src/integrations/http.ts"],"sourcesContent":["import type { RequestOptions } from 'node:http';\nimport type { HttpClientRequest, HttpIncomingMessage, HttpServerResponse, Span } from '@sentry/core';\nimport {\n defineIntegration,\n hasSpansEnabled,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n stripDataUrlContent,\n getRequestUrlFromClientRequest,\n} from '@sentry/core';\nimport type {\n NodeClient,\n SentryHttpInstrumentationOptions,\n HttpServerIntegrationOptions,\n HttpServerSpansIntegrationOptions,\n} from '@sentry/node-core';\nimport { httpServerIntegration, httpServerSpansIntegration, instrumentHttpOutgoingRequests } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Http' as const;\n\n// TODO(v11): Consolidate all the various HTTP integration options into one,\n// and deprecate the duplicated and aliased options.\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 * Whether to inject trace propagation headers (sentry-trace, baggage, traceparent) into outgoing HTTP requests.\n *\n * When set to `false`, Sentry will not inject any trace propagation headers, but will still create breadcrumbs\n * (if `breadcrumbs` is enabled). This is useful when `skipOpenTelemetrySetup: true` is configured and you want\n * to avoid duplicate trace headers being injected by both Sentry and OpenTelemetry's HttpInstrumentation.\n *\n * @default `true`\n */\n tracePropagation?: boolean;\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: HttpIncomingMessage) => boolean;\n\n /**\n * A hook that can be used to mutate the span for incoming requests.\n * This is triggered after the span is created, but before it is recorded.\n */\n incomingRequestSpanHook?: (span: Span, request: HttpIncomingMessage, response: HttpServerResponse) => void;\n\n /**\n * Whether to automatically ignore common static asset requests like favicon.ico, robots.txt, etc.\n * This helps reduce noise in your transactions.\n *\n * @default `true`\n */\n ignoreStaticAssets?: boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests with the given status codes.\n * By default, spans with some 3xx and 4xx status codes are ignored (see @default).\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 `[[401, 404], [301, 303], [305, 399]]`\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 incoming request.\n * @param request Contains the {@type RequestOptions} object used to make the incoming request.\n */\n ignoreIncomingRequestBody?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Controls the maximum size of incoming HTTP request bodies attached to events.\n *\n * Available options:\n * - 'none': No request bodies will be attached\n * - 'small': Request bodies up to 1,000 bytes will be attached\n * - 'medium': Request bodies up to 10,000 bytes will be attached (default)\n * - 'always': Request bodies will always be attached\n *\n * Note that even with 'always' setting, bodies exceeding 1MB will never be attached\n * for performance and security reasons.\n *\n * @default 'medium'\n */\n maxIncomingRequestBodySize?: 'none' | 'small' | 'medium' | 'always';\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: HttpIncomingMessage | HttpClientRequest) => void;\n responseHook?: (span: Span, response: HttpIncomingMessage | HttpServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: HttpIncomingMessage | HttpClientRequest,\n response: HttpIncomingMessage | HttpServerResponse,\n ) => void;\n };\n}\n\nexport const instrumentSentryHttp = Object.assign(instrumentHttpOutgoingRequests, {\n id: `${INTEGRATION_NAME}.sentry`,\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 spans = options.spans ?? true;\n const disableIncomingRequestSpans = options.disableIncomingRequestSpans;\n const enableServerSpans = spans && !disableIncomingRequestSpans;\n\n const serverOptions = {\n sessions: options.trackIncomingRequestsAsSessions,\n sessionFlushingDelayMS: options.sessionFlushingDelayMS,\n ignoreRequestBody: options.ignoreIncomingRequestBody,\n maxRequestBodySize: options.maxIncomingRequestBodySize,\n } satisfies HttpServerIntegrationOptions;\n\n const serverSpansOptions: HttpServerSpansIntegrationOptions = {\n ignoreIncomingRequests: options.ignoreIncomingRequests,\n ignoreStaticAssets: options.ignoreStaticAssets,\n ignoreStatusCodes: options.dropSpansForIncomingRequestStatusCodes,\n instrumentation: options.instrumentation,\n onSpanCreated: options.incomingRequestSpanHook,\n };\n\n const server = httpServerIntegration(serverOptions);\n const serverSpans = httpServerSpansIntegration(serverSpansOptions);\n\n return {\n name: INTEGRATION_NAME,\n setup(client: NodeClient) {\n const clientOptions = client.getOptions();\n\n if (enableServerSpans && hasSpansEnabled(clientOptions)) {\n serverSpans.setup(client);\n }\n },\n setupOnce() {\n server.setupOnce();\n\n const sentryHttpInstrumentationOptions: SentryHttpInstrumentationOptions = {\n breadcrumbs: options.breadcrumbs,\n spans,\n propagateTraceInOutgoingRequests: options.tracePropagation ?? true,\n createSpansForOutgoingRequests: spans,\n ignoreOutgoingRequests: options.ignoreOutgoingRequests,\n outgoingRequestHook: (span: Span, request: HttpClientRequest) => {\n // Sanitize data URLs to prevent long base64 strings in span attributes\n const url = getRequestUrlFromClientRequest(request);\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n // TODO(v11): Update these to the Sentry semantic attributes.\n // https://getsentry.github.io/sentry-conventions/attributes/\n span.setAttribute('http.url', sanitizedUrl);\n span.setAttribute(SEMANTIC_ATTRIBUTE_URL_FULL, sanitizedUrl);\n span.updateName(`${request.method || 'GET'} ${sanitizedUrl}`);\n }\n options.instrumentation?.requestHook?.(span, request);\n },\n outgoingResponseHook: options.instrumentation?.responseHook,\n outgoingRequestApplyCustomAttributes: options.instrumentation?.applyCustomAttributesOnSpan,\n };\n\n // This is Sentry-specific instrumentation for outgoing request\n // breadcrumbs & trace propagation. It uses the diagnostic channels on\n // node versions that support it, falling back to monkey-patching when\n // needed.\n instrumentHttpOutgoingRequests(sentryHttpInstrumentationOptions);\n },\n processEvent(event) {\n // Always run this, even if spans are disabled\n // The reason being that e.g. the remix integration disables span\n // creation here but still wants to use the ignore status codes option\n return serverSpans.processEvent(event);\n },\n };\n});\n"],"names":[],"mappings":";;;AAiBA,MAAM,gBAAA,GAAmB,MAAA;AA0IlB,MAAM,oBAAA,GAAuB,MAAA,CAAO,MAAA,CAAO,8BAAA,EAAgC;AAAA,EAChF,EAAA,EAAI,GAAG,gBAAgB,CAAA,OAAA;AACzB,CAAC;AAMM,MAAM,eAAA,GAAkB,iBAAA,CAAkB,CAAC,OAAA,GAAuB,EAAC,KAAM;AAC9E,EAAA,MAAM,KAAA,GAAQ,QAAQ,KAAA,IAAS,IAAA;AAC/B,EAAA,MAAM,8BAA8B,OAAA,CAAQ,2BAAA;AAC5C,EAAA,MAAM,iBAAA,GAAoB,SAAS,CAAC,2BAAA;AAEpC,EAAA,MAAM,aAAA,GAAgB;AAAA,IACpB,UAAU,OAAA,CAAQ,+BAAA;AAAA,IAClB,wBAAwB,OAAA,CAAQ,sBAAA;AAAA,IAChC,mBAAmB,OAAA,CAAQ,yBAAA;AAAA,IAC3B,oBAAoB,OAAA,CAAQ;AAAA,GAC9B;AAEA,EAAA,MAAM,kBAAA,GAAwD;AAAA,IAC5D,wBAAwB,OAAA,CAAQ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A,EAAI,YAAY,CAAA,CAAE,CAAA;AAAA,UAC9D;AACA,UAAA,OAAA,CAAQ,eAAA,EAAiB,WAAA,GAAc,IAAA,EAAM,OAAO,CAAA;AAAA,QACtD,CAAA;AAAA,QACA,oBAAA,EAAsB,QAAQ,eAAA,EAAiB,YAAA;AAAA,QAC/C,oCAAA,EAAsC,QAAQ,eAAA,EAAiB;AAAA,OACjE;AAMA,MAAA,8BAAA,CAA+B,gCAAgC,CAAA;AAAA,IACjE,CAAA;AAAA,IACA,aAAa,KAAA,EAAO;AAIlB,MAAA,OAAO,WAAA,CAAY,aAAa,KAAK,CAAA;AAAA,IACvC;AAAA,GACF;AACF,CAAC;;;;"} |
| import { GraphQLInstrumentation } from './vendored/instrumentation.js'; | ||
| import { defineIntegration } from '@sentry/core'; | ||
| import { defineIntegration, extendIntegration } from '@sentry/core'; | ||
| import { generateInstrumentOnce } from '@sentry/node-core'; | ||
| import { graphqlIntegration as graphqlIntegration$1 } from '@sentry/server-utils'; | ||
@@ -12,3 +13,3 @@ const INTEGRATION_NAME = "Graphql"; | ||
| const _graphqlIntegration = ((options = {}) => { | ||
| return { | ||
| return extendIntegration(graphqlIntegration$1(getOptionsWithDefaults(options)), { | ||
| name: INTEGRATION_NAME, | ||
@@ -18,3 +19,3 @@ setupOnce() { | ||
| } | ||
| }; | ||
| }); | ||
| }); | ||
@@ -21,0 +22,0 @@ const graphqlIntegration = defineIntegration(_graphqlIntegration); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/graphql/index.ts"],"sourcesContent":["import { GraphQLInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\ninterface GraphqlOptions {\n /**\n * Do not create spans for resolvers.\n *\n * Defaults to true.\n */\n ignoreResolveSpans?: boolean;\n\n /**\n * Don't create spans for the execution of the default resolver on object properties.\n *\n * When a resolver function is not defined on the schema for a field, graphql will\n * use the default resolver which just looks for a property with that name on the object.\n * If the property is not a function, it's not very interesting to trace.\n * This option can reduce noise and number of spans created.\n *\n * Defaults to true.\n */\n ignoreTrivialResolveSpans?: boolean;\n\n /**\n * If this is enabled, a http.server root span containing this span will automatically be renamed to include the operation name.\n * Set this to `false` if you do not want this behavior, and want to keep the default http.server span name.\n *\n * Defaults to true.\n */\n useOperationNameForRootSpan?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Graphql' as const;\n\nexport const instrumentGraphql = generateInstrumentOnce(\n INTEGRATION_NAME,\n GraphQLInstrumentation,\n (_options: GraphqlOptions) => getOptionsWithDefaults(_options),\n);\n\nconst _graphqlIntegration = ((options: GraphqlOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n // We set defaults here, too, because otherwise we'd update the instrumentation config\n // to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`\n // when being called the second time\n instrumentGraphql(getOptionsWithDefaults(options));\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.\n *\n * For more information, see the [`graphqlIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).\n *\n * @param {GraphqlOptions} options Configuration options for the GraphQL integration.\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.graphqlIntegration()],\n * });\n */\nexport const graphqlIntegration = defineIntegration(_graphqlIntegration);\n\nfunction getOptionsWithDefaults(options?: GraphqlOptions): GraphqlOptions {\n return {\n ignoreResolveSpans: true,\n ignoreTrivialResolveSpans: true,\n useOperationNameForRootSpan: true,\n ...options,\n };\n}\n"],"names":[],"mappings":";;;;AAkCA,MAAM,gBAAA,GAAmB,SAAA;AAElB,MAAM,iBAAA,GAAoB,sBAAA;AAAA,EAC/B,gBAAA;AAAA,EACA,sBAAA;AAAA,EACA,CAAC,QAAA,KAA6B,sBAAA,CAAuB,QAAQ;AAC/D;AAEA,MAAM,mBAAA,IAAuB,CAAC,OAAA,GAA0B,EAAC,KAAM;AAC7D,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAIV,MAAA,iBAAA,CAAkB,sBAAA,CAAuB,OAAO,CAAC,CAAA;AAAA,IACnD;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,kBAAA,GAAqB,kBAAkB,mBAAmB;AAEvE,SAAS,uBAAuB,OAAA,EAA0C;AACxE,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,IAAA;AAAA,IACpB,yBAAA,EAA2B,IAAA;AAAA,IAC3B,2BAAA,EAA6B,IAAA;AAAA,IAC7B,GAAG;AAAA,GACL;AACF;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/graphql/index.ts"],"sourcesContent":["import { GraphQLInstrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, extendIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { graphqlIntegration as graphqlChannelIntegration } from '@sentry/server-utils';\n\ninterface GraphqlOptions {\n /**\n * Do not create spans for resolvers.\n *\n * Defaults to true.\n */\n ignoreResolveSpans?: boolean;\n\n /**\n * Don't create spans for the execution of the default resolver on object properties.\n *\n * When a resolver function is not defined on the schema for a field, graphql will\n * use the default resolver which just looks for a property with that name on the object.\n * If the property is not a function, it's not very interesting to trace.\n * This option can reduce noise and number of spans created.\n *\n * Defaults to true.\n */\n ignoreTrivialResolveSpans?: boolean;\n\n /**\n * If this is enabled, a http.server root span containing this span will automatically be renamed to include the operation name.\n * Set this to `false` if you do not want this behavior, and want to keep the default http.server span name.\n *\n * Defaults to true.\n */\n useOperationNameForRootSpan?: boolean;\n}\n\nconst INTEGRATION_NAME = 'Graphql' as const;\n\nexport const instrumentGraphql = generateInstrumentOnce(\n INTEGRATION_NAME,\n GraphQLInstrumentation,\n (_options: GraphqlOptions) => getOptionsWithDefaults(_options),\n);\n\nconst _graphqlIntegration = ((options: GraphqlOptions = {}) => {\n // The diagnostics_channel subscription (graphql >= 17) lives in server-utils so it is shared\n // across server runtimes; we extend it here to also run the vendored OTel patcher for graphql < 17.\n // Both paths read the same `ignoreResolveSpans` / `ignoreTrivialResolveSpans` options.\n return extendIntegration(graphqlChannelIntegration(getOptionsWithDefaults(options)), {\n name: INTEGRATION_NAME,\n setupOnce() {\n // We set defaults here, too, because otherwise we'd update the instrumentation config\n // to the config without defaults, as `generateInstrumentOnce` automatically calls `setConfig(options)`\n // when being called the second time\n instrumentGraphql(getOptionsWithDefaults(options));\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [graphql](https://www.npmjs.com/package/graphql) library.\n *\n * For more information, see the [`graphqlIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/graphql/).\n *\n * @param {GraphqlOptions} options Configuration options for the GraphQL integration.\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.graphqlIntegration()],\n * });\n */\nexport const graphqlIntegration = defineIntegration(_graphqlIntegration);\n\nfunction getOptionsWithDefaults(options?: GraphqlOptions): GraphqlOptions {\n return {\n ignoreResolveSpans: true,\n ignoreTrivialResolveSpans: true,\n useOperationNameForRootSpan: true,\n ...options,\n };\n}\n"],"names":["graphqlChannelIntegration"],"mappings":";;;;;AAmCA,MAAM,gBAAA,GAAmB,SAAA;AAElB,MAAM,iBAAA,GAAoB,sBAAA;AAAA,EAC/B,gBAAA;AAAA,EACA,sBAAA;AAAA,EACA,CAAC,QAAA,KAA6B,sBAAA,CAAuB,QAAQ;AAC/D;AAEA,MAAM,mBAAA,IAAuB,CAAC,OAAA,GAA0B,EAAC,KAAM;AAI7D,EAAA,OAAO,iBAAA,CAAkBA,oBAAA,CAA0B,sBAAA,CAAuB,OAAO,CAAC,CAAA,EAAG;AAAA,IACnF,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AAIV,MAAA,iBAAA,CAAkB,sBAAA,CAAuB,OAAO,CAAC,CAAA;AAAA,IACnD;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAiBO,MAAM,kBAAA,GAAqB,kBAAkB,mBAAmB;AAEvE,SAAS,uBAAuB,OAAA,EAA0C;AACxE,EAAA,OAAO;AAAA,IACL,kBAAA,EAAoB,IAAA;AAAA,IACpB,yBAAA,EAA2B,IAAA;AAAA,IAC3B,2BAAA,EAA6B,IAAA;AAAA,IAC7B,GAAG;AAAA,GACL;AACF;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/graphql/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-graphql\n * - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0\n * - Types from `graphql` package inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n * - Span lifecycle migrated from the OpenTelemetry tracer to the @sentry/core span API\n * - `auto.graphql.otel.graphql` origin baked into the execute span (previously set via a Sentry responseHook)\n * - The generic `responseHook` config was removed; its Sentry-specific logic (error status + root span renaming\n * via `useOperationNameForRootSpan`) is now applied directly when the execution result is handled\n */\n\n/* oxlint-disable max-lines */\n\nimport {\n isWrapped,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport type {\n DefinitionNode,\n DocumentNode,\n ExecutionArgs,\n ExecutionResult,\n GraphQLError,\n GraphQLFieldResolver,\n GraphQLSchema,\n GraphQLTypeResolver,\n OperationDefinitionNode,\n ParseOptions,\n PromiseOrValue,\n Source,\n TypeInfo,\n ValidationRule,\n} from './graphql-types';\nimport type { Maybe } from './graphql-types';\nimport { SpanNames } from './enum';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { OTEL_GRAPHQL_DATA_SYMBOL } from './symbols';\n\nimport {\n type executeFunctionWithObj,\n type executeArgumentsArray,\n type executeType,\n type parseType,\n type validateType,\n type OtelExecutionArgs,\n type ObjectWithGraphQLData,\n OPERATION_NOT_SUPPORTED,\n} from './internal-types';\nimport { addSpanSource, endSpan, getOperation, isPromise, wrapFieldResolver, wrapFields } from './utils';\n\nimport type { Span, SpanAttributeValue } from '@sentry/core';\nimport {\n getRootSpan,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n spanToJSON,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';\nimport type { GraphQLInstrumentationConfig, GraphQLInstrumentationParsedConfig } from './types';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-graphql';\n\nconst ORIGIN = 'auto.graphql.otel.graphql';\n\nconst DEFAULT_CONFIG: GraphQLInstrumentationParsedConfig = {\n ignoreResolveSpans: false,\n};\n\nconst supportedVersions = ['>=14.0.0 <17'];\n\nexport class GraphQLInstrumentation extends InstrumentationBase<GraphQLInstrumentationParsedConfig> {\n constructor(config: GraphQLInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, { ...DEFAULT_CONFIG, ...config });\n }\n\n override setConfig(config: GraphQLInstrumentationConfig = {}) {\n super.setConfig({ ...DEFAULT_CONFIG, ...config });\n }\n\n protected init() {\n const module = new InstrumentationNodeModuleDefinition('graphql', supportedVersions);\n module.files.push(this._addPatchingExecute());\n module.files.push(this._addPatchingParser());\n module.files.push(this._addPatchingValidate());\n\n return module;\n }\n\n private _addPatchingExecute(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/execution/execute.js',\n supportedVersions,\n // cannot make it work with appropriate type as execute function has 2\n //types and/cannot import function but only types\n (moduleExports: any) => {\n if (isWrapped(moduleExports.execute)) {\n this._unwrap(moduleExports, 'execute');\n }\n this._wrap(moduleExports, 'execute', this._patchExecute(moduleExports.defaultFieldResolver));\n return moduleExports;\n },\n moduleExports => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'execute');\n }\n },\n );\n }\n\n private _addPatchingParser(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/language/parser.js',\n supportedVersions,\n (moduleExports: { parse: parseType; [key: string]: any }) => {\n if (isWrapped(moduleExports.parse)) {\n this._unwrap(moduleExports, 'parse');\n }\n this._wrap(moduleExports, 'parse', this._patchParse());\n return moduleExports;\n },\n (moduleExports: { parse: parseType; [key: string]: any }) => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'parse');\n }\n },\n );\n }\n\n private _addPatchingValidate(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/validation/validate.js',\n supportedVersions,\n moduleExports => {\n if (isWrapped(moduleExports.validate)) {\n this._unwrap(moduleExports, 'validate');\n }\n this._wrap(moduleExports, 'validate', this._patchValidate());\n return moduleExports;\n },\n moduleExports => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'validate');\n }\n },\n );\n }\n\n private _patchExecute(defaultFieldResolved: GraphQLFieldResolver<any, any>): (original: executeType) => executeType {\n const instrumentation = this;\n return function execute(original) {\n return function patchExecute(this: executeType): PromiseOrValue<ExecutionResult> {\n let processedArgs: OtelExecutionArgs;\n\n // case when apollo server is used for example\n if (arguments.length >= 2) {\n const args = arguments as unknown as executeArgumentsArray;\n processedArgs = instrumentation._wrapExecuteArgs(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4],\n args[5],\n args[6],\n args[7],\n defaultFieldResolved,\n );\n } else {\n const args = arguments[0] as ExecutionArgs;\n processedArgs = instrumentation._wrapExecuteArgs(\n args.schema,\n args.document,\n args.rootValue,\n args.contextValue,\n args.variableValues,\n args.operationName,\n args.fieldResolver,\n args.typeResolver,\n defaultFieldResolved,\n );\n }\n\n const operation = getOperation(processedArgs.document, processedArgs.operationName);\n\n const span = instrumentation._createExecuteSpan(operation, processedArgs);\n\n processedArgs.contextValue[OTEL_GRAPHQL_DATA_SYMBOL] = {\n source: processedArgs.document\n ? processedArgs.document || (processedArgs.document as ObjectWithGraphQLData)[OTEL_GRAPHQL_DATA_SYMBOL]\n : undefined,\n span,\n fields: {},\n };\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<PromiseOrValue<ExecutionResult>>(\n () => {\n return (original as executeFunctionWithObj).apply(this, [processedArgs]);\n },\n (err, result) => {\n instrumentation._handleExecutionResult(span, err, result);\n },\n );\n });\n };\n };\n }\n\n private _handleExecutionResult(span: Span, err?: Error, result?: PromiseOrValue<ExecutionResult>) {\n if (result === undefined || err) {\n endSpan(span, err);\n return;\n }\n\n if (isPromise(result)) {\n result.then(\n resultData => {\n this._updateSpanFromResult(span, resultData);\n endSpan(span);\n },\n error => {\n endSpan(span, error);\n },\n );\n } else {\n this._updateSpanFromResult(span, result);\n endSpan(span);\n }\n }\n\n /**\n * Applies Sentry-specific span mutations based on the GraphQL execution result:\n * - Marks the execute span as errored if the result contains errors (and no status was set yet)\n * - Optionally renames the containing root span to include the GraphQL operation name(s)\n */\n private _updateSpanFromResult(span: Span, result: ExecutionResult): void {\n // We want to ensure spans are marked as errored if there are errors in the result\n // We only do that if the span is not already marked with a status\n if (result.errors?.length && !spanToJSON(span).status) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n }\n\n if (!this.getConfig().useOperationNameForRootSpan) {\n return;\n }\n\n const attributes = spanToJSON(span).data;\n\n // If operation.name is not set, we fall back to use operation.type only\n const operationType = attributes[AttributeNames.OPERATION_TYPE];\n const operationName = attributes[AttributeNames.OPERATION_NAME];\n\n if (!operationType) {\n return;\n }\n\n const rootSpan = getRootSpan(span);\n const rootSpanAttributes = spanToJSON(rootSpan).data;\n\n const existingOperations = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION] || [];\n\n const newOperation = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n\n // We keep track of each operation on the root span\n // This can either be a string, or an array of strings (if there are multiple operations)\n if (Array.isArray(existingOperations)) {\n (existingOperations as string[]).push(newOperation);\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, existingOperations);\n } else if (typeof existingOperations === 'string') {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);\n } else {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, newOperation);\n }\n\n if (!spanToJSON(rootSpan).data['original-description']) {\n rootSpan.setAttribute('original-description', spanToJSON(rootSpan).description);\n }\n // Important for e.g. @sentry/aws-serverless because this would otherwise overwrite the name again\n rootSpan.updateName(\n `${spanToJSON(rootSpan).data['original-description']} (${getGraphqlOperationNamesFromAttribute(\n existingOperations,\n )})`,\n );\n }\n\n private _patchParse(): (original: parseType) => parseType {\n const instrumentation = this;\n return function parse(original) {\n return function patchParse(this: parseType, source: string | Source, options?: ParseOptions): DocumentNode {\n return instrumentation._parse(this, original, source, options);\n };\n };\n }\n\n private _patchValidate(): (original: validateType) => validateType {\n const instrumentation = this;\n return function validate(original: validateType) {\n return function patchValidate(\n this: validateType,\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules?: ReadonlyArray<ValidationRule>,\n options?: { maxErrors?: number },\n typeInfo?: TypeInfo,\n ): ReadonlyArray<GraphQLError> {\n return instrumentation._validate(this, original, schema, documentAST, rules, typeInfo, options);\n };\n };\n }\n\n private _parse(obj: parseType, original: parseType, source: string | Source, options?: ParseOptions): DocumentNode {\n const span = startInactiveSpan({ name: SpanNames.PARSE });\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<DocumentNode & ObjectWithGraphQLData>(\n () => {\n return original.call(obj, source, options);\n },\n (err, result) => {\n if (result) {\n const operation = getOperation(result);\n if (!operation) {\n span.updateName(SpanNames.SCHEMA_PARSE);\n } else if (result.loc) {\n addSpanSource(span, result.loc);\n }\n }\n endSpan(span, err);\n },\n );\n });\n }\n\n private _validate(\n obj: validateType,\n original: validateType,\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules?: ReadonlyArray<ValidationRule>,\n typeInfo?: TypeInfo,\n options?: { maxErrors?: number },\n ): ReadonlyArray<GraphQLError> {\n const span = startInactiveSpan({ name: SpanNames.VALIDATE });\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<ReadonlyArray<GraphQLError>>(\n () => {\n return original.call(obj, schema, documentAST, rules, options, typeInfo);\n },\n (err, _errors) => {\n if (!documentAST.loc) {\n span.updateName(SpanNames.SCHEMA_VALIDATE);\n }\n endSpan(span, err);\n },\n );\n });\n }\n\n private _createExecuteSpan(operation: DefinitionNode | undefined, processedArgs: ExecutionArgs): Span {\n const span = startInactiveSpan({\n name: SpanNames.EXECUTE,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN },\n });\n if (operation) {\n const { operation: operationType, name: nameNode } = operation as OperationDefinitionNode;\n\n span.setAttribute(AttributeNames.OPERATION_TYPE, operationType);\n\n const operationName = nameNode?.value;\n\n // https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/instrumentation/graphql/\n // > The span name MUST be of the format <graphql.operation.type> <graphql.operation.name> provided that graphql.operation.type and graphql.operation.name are available.\n // > If graphql.operation.name is not available, the span SHOULD be named <graphql.operation.type>.\n if (operationName) {\n span.setAttribute(AttributeNames.OPERATION_NAME, operationName);\n span.updateName(`${operationType} ${operationName}`);\n } else {\n span.updateName(operationType);\n }\n } else {\n let operationName = ' ';\n if (processedArgs.operationName) {\n operationName = ` \"${processedArgs.operationName}\" `;\n }\n operationName = OPERATION_NOT_SUPPORTED.replace('$operationName$', operationName);\n span.setAttribute(AttributeNames.OPERATION_NAME, operationName);\n }\n\n if (processedArgs.document?.loc) {\n addSpanSource(span, processedArgs.document.loc);\n }\n\n return span;\n }\n\n private _wrapExecuteArgs(\n schema: GraphQLSchema,\n document: DocumentNode,\n rootValue: any,\n contextValue: any,\n variableValues: Maybe<{ [key: string]: any }>,\n operationName: Maybe<string>,\n fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,\n typeResolver: Maybe<GraphQLTypeResolver<any, any>>,\n defaultFieldResolved: GraphQLFieldResolver<any, any>,\n ): OtelExecutionArgs {\n if (!contextValue) {\n // oxlint-disable-next-line no-param-reassign\n contextValue = {};\n }\n\n if (contextValue[OTEL_GRAPHQL_DATA_SYMBOL] || this.getConfig().ignoreResolveSpans) {\n return {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n };\n }\n\n const isUsingDefaultResolver = fieldResolver == null;\n // follows graphql implementation here:\n // https://github.com/graphql/graphql-js/blob/0b7daed9811731362c71900e12e5ea0d1ecc7f1f/src/execution/execute.ts#L494\n const fieldResolverForExecute = fieldResolver ?? defaultFieldResolved;\n // oxlint-disable-next-line no-param-reassign\n fieldResolver = wrapFieldResolver(() => this.getConfig(), fieldResolverForExecute, isUsingDefaultResolver);\n\n if (schema) {\n wrapFields(schema.getQueryType() as any, () => this.getConfig());\n wrapFields(schema.getMutationType() as any, () => this.getConfig());\n }\n\n return {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n };\n }\n}\n\n// copy from packages/opentelemetry/utils\nfunction getGraphqlOperationNamesFromAttribute(attr: SpanAttributeValue): string {\n if (Array.isArray(attr)) {\n // oxlint-disable-next-line typescript/require-array-sort-compare\n const sorted = attr.slice().sort();\n\n // Up to 5 items, we just add all of them\n if (sorted.length <= 5) {\n return sorted.join(', ');\n } else {\n // Else, we add the first 5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IAAA,EAAK;AAGjC,IAAA,IAAI,MAAA,CAAO,UAAU,CAAA,EAAG;AACtB,MAAA,OAAO,MAAA,CAAO,KAAK,IAAI,CAAA;AAAA,IACzB,CAAA,MAAO;AAEL,MAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,GAAA,EAAM,MAAA,CAAO,MAAA,GAAS,CAAC,CAAA,CAAA;AAAA,IAChE;AAAA,EACF;AAEA,EAAA,OAAO,GAAG,IAAI,CAAA,CAAA;AAChB;;;;"} | ||
| {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/graphql/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-graphql\n * - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0\n * - Types from `graphql` package inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n * - Span lifecycle migrated from the OpenTelemetry tracer to the @sentry/core span API\n * - `auto.graphql.otel.graphql` origin baked into the execute span (previously set via a Sentry responseHook)\n * - The generic `responseHook` config was removed; its Sentry-specific logic (error status + root span renaming\n * via `useOperationNameForRootSpan`) is now applied directly when the execution result is handled\n */\n\n/* oxlint-disable max-lines */\n\nimport {\n isWrapped,\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport type {\n DefinitionNode,\n DocumentNode,\n ExecutionArgs,\n ExecutionResult,\n GraphQLError,\n GraphQLFieldResolver,\n GraphQLSchema,\n GraphQLTypeResolver,\n OperationDefinitionNode,\n ParseOptions,\n PromiseOrValue,\n Source,\n TypeInfo,\n ValidationRule,\n} from './graphql-types';\nimport type { Maybe } from './graphql-types';\nimport { SpanNames } from './enum';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { OTEL_GRAPHQL_DATA_SYMBOL } from './symbols';\n\nimport {\n type executeFunctionWithObj,\n type executeArgumentsArray,\n type executeType,\n type parseType,\n type validateType,\n type OtelExecutionArgs,\n type ObjectWithGraphQLData,\n OPERATION_NOT_SUPPORTED,\n} from './internal-types';\nimport { addSpanSource, endSpan, getOperation, isPromise, wrapFieldResolver, wrapFields } from './utils';\n\nimport type { Span, SpanAttributeValue } from '@sentry/core';\nimport {\n getRootSpan,\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_STATUS_ERROR,\n spanToJSON,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';\nimport type { GraphQLInstrumentationConfig, GraphQLInstrumentationParsedConfig } from './types';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-graphql';\n\nconst ORIGIN = 'auto.graphql.otel.graphql';\n\nconst DEFAULT_CONFIG: GraphQLInstrumentationParsedConfig = {\n ignoreResolveSpans: false,\n};\n\nconst supportedVersions = ['>=14.0.0 <17'];\n\nexport class GraphQLInstrumentation extends InstrumentationBase<GraphQLInstrumentationParsedConfig> {\n constructor(config: GraphQLInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, { ...DEFAULT_CONFIG, ...config });\n }\n\n override setConfig(config: GraphQLInstrumentationConfig = {}) {\n super.setConfig({ ...DEFAULT_CONFIG, ...config });\n }\n\n protected init() {\n const module = new InstrumentationNodeModuleDefinition('graphql', supportedVersions);\n module.files.push(this._addPatchingExecute());\n module.files.push(this._addPatchingParser());\n module.files.push(this._addPatchingValidate());\n\n return module;\n }\n\n private _addPatchingExecute(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/execution/execute.js',\n supportedVersions,\n // cannot make it work with appropriate type as execute function has 2\n //types and/cannot import function but only types\n (moduleExports: any) => {\n if (isWrapped(moduleExports.execute)) {\n this._unwrap(moduleExports, 'execute');\n }\n this._wrap(moduleExports, 'execute', this._patchExecute(moduleExports.defaultFieldResolver));\n return moduleExports;\n },\n moduleExports => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'execute');\n }\n },\n );\n }\n\n private _addPatchingParser(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/language/parser.js',\n supportedVersions,\n (moduleExports: { parse: parseType; [key: string]: any }) => {\n if (isWrapped(moduleExports.parse)) {\n this._unwrap(moduleExports, 'parse');\n }\n this._wrap(moduleExports, 'parse', this._patchParse());\n return moduleExports;\n },\n (moduleExports: { parse: parseType; [key: string]: any }) => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'parse');\n }\n },\n );\n }\n\n private _addPatchingValidate(): InstrumentationNodeModuleFile {\n return new InstrumentationNodeModuleFile(\n 'graphql/validation/validate.js',\n supportedVersions,\n moduleExports => {\n if (isWrapped(moduleExports.validate)) {\n this._unwrap(moduleExports, 'validate');\n }\n this._wrap(moduleExports, 'validate', this._patchValidate());\n return moduleExports;\n },\n moduleExports => {\n if (moduleExports) {\n this._unwrap(moduleExports, 'validate');\n }\n },\n );\n }\n\n private _patchExecute(defaultFieldResolved: GraphQLFieldResolver<any, any>): (original: executeType) => executeType {\n const instrumentation = this;\n return function execute(original) {\n return function patchExecute(this: executeType): PromiseOrValue<ExecutionResult> {\n let processedArgs: OtelExecutionArgs;\n\n // case when apollo server is used for example\n if (arguments.length >= 2) {\n const args = arguments as unknown as executeArgumentsArray;\n processedArgs = instrumentation._wrapExecuteArgs(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4],\n args[5],\n args[6],\n args[7],\n defaultFieldResolved,\n );\n } else {\n const args = arguments[0] as ExecutionArgs;\n processedArgs = instrumentation._wrapExecuteArgs(\n args.schema,\n args.document,\n args.rootValue,\n args.contextValue,\n args.variableValues,\n args.operationName,\n args.fieldResolver,\n args.typeResolver,\n defaultFieldResolved,\n );\n }\n\n const operation = getOperation(processedArgs.document, processedArgs.operationName);\n\n const span = instrumentation._createExecuteSpan(operation, processedArgs);\n\n processedArgs.contextValue[OTEL_GRAPHQL_DATA_SYMBOL] = {\n source: processedArgs.document\n ? processedArgs.document || (processedArgs.document as ObjectWithGraphQLData)[OTEL_GRAPHQL_DATA_SYMBOL]\n : undefined,\n span,\n fields: {},\n };\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<PromiseOrValue<ExecutionResult>>(\n () => {\n return (original as executeFunctionWithObj).apply(this, [processedArgs]);\n },\n (err, result) => {\n instrumentation._handleExecutionResult(span, err, result);\n },\n );\n });\n };\n };\n }\n\n private _handleExecutionResult(span: Span, err?: Error, result?: PromiseOrValue<ExecutionResult>) {\n if (result === undefined || err) {\n endSpan(span, err);\n return;\n }\n\n if (isPromise(result)) {\n result.then(\n resultData => {\n this._updateSpanFromResult(span, resultData);\n endSpan(span);\n },\n error => {\n endSpan(span, error);\n },\n );\n } else {\n this._updateSpanFromResult(span, result);\n endSpan(span);\n }\n }\n\n /**\n * Applies Sentry-specific span mutations based on the GraphQL execution result:\n * - Marks the execute span as errored if the result contains errors (and no status was set yet)\n * - Optionally renames the containing root span to include the GraphQL operation name(s)\n */\n private _updateSpanFromResult(span: Span, result: ExecutionResult): void {\n // We want to ensure spans are marked as errored if there are errors in the result\n // We only do that if the span is not already marked with a status\n if (result.errors?.length && !spanToJSON(span).status) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n }\n\n if (!this.getConfig().useOperationNameForRootSpan) {\n return;\n }\n\n const attributes = spanToJSON(span).data;\n\n // If operation.name is not set, we fall back to use operation.type only\n const operationType = attributes[AttributeNames.OPERATION_TYPE];\n const operationName = attributes[AttributeNames.OPERATION_NAME];\n\n if (!operationType) {\n return;\n }\n\n const rootSpan = getRootSpan(span);\n const rootSpanAttributes = spanToJSON(rootSpan).data;\n\n const existingOperations = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION] || [];\n\n const newOperation = operationName ? `${operationType} ${operationName}` : `${operationType}`;\n\n // We keep track of each operation on the root span\n // This can either be a string, or an array of strings (if there are multiple operations)\n if (Array.isArray(existingOperations)) {\n (existingOperations as string[]).push(newOperation);\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, existingOperations);\n } else if (typeof existingOperations === 'string') {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);\n } else {\n rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, newOperation);\n }\n\n if (!spanToJSON(rootSpan).data['original-description']) {\n rootSpan.setAttribute('original-description', spanToJSON(rootSpan).description);\n }\n // Important for e.g. @sentry/aws-serverless because this would otherwise overwrite the name again\n rootSpan.updateName(\n `${spanToJSON(rootSpan).data['original-description']} (${getGraphqlOperationNamesFromAttribute(\n existingOperations,\n )})`,\n );\n }\n\n private _patchParse(): (original: parseType) => parseType {\n const instrumentation = this;\n return function parse(original) {\n return function patchParse(this: parseType, source: string | Source, options?: ParseOptions): DocumentNode {\n return instrumentation._parse(this, original, source, options);\n };\n };\n }\n\n private _patchValidate(): (original: validateType) => validateType {\n const instrumentation = this;\n return function validate(original: validateType) {\n return function patchValidate(\n this: validateType,\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules?: ReadonlyArray<ValidationRule>,\n options?: { maxErrors?: number },\n typeInfo?: TypeInfo,\n ): ReadonlyArray<GraphQLError> {\n return instrumentation._validate(this, original, schema, documentAST, rules, typeInfo, options);\n };\n };\n }\n\n private _parse(obj: parseType, original: parseType, source: string | Source, options?: ParseOptions): DocumentNode {\n const span = startInactiveSpan({ name: SpanNames.PARSE });\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<DocumentNode & ObjectWithGraphQLData>(\n () => {\n return original.call(obj, source, options);\n },\n (err, result) => {\n if (result) {\n const operation = getOperation(result);\n if (!operation) {\n span.updateName(SpanNames.SCHEMA_PARSE);\n } else if (result.loc) {\n addSpanSource(span, result.loc);\n }\n }\n endSpan(span, err);\n },\n );\n });\n }\n\n private _validate(\n obj: validateType,\n original: validateType,\n schema: GraphQLSchema,\n documentAST: DocumentNode,\n rules?: ReadonlyArray<ValidationRule>,\n typeInfo?: TypeInfo,\n options?: { maxErrors?: number },\n ): ReadonlyArray<GraphQLError> {\n const span = startInactiveSpan({ name: SpanNames.VALIDATE });\n\n return withActiveSpan(span, () => {\n return safeExecuteInTheMiddle<ReadonlyArray<GraphQLError>>(\n () => {\n return original.call(obj, schema, documentAST, rules, options, typeInfo);\n },\n (err, _errors) => {\n if (!documentAST.loc) {\n span.updateName(SpanNames.SCHEMA_VALIDATE);\n }\n endSpan(span, err);\n },\n );\n });\n }\n\n private _createExecuteSpan(operation: DefinitionNode | undefined, processedArgs: OtelExecutionArgs): Span {\n const span = startInactiveSpan({\n name: SpanNames.EXECUTE,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN },\n });\n if (operation) {\n const { operation: operationType, name: nameNode } = operation as OperationDefinitionNode;\n\n span.setAttribute(AttributeNames.OPERATION_TYPE, operationType);\n\n const operationName = nameNode?.value;\n\n // https://opentelemetry.io/docs/reference/specification/trace/semantic_conventions/instrumentation/graphql/\n // > The span name MUST be of the format <graphql.operation.type> <graphql.operation.name> provided that graphql.operation.type and graphql.operation.name are available.\n // > If graphql.operation.name is not available, the span SHOULD be named <graphql.operation.type>.\n if (operationName) {\n span.setAttribute(AttributeNames.OPERATION_NAME, operationName);\n span.updateName(`${operationType} ${operationName}`);\n } else {\n span.updateName(operationType);\n }\n } else {\n let operationName = ' ';\n if (processedArgs.operationName) {\n operationName = ` \"${processedArgs.operationName}\" `;\n }\n operationName = OPERATION_NOT_SUPPORTED.replace('$operationName$', operationName);\n span.setAttribute(AttributeNames.OPERATION_NAME, operationName);\n }\n\n if (processedArgs.document?.loc) {\n addSpanSource(span, processedArgs.document.loc);\n }\n\n return span;\n }\n\n private _wrapExecuteArgs(\n schema: GraphQLSchema,\n document: DocumentNode,\n rootValue: any,\n contextValue: any,\n variableValues: Maybe<{ [key: string]: any }>,\n operationName: Maybe<string>,\n fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,\n typeResolver: Maybe<GraphQLTypeResolver<any, any>>,\n defaultFieldResolved: GraphQLFieldResolver<any, any>,\n ): OtelExecutionArgs {\n if (!contextValue) {\n // oxlint-disable-next-line no-param-reassign\n contextValue = {};\n }\n\n if (contextValue[OTEL_GRAPHQL_DATA_SYMBOL] || this.getConfig().ignoreResolveSpans) {\n return {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n };\n }\n\n const isUsingDefaultResolver = fieldResolver == null;\n // follows graphql implementation here:\n // https://github.com/graphql/graphql-js/blob/0b7daed9811731362c71900e12e5ea0d1ecc7f1f/src/execution/execute.ts#L494\n const fieldResolverForExecute = fieldResolver ?? defaultFieldResolved;\n // oxlint-disable-next-line no-param-reassign\n fieldResolver = wrapFieldResolver(() => this.getConfig(), fieldResolverForExecute, isUsingDefaultResolver);\n\n if (schema) {\n wrapFields(schema.getQueryType() as any, () => this.getConfig());\n wrapFields(schema.getMutationType() as any, () => this.getConfig());\n }\n\n return {\n schema,\n document,\n rootValue,\n contextValue,\n variableValues,\n operationName,\n fieldResolver,\n typeResolver,\n };\n }\n}\n\n// copy from packages/opentelemetry/utils\nfunction getGraphqlOperationNamesFromAttribute(attr: SpanAttributeValue): string {\n if (Array.isArray(attr)) {\n // oxlint-disable-next-line typescript/require-array-sort-compare\n const sorted = attr.slice().sort();\n\n // Up to 5 items, we just add all of them\n if (sorted.length <= 5) {\n return sorted.join(', ');\n } else {\n // Else, we add the first 5 and the diff of other operations\n return `${sorted.slice(0, 5).join(', ')}, +${sor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AAU,CAAA,EAAG;AACtB,MAAA,OAAO,MAAA,CAAO,KAAK,IAAI,CAAA;AAAA,IACzB,CAAA,MAAO;AAEL,MAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,GAAA,EAAM,MAAA,CAAO,MAAA,GAAS,CAAC,CAAA,CAAA;AAAA,IAChE;AAAA,EACF;AAEA,EAAA,OAAO,GAAG,IAAI,CAAA,CAAA;AAChB;;;;"} |
@@ -1,2 +0,2 @@ | ||
| import { SPAN_STATUS_ERROR, withActiveSpan, startInactiveSpan } from '@sentry/core'; | ||
| import { SPAN_STATUS_ERROR, isObjectLike, withActiveSpan, startInactiveSpan } from '@sentry/core'; | ||
| import { AllowedOperationTypes, TokenKind, SpanNames } from './enum.js'; | ||
@@ -10,5 +10,2 @@ import { AttributeNames } from './enums/AttributeNames.js'; | ||
| }; | ||
| const isObjectLike = (value) => { | ||
| return typeof value == "object" && value !== null; | ||
| }; | ||
| function addSpanSource(span, loc, start, end) { | ||
@@ -15,0 +12,0 @@ const source = getSourceFromLocation(loc, start, end); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/graphql/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-graphql\n * - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0\n * - Types from `graphql` package inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n * - Span lifecycle migrated from the OpenTelemetry tracer to the @sentry/core span API\n */\n\nimport type {\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLResolveInfo,\n GraphQLType,\n GraphQLUnionType,\n Location,\n Maybe,\n Token,\n} from './graphql-types';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport { SPAN_STATUS_ERROR, startInactiveSpan, withActiveSpan } from '@sentry/core';\nimport { AllowedOperationTypes, SpanNames, TokenKind } from './enum';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { OTEL_GRAPHQL_DATA_SYMBOL, OTEL_PATCHED_SYMBOL } from './symbols';\nimport type { GraphQLField, GraphQLPath, ObjectWithGraphQLData, OtelPatched } from './internal-types';\nimport type { GraphQLInstrumentationParsedConfig } from './types';\n\nconst OPERATION_VALUES = Object.values(AllowedOperationTypes);\n\n// https://github.com/graphql/graphql-js/blob/main/src/jsutils/isPromise.ts\nexport const isPromise = (value: any): value is Promise<unknown> => {\n return typeof value?.then === 'function';\n};\n\n// https://github.com/graphql/graphql-js/blob/main/src/jsutils/isObjectLike.ts\nconst isObjectLike = (value: unknown): value is { [key: string]: unknown } => {\n return typeof value == 'object' && value !== null;\n};\n\nexport function addSpanSource(span: Span, loc?: Location, start?: number, end?: number): void {\n const source = getSourceFromLocation(loc, start, end);\n span.setAttribute(AttributeNames.SOURCE, source);\n}\n\nfunction createFieldIfNotExists(\n contextValue: any,\n info: GraphQLResolveInfo,\n path: string[],\n): {\n field: GraphQLField;\n spanAdded: boolean;\n} {\n let field = getField(contextValue, path);\n if (field) {\n return { field, spanAdded: false };\n }\n\n const parentSpan = getParentFieldSpan(contextValue, path);\n\n field = {\n span: createResolverSpan(contextValue, info, path, parentSpan),\n };\n\n addField(contextValue, path, field);\n\n return { field, spanAdded: true };\n}\n\nfunction createResolverSpan(contextValue: any, info: GraphQLResolveInfo, path: string[], parentSpan?: Span): Span {\n const attributes: SpanAttributes = {\n [AttributeNames.FIELD_NAME]: info.fieldName,\n [AttributeNames.FIELD_PATH]: path.join('.'),\n [AttributeNames.FIELD_TYPE]: info.returnType.toString(),\n [AttributeNames.PARENT_NAME]: info.parentType.name,\n };\n\n const span = startInactiveSpan({\n name: `${SpanNames.RESOLVE} ${attributes[AttributeNames.FIELD_PATH]}`,\n attributes,\n parentSpan,\n });\n\n const document = contextValue[OTEL_GRAPHQL_DATA_SYMBOL].source;\n const fieldNode = info.fieldNodes.find(fieldNode => fieldNode.kind === 'Field');\n\n if (fieldNode) {\n addSpanSource(span, document.loc, fieldNode.loc?.start, fieldNode.loc?.end);\n }\n\n return span;\n}\n\nexport function endSpan(span: Span, error?: Error): void {\n if (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n}\n\nexport function getOperation(document: DocumentNode, operationName?: Maybe<string>): DefinitionNodeLike | undefined {\n if (!document || !Array.isArray(document.definitions)) {\n return undefined;\n }\n\n if (operationName) {\n return document.definitions\n .filter(definition => OPERATION_VALUES.indexOf(definition?.operation) !== -1)\n .find(definition => operationName === definition?.name?.value);\n } else {\n return document.definitions.find(definition => OPERATION_VALUES.indexOf(definition?.operation) !== -1);\n }\n}\n\ntype DefinitionNodeLike = DocumentNode['definitions'][number];\n\nfunction addField(contextValue: any, path: string[], field: GraphQLField) {\n return (contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path.join('.')] = field);\n}\n\nfunction getField(contextValue: any, path: string[]): GraphQLField {\n return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path.join('.')];\n}\n\nfunction getParentFieldSpan(contextValue: any, path: string[]): Span {\n for (let i = path.length - 1; i > 0; i--) {\n const field = getField(contextValue, path.slice(0, i));\n\n if (field) {\n return field.span;\n }\n }\n\n return getRootSpan(contextValue);\n}\n\nfunction getRootSpan(contextValue: any): Span {\n return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].span;\n}\n\nfunction pathToArray(path: GraphQLPath): string[] {\n const flattened: string[] = [];\n let curr: GraphQLPath | undefined = path;\n while (curr) {\n flattened.push(String(curr.key));\n curr = curr.prev;\n }\n return flattened.reverse();\n}\n\nfunction repeatBreak(i: number): string {\n return repeatChar('\\n', i);\n}\n\nfunction repeatSpace(i: number): string {\n return repeatChar(' ', i);\n}\n\nfunction repeatChar(char: string, to: number): string {\n let text = '';\n for (let i = 0; i < to; i++) {\n text += char;\n }\n return text;\n}\n\nconst KindsToBeRemoved: string[] = [TokenKind.FLOAT, TokenKind.STRING, TokenKind.INT, TokenKind.BLOCK_STRING];\n\nexport function getSourceFromLocation(loc?: Location, inputStart?: number, inputEnd?: number): string {\n let source = '';\n\n if (loc?.startToken) {\n const start = typeof inputStart === 'number' ? inputStart : loc.start;\n const end = typeof inputEnd === 'number' ? inputEnd : loc.end;\n\n let next: Token | null = loc.startToken.next;\n let previousLine: number | undefined = 1;\n while (next) {\n if (next.start < start) {\n next = next.next;\n previousLine = next?.line;\n continue;\n }\n if (next.end > end) {\n next = next.next;\n previousLine = next?.line;\n continue;\n }\n let value = next.value || next.kind;\n let space = '';\n if (KindsToBeRemoved.indexOf(next.kind) >= 0) {\n value = '*';\n }\n if (next.kind === TokenKind.STRING) {\n value = `\"${value}\"`;\n }\n if (next.kind === TokenKind.EOF) {\n value = '';\n }\n if (next.line > previousLine!) {\n source += repeatBreak(next.line - previousLine!);\n previousLine = next.line;\n space = repeatSpace(next.column - 1);\n } else {\n if (next.line === next.prev?.line) {\n space = repeatSpace(next.start - (next.prev?.end || 0));\n }\n }\n source += space + value;\n if (next) {\n next = next.next!;\n }\n }\n }\n\n return source;\n}\n\nexport function wrapFields(\n type: Maybe<GraphQLObjectType & OtelPatched>,\n getConfig: () => GraphQLInstrumentationParsedConfig,\n): void {\n if (!type || (type as any)[OTEL_PATCHED_SYMBOL]) {\n return;\n }\n const fields = type.getFields();\n\n (type as any)[OTEL_PATCHED_SYMBOL] = true;\n\n Object.keys(fields).forEach(key => {\n const field = fields[key];\n\n if (!field) {\n return;\n }\n\n if (field.resolve) {\n field.resolve = wrapFieldResolver(getConfig, field.resolve);\n }\n\n if (field.type) {\n const unwrappedTypes = unwrapType(field.type);\n for (const unwrappedType of unwrappedTypes) {\n wrapFields(unwrappedType as any, getConfig);\n }\n }\n });\n}\n\nfunction unwrapType(type: GraphQLOutputType): readonly GraphQLObjectType[] {\n // unwrap wrapping types (non-nullable and list types)\n if ('ofType' in type) {\n return unwrapType(type.ofType);\n }\n\n // unwrap union types\n if (isGraphQLUnionType(type)) {\n return type.getTypes();\n }\n\n // return object types\n if (isGraphQLObjectType(type)) {\n return [type];\n }\n\n return [];\n}\n\nfunction isGraphQLUnionType(type: GraphQLType): type is GraphQLUnionType {\n return 'getTypes' in type && typeof type.getTypes === 'function';\n}\n\nfunction isGraphQLObjectType(type: GraphQLType): type is GraphQLObjectType {\n return 'getFields' in type && typeof type.getFields === 'function';\n}\n\nconst handleResolveSpanError = (resolveSpan: Span, err: any, shouldEndSpan: boolean) => {\n if (!shouldEndSpan) {\n return;\n }\n resolveSpan.setStatus({\n code: SPAN_STATUS_ERROR,\n message: err.message,\n });\n resolveSpan.end();\n};\n\nconst handleResolveSpanSuccess = (resolveSpan: Span, shouldEndSpan: boolean) => {\n if (!shouldEndSpan) {\n return;\n }\n resolveSpan.end();\n};\n\nexport function wrapFieldResolver<TSource = any, TContext = any, TArgs = any>(\n getConfig: () => GraphQLInstrumentationParsedConfig,\n fieldResolver: Maybe<GraphQLFieldResolver<TSource, TContext, TArgs> & OtelPatched>,\n isDefaultResolver = false,\n): GraphQLFieldResolver<TSource, TContext & ObjectWithGraphQLData, TArgs> & OtelPatched {\n if ((wrappedFieldResolver as OtelPatched)[OTEL_PATCHED_SYMBOL] || typeof fieldResolver !== 'function') {\n return fieldResolver!;\n }\n\n function wrappedFieldResolver(\n this: GraphQLFieldResolver<TSource, TContext, TArgs>,\n source: TSource,\n args: TArgs,\n contextValue: TContext & ObjectWithGraphQLData,\n info: GraphQLResolveInfo,\n ) {\n if (!fieldResolver) {\n return undefined;\n }\n const config = getConfig();\n\n // follows what graphql is doing to decide if this is a trivial resolver\n // for which we don't need to create a resolve span\n if (\n config.ignoreTrivialResolveSpans &&\n isDefaultResolver &&\n (isObjectLike(source) || typeof source === 'function')\n ) {\n const property = (source as any)[info.fieldName];\n // a function execution is not trivial and should be recorder.\n // property which is not a function is just a value and we don't want a \"resolve\" span for it\n if (typeof property !== 'function') {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n }\n\n if (!contextValue[OTEL_GRAPHQL_DATA_SYMBOL]) {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n const path = pathToArray(info?.path);\n\n const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path);\n const span = field.span;\n const shouldEndSpan = spanAdded;\n\n return withActiveSpan(span, () => {\n try {\n const res = fieldResolver.call(this, source, args, contextValue, info);\n if (isPromise(res)) {\n return res.then(\n (r: any) => {\n handleResolveSpanSuccess(span, shouldEndSpan);\n return r;\n },\n (err: Error) => {\n handleResolveSpanError(span, err, shouldEndSpan);\n throw err;\n },\n );\n } else {\n handleResolveSpanSuccess(span, shouldEndSpan);\n return res;\n }\n } catch (err: any) {\n handleResolveSpanError(span, err, shouldEndSpan);\n throw err;\n }\n });\n }\n\n (wrappedFieldResolver as OtelPatched)[OTEL_PATCHED_SYMBOL] = true;\n\n return wrappedFieldResolver;\n}\n"],"names":["fieldNode"],"mappings":";;;;;AAgCA,MAAM,gBAAA,GAAmB,MAAA,CAAO,MAAA,CAAO,qBAAqB,CAAA;AAGrD,MAAM,SAAA,GAAY,CAAC,KAAA,KAA0C;AAClE,EAAA,OAAO,OAAO,OAAO,IAAA,KAAS,UAAA;AAChC;AAGA,MAAM,YAAA,GAAe,CAAC,KAAA,KAAwD;AAC5E,EAAA,OAAO,OAAO,KAAA,IAAS,QAAA,IAAY,KAAA,KAAU,IAAA;AAC/C,CAAA;AAEO,SAAS,aAAA,CAAc,IAAA,EAAY,GAAA,EAAgB,KAAA,EAAgB,GAAA,EAAoB;AAC5F,EAAA,MAAM,MAAA,GAAS,qBAAA,CAAsB,GAAA,EAAK,KAAA,EAAO,GAAG,CAAA;AACpD,EAAA,IAAA,CAAK,YAAA,CAAa,cAAA,CAAe,MAAA,EAAQ,MAAM,CAAA;AACjD;AA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A;AAC5E,IAAA,MAAM,OAAO,KAAA,CAAM,IAAA;AACnB,IAAA,MAAM,aAAA,GAAgB,SAAA;AAEtB,IAAA,OAAO,cAAA,CAAe,MAAM,MAAM;AAChC,MAAA,IAAI;AACF,QAAA,MAAM,MAAM,aAAA,CAAc,IAAA,CAAK,MAAM,MAAA,EAAQ,IAAA,EAAM,cAAc,IAAI,CAAA;AACrE,QAAA,IAAI,SAAA,CAAU,GAAG,CAAA,EAAG;AAClB,UAAA,OAAO,GAAA,CAAI,IAAA;AAAA,YACT,CAAC,CAAA,KAAW;AACV,cAAA,wBAAA,CAAyB,MAAM,aAAa,CAAA;AAC5C,cAAA,OAAO,CAAA;AAAA,YACT,CAAA;AAAA,YACA,CAAC,GAAA,KAAe;AACd,cAAA,sBAAA,CAAuB,IAAA,EAAM,KAAK,aAAa,CAAA;AAC/C,cAAA,MAAM,GAAA;AAAA,YACR;AAAA,WACF;AAAA,QACF,CAAA,MAAO;AACL,UAAA,wBAAA,CAAyB,MAAM,aAAa,CAAA;AAC5C,UAAA,OAAO,GAAA;AAAA,QACT;AAAA,MACF,SAAS,GAAA,EAAU;AACjB,QAAA,sBAAA,CAAuB,IAAA,EAAM,KAAK,aAAa,CAAA;AAC/C,QAAA,MAAM,GAAA;AAAA,MACR;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAEA,EAAC,oBAAA,CAAqC,mBAAmB,CAAA,GAAI,IAAA;AAE7D,EAAA,OAAO,oBAAA;AACT;;;;"} | ||
| {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/graphql/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-graphql\n * - Upstream version: @opentelemetry/instrumentation-graphql@0.66.0\n * - Types from `graphql` package inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments\n * - Span lifecycle migrated from the OpenTelemetry tracer to the @sentry/core span API\n */\n\nimport type {\n DocumentNode,\n GraphQLFieldResolver,\n GraphQLObjectType,\n GraphQLOutputType,\n GraphQLResolveInfo,\n GraphQLType,\n GraphQLUnionType,\n Location,\n Maybe,\n Token,\n} from './graphql-types';\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport { isObjectLike, SPAN_STATUS_ERROR, startInactiveSpan, withActiveSpan } from '@sentry/core';\nimport { AllowedOperationTypes, SpanNames, TokenKind } from './enum';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { OTEL_GRAPHQL_DATA_SYMBOL, OTEL_PATCHED_SYMBOL } from './symbols';\nimport type { GraphQLField, GraphQLPath, ObjectWithGraphQLData, OtelPatched } from './internal-types';\nimport type { GraphQLInstrumentationParsedConfig } from './types';\n\nconst OPERATION_VALUES = Object.values(AllowedOperationTypes);\n\n// https://github.com/graphql/graphql-js/blob/main/src/jsutils/isPromise.ts\nexport const isPromise = (value: any): value is Promise<unknown> => {\n return typeof value?.then === 'function';\n};\n\nexport function addSpanSource(span: Span, loc?: Location, start?: number, end?: number): void {\n const source = getSourceFromLocation(loc, start, end);\n span.setAttribute(AttributeNames.SOURCE, source);\n}\n\nfunction createFieldIfNotExists(\n contextValue: any,\n info: GraphQLResolveInfo,\n path: string[],\n): {\n field: GraphQLField;\n spanAdded: boolean;\n} {\n let field = getField(contextValue, path);\n if (field) {\n return { field, spanAdded: false };\n }\n\n const parentSpan = getParentFieldSpan(contextValue, path);\n\n field = {\n span: createResolverSpan(contextValue, info, path, parentSpan),\n };\n\n addField(contextValue, path, field);\n\n return { field, spanAdded: true };\n}\n\nfunction createResolverSpan(contextValue: any, info: GraphQLResolveInfo, path: string[], parentSpan?: Span): Span {\n const attributes: SpanAttributes = {\n [AttributeNames.FIELD_NAME]: info.fieldName,\n [AttributeNames.FIELD_PATH]: path.join('.'),\n [AttributeNames.FIELD_TYPE]: info.returnType.toString(),\n [AttributeNames.PARENT_NAME]: info.parentType.name,\n };\n\n const span = startInactiveSpan({\n name: `${SpanNames.RESOLVE} ${attributes[AttributeNames.FIELD_PATH]}`,\n attributes,\n parentSpan,\n });\n\n const document = contextValue[OTEL_GRAPHQL_DATA_SYMBOL].source;\n const fieldNode = info.fieldNodes.find(fieldNode => fieldNode.kind === 'Field');\n\n if (fieldNode) {\n addSpanSource(span, document.loc, fieldNode.loc?.start, fieldNode.loc?.end);\n }\n\n return span;\n}\n\nexport function endSpan(span: Span, error?: Error): void {\n if (error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n}\n\nexport function getOperation(document: DocumentNode, operationName?: Maybe<string>): DefinitionNodeLike | undefined {\n if (!document || !Array.isArray(document.definitions)) {\n return undefined;\n }\n\n if (operationName) {\n return document.definitions\n .filter(definition => OPERATION_VALUES.indexOf(definition?.operation) !== -1)\n .find(definition => operationName === definition?.name?.value);\n } else {\n return document.definitions.find(definition => OPERATION_VALUES.indexOf(definition?.operation) !== -1);\n }\n}\n\ntype DefinitionNodeLike = DocumentNode['definitions'][number];\n\nfunction addField(contextValue: any, path: string[], field: GraphQLField) {\n return (contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path.join('.')] = field);\n}\n\nfunction getField(contextValue: any, path: string[]): GraphQLField {\n return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].fields[path.join('.')];\n}\n\nfunction getParentFieldSpan(contextValue: any, path: string[]): Span {\n for (let i = path.length - 1; i > 0; i--) {\n const field = getField(contextValue, path.slice(0, i));\n\n if (field) {\n return field.span;\n }\n }\n\n return getRootSpan(contextValue);\n}\n\nfunction getRootSpan(contextValue: any): Span {\n return contextValue[OTEL_GRAPHQL_DATA_SYMBOL].span;\n}\n\nfunction pathToArray(path: GraphQLPath): string[] {\n const flattened: string[] = [];\n let curr: GraphQLPath | undefined = path;\n while (curr) {\n flattened.push(String(curr.key));\n curr = curr.prev;\n }\n return flattened.reverse();\n}\n\nfunction repeatBreak(i: number): string {\n return repeatChar('\\n', i);\n}\n\nfunction repeatSpace(i: number): string {\n return repeatChar(' ', i);\n}\n\nfunction repeatChar(char: string, to: number): string {\n let text = '';\n for (let i = 0; i < to; i++) {\n text += char;\n }\n return text;\n}\n\nconst KindsToBeRemoved: string[] = [TokenKind.FLOAT, TokenKind.STRING, TokenKind.INT, TokenKind.BLOCK_STRING];\n\nexport function getSourceFromLocation(loc?: Location, inputStart?: number, inputEnd?: number): string {\n let source = '';\n\n if (loc?.startToken) {\n const start = typeof inputStart === 'number' ? inputStart : loc.start;\n const end = typeof inputEnd === 'number' ? inputEnd : loc.end;\n\n let next: Token | null = loc.startToken.next;\n let previousLine: number | undefined = 1;\n while (next) {\n if (next.start < start) {\n next = next.next;\n previousLine = next?.line;\n continue;\n }\n if (next.end > end) {\n next = next.next;\n previousLine = next?.line;\n continue;\n }\n let value = next.value || next.kind;\n let space = '';\n if (KindsToBeRemoved.indexOf(next.kind) >= 0) {\n value = '*';\n }\n if (next.kind === TokenKind.STRING) {\n value = `\"${value}\"`;\n }\n if (next.kind === TokenKind.EOF) {\n value = '';\n }\n if (next.line > previousLine!) {\n source += repeatBreak(next.line - previousLine!);\n previousLine = next.line;\n space = repeatSpace(next.column - 1);\n } else {\n if (next.line === next.prev?.line) {\n space = repeatSpace(next.start - (next.prev?.end || 0));\n }\n }\n source += space + value;\n if (next) {\n next = next.next!;\n }\n }\n }\n\n return source;\n}\n\nexport function wrapFields(\n type: Maybe<GraphQLObjectType & OtelPatched>,\n getConfig: () => GraphQLInstrumentationParsedConfig,\n): void {\n if (!type || (type as any)[OTEL_PATCHED_SYMBOL]) {\n return;\n }\n const fields = type.getFields();\n\n (type as any)[OTEL_PATCHED_SYMBOL] = true;\n\n Object.keys(fields).forEach(key => {\n const field = fields[key];\n\n if (!field) {\n return;\n }\n\n if (field.resolve) {\n // The shared structural types narrow the resolver context to `ObjectWithGraphQLData`; cast back\n // to the field's own resolver type (behavior is unchanged — this is a type-only adjustment).\n field.resolve = wrapFieldResolver(getConfig, field.resolve) as GraphQLFieldResolver;\n }\n\n if (field.type) {\n const unwrappedTypes = unwrapType(field.type);\n for (const unwrappedType of unwrappedTypes) {\n wrapFields(unwrappedType as any, getConfig);\n }\n }\n });\n}\n\nfunction unwrapType(type: GraphQLOutputType): readonly GraphQLObjectType[] {\n // unwrap wrapping types (non-nullable and list types)\n if ('ofType' in type) {\n // The structural index signature widens `ofType` to `unknown`, so narrow it back explicitly.\n return unwrapType(type.ofType as GraphQLOutputType);\n }\n\n // unwrap union types\n if (isGraphQLUnionType(type)) {\n return type.getTypes();\n }\n\n // return object types\n if (isGraphQLObjectType(type)) {\n return [type];\n }\n\n return [];\n}\n\nfunction isGraphQLUnionType(type: GraphQLType): type is GraphQLUnionType {\n return 'getTypes' in type && typeof type.getTypes === 'function';\n}\n\nfunction isGraphQLObjectType(type: GraphQLType): type is GraphQLObjectType {\n return 'getFields' in type && typeof type.getFields === 'function';\n}\n\nconst handleResolveSpanError = (resolveSpan: Span, err: any, shouldEndSpan: boolean) => {\n if (!shouldEndSpan) {\n return;\n }\n resolveSpan.setStatus({\n code: SPAN_STATUS_ERROR,\n message: err.message,\n });\n resolveSpan.end();\n};\n\nconst handleResolveSpanSuccess = (resolveSpan: Span, shouldEndSpan: boolean) => {\n if (!shouldEndSpan) {\n return;\n }\n resolveSpan.end();\n};\n\nexport function wrapFieldResolver<TSource = any, TContext = any, TArgs = any>(\n getConfig: () => GraphQLInstrumentationParsedConfig,\n fieldResolver: Maybe<GraphQLFieldResolver<TSource, TContext, TArgs> & OtelPatched>,\n isDefaultResolver = false,\n): GraphQLFieldResolver<TSource, TContext & ObjectWithGraphQLData, TArgs> & OtelPatched {\n if ((wrappedFieldResolver as OtelPatched)[OTEL_PATCHED_SYMBOL] || typeof fieldResolver !== 'function') {\n return fieldResolver!;\n }\n\n function wrappedFieldResolver(\n this: GraphQLFieldResolver<TSource, TContext, TArgs>,\n source: TSource,\n args: TArgs,\n contextValue: TContext & ObjectWithGraphQLData,\n info: GraphQLResolveInfo,\n ) {\n if (!fieldResolver) {\n return undefined;\n }\n const config = getConfig();\n\n // follows what graphql is doing to decide if this is a trivial resolver\n // for which we don't need to create a resolve span\n if (\n config.ignoreTrivialResolveSpans &&\n isDefaultResolver &&\n (isObjectLike(source) || typeof source === 'function')\n ) {\n const property = (source as any)[info.fieldName];\n // a function execution is not trivial and should be recorder.\n // property which is not a function is just a value and we don't want a \"resolve\" span for it\n if (typeof property !== 'function') {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n }\n\n if (!contextValue[OTEL_GRAPHQL_DATA_SYMBOL]) {\n return fieldResolver.call(this, source, args, contextValue, info);\n }\n const path = pathToArray(info?.path);\n\n const { field, spanAdded } = createFieldIfNotExists(contextValue, info, path);\n const span = field.span;\n const shouldEndSpan = spanAdded;\n\n return withActiveSpan(span, () => {\n try {\n const res = fieldResolver.call(this, source, args, contextValue, info);\n if (isPromise(res)) {\n return res.then(\n (r: any) => {\n handleResolveSpanSuccess(span, shouldEndSpan);\n return r;\n },\n (err: Error) => {\n handleResolveSpanError(span, err, shouldEndSpan);\n throw err;\n },\n );\n } else {\n handleResolveSpanSuccess(span, shouldEndSpan);\n return res;\n }\n } catch (err: any) {\n handleResolveSpanError(span, err, shouldEndSpan);\n throw err;\n }\n });\n }\n\n (wrappedFieldResolver as OtelPatched)[OTEL_PATCHED_SYMBOL] = true;\n\n return wrappedFieldResolver;\n}\n"],"names":["fieldNode"],"mappings":";;;;;AAgCA,MAAM,gBAAA,GAAmB,MAAA,CAAO,MAAA,CAAO,qBAAqB,CAAA;AAGrD,MAAM,SAAA,GAAY,CAAC,KAAA,KAA0C;AAClE,EAAA,OAAO,OAAO,OAAO,IAAA,KAAS,UAAA;AAChC;AAEO,SAAS,aAAA,CAAc,IAAA,EAAY,GAAA,EAAgB,KAAA,EAAgB,GAAA,EAAoB;AAC5F,EAAA,MAAM,MAAA,GAAS,qBAAA,CAAsB,GAAA,EAAK,KAAA,EA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I,CAAA;AAEnC,IAAA,MAAM,EAAE,KAAA,EAAO,SAAA,KAAc,sBAAA,CAAuB,YAAA,EAAc,MAAM,IAAI,CAAA;AAC5E,IAAA,MAAM,OAAO,KAAA,CAAM,IAAA;AACnB,IAAA,MAAM,aAAA,GAAgB,SAAA;AAEtB,IAAA,OAAO,cAAA,CAAe,MAAM,MAAM;AAChC,MAAA,IAAI;AACF,QAAA,MAAM,MAAM,aAAA,CAAc,IAAA,CAAK,MAAM,MAAA,EAAQ,IAAA,EAAM,cAAc,IAAI,CAAA;AACrE,QAAA,IAAI,SAAA,CAAU,GAAG,CAAA,EAAG;AAClB,UAAA,OAAO,GAAA,CAAI,IAAA;AAAA,YACT,CAAC,CAAA,KAAW;AACV,cAAA,wBAAA,CAAyB,MAAM,aAAa,CAAA;AAC5C,cAAA,OAAO,CAAA;AAAA,YACT,CAAA;AAAA,YACA,CAAC,GAAA,KAAe;AACd,cAAA,sBAAA,CAAuB,IAAA,EAAM,KAAK,aAAa,CAAA;AAC/C,cAAA,MAAM,GAAA;AAAA,YACR;AAAA,WACF;AAAA,QACF,CAAA,MAAO;AACL,UAAA,wBAAA,CAAyB,MAAM,aAAa,CAAA;AAC5C,UAAA,OAAO,GAAA;AAAA,QACT;AAAA,MACF,SAAS,GAAA,EAAU;AACjB,QAAA,sBAAA,CAAuB,IAAA,EAAM,KAAK,aAAa,CAAA;AAC/C,QAAA,MAAM,GAAA;AAAA,MACR;AAAA,IACF,CAAC,CAAA;AAAA,EACH;AAEA,EAAC,oBAAA,CAAqC,mBAAmB,CAAA,GAAI,IAAA;AAE7D,EAAA,OAAO,oBAAA;AACT;;;;"} |
@@ -1,2 +0,2 @@ | ||
| import { getActiveSpan, startInactiveSpan, SPAN_KIND, SPAN_STATUS_ERROR, withActiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core'; | ||
| import { getActiveSpan, startInactiveSpan, SPAN_KIND, SPAN_STATUS_ERROR, withActiveSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, isObjectLike } from '@sentry/core'; | ||
| import { DB_OPERATION, NET_PEER_NAME, NET_PEER_PORT, DB_STATEMENT, DB_NAME, DB_SYSTEM } from '@sentry/conventions/attributes'; | ||
@@ -26,3 +26,3 @@ import { DB_SYSTEM_VALUE_MONGODB, ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION } from './semconv.js'; | ||
| function isCommandObj(value) { | ||
| return typeof value === "object" && value !== null && !isBuffer(value); | ||
| return isObjectLike(value) && !isBuffer(value); | ||
| } | ||
@@ -29,0 +29,0 @@ function isBuffer(value) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mongo/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongodb\n * - Upstream version: @opentelemetry/instrumentation-mongodb@0.71.0\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport {\n DB_NAME,\n DB_OPERATION,\n DB_STATEMENT,\n DB_SYSTEM,\n NET_PEER_NAME,\n NET_PEER_PORT,\n} from '@sentry/conventions/attributes';\nimport { ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION, DB_SYSTEM_VALUE_MONGODB } from './semconv';\nimport type { MongodbNamespace, MongoInternalCommand, MongoInternalTopology } from './internal-types';\nimport { MongodbCommandType } from './internal-types';\n\nconst ORIGIN = 'auto.db.otel.mongo';\n\n/**\n * Replaces values in the command object with '?', hiding PII and helping grouping.\n */\nfunction serializeDbStatement(commandObj: Record<string, unknown>): string {\n return JSON.stringify(scrubStatement(commandObj));\n}\n\nfunction scrubStatement(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(element => scrubStatement(element));\n }\n\n if (isCommandObj(value)) {\n const initial: Record<string, unknown> = {};\n return Object.entries(value)\n .map(([key, element]) => [key, scrubStatement(element)])\n .reduce((prev, current) => {\n if (isCommandEntry(current)) {\n prev[current[0]] = current[1];\n }\n return prev;\n }, initial);\n }\n\n // A value like string or number, possibly contains PII, scrub it\n return '?';\n}\n\nfunction isCommandObj(value: Record<string, unknown> | unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !isBuffer(value);\n}\n\nfunction isBuffer(value: unknown): boolean {\n return typeof Buffer !== 'undefined' && Buffer.isBuffer(value);\n}\n\nfunction isCommandEntry(value: [string, unknown] | unknown): value is [string, unknown] {\n return Array.isArray(value);\n}\n\n/**\n * Get the mongodb command type from the object.\n */\nexport function getCommandType(command: MongoInternalCommand): MongodbCommandType {\n if (command.createIndexes !== undefined) {\n return MongodbCommandType.CREATE_INDEXES;\n } else if (command.findandmodify !== undefined) {\n return MongodbCommandType.FIND_AND_MODIFY;\n } else if (command.ismaster !== undefined) {\n return MongodbCommandType.IS_MASTER;\n } else if (command.count !== undefined) {\n return MongodbCommandType.COUNT;\n } else if (command.aggregate !== undefined) {\n return MongodbCommandType.AGGREGATE;\n } else {\n return MongodbCommandType.UNKNOWN;\n }\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v4 connection context.\n */\nexport function getV4SpanAttributes(\n connectionCtx: any,\n ns: MongodbNamespace,\n command?: any,\n operation?: string,\n): SpanAttributes {\n let host, port: undefined | string;\n if (connectionCtx) {\n const hostParts = typeof connectionCtx.address === 'string' ? connectionCtx.address.split(':') : '';\n if (hostParts.length === 2) {\n host = hostParts[0];\n port = hostParts[1];\n }\n }\n let commandObj: Record<string, unknown>;\n if (command?.documents && command.documents[0]) {\n commandObj = command.documents[0];\n } else if (command?.cursors) {\n commandObj = command.cursors;\n } else {\n commandObj = command;\n }\n\n return getSpanAttributes(ns.db, ns.collection, host, port, commandObj, operation);\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v3 topology.\n */\nexport function getV3SpanAttributes(\n ns: string,\n topology: MongoInternalTopology,\n command?: MongoInternalCommand,\n operation?: string | undefined,\n): SpanAttributes {\n let host: undefined | string;\n let port: undefined | string;\n if (topology?.s) {\n host = topology.s.options?.host ?? topology.s.host;\n port = (topology.s.options?.port ?? topology.s.port)?.toString();\n if (host == null || port == null) {\n const address = topology.description?.address;\n if (address) {\n const addressSegments = address.split(':');\n host = addressSegments[0];\n port = addressSegments[1];\n }\n }\n }\n\n // The namespace is a combination of the database name and the name of the\n // collection or index, like so: [database-name].[collection-or-index-name].\n // It could be a string or an instance of MongoDBNamespace, as such we\n // always coerce to a string to extract db and collection.\n const [dbName, dbCollection] = ns.toString().split('.');\n const commandObj = command?.query ?? command?.q ?? command;\n\n return getSpanAttributes(dbName, dbCollection, host, port, commandObj, operation);\n}\n\nfunction getSpanAttributes(\n dbName?: string,\n dbCollection?: string,\n host?: undefined | string,\n port?: undefined | string,\n commandObj?: any,\n operation?: string | undefined,\n): SpanAttributes {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_NAME]: dbName,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_MONGODB_COLLECTION]: dbCollection,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_OPERATION]: operation,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,\n };\n\n if (host && port) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_NAME] = host;\n const portNumber = parseInt(port, 10);\n if (!isNaN(portNumber)) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_PORT] = portNumber;\n }\n }\n\n if (commandObj) {\n try {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[DB_STATEMENT] = serializeDbStatement(commandObj);\n } catch {\n // ignore serialization errors — the statement is best-effort metadata\n }\n }\n\n return attributes;\n}\n\nexport function startMongoSpan(attributes: SpanAttributes): Span {\n return startInactiveSpan({\n // eslint-disable-next-line typescript/no-deprecated\n name: `mongodb.${attributes[DB_OPERATION] || 'command'}`,\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n}\n\n/**\n * Wraps the result handler so it ends the span (with error status on failure) and runs the\n * original callback re-activated under the parent span — mongodb loses the async context when\n * it invokes the callback on a later tick.\n */\nexport function patchEnd(span: Span | undefined, resultHandler: Function): Function {\n const parentSpan = getActiveSpan();\n let spanEnded = false;\n\n return function patchedEnd(this: {}, ...args: unknown[]) {\n if (!spanEnded) {\n spanEnded = true;\n const error = args[0];\n if (span) {\n if (error instanceof Error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n }\n }\n\n return withActiveSpan(parentSpan ?? null, () => resultHandler.apply(this, args));\n };\n}\n\n// The instrumentation only creates spans when there is an active parent span, to avoid emitting\n// orphaned mongodb spans.\nexport function shouldSkipInstrumentation(): boolean {\n return !getActiveSpan();\n}\n"],"names":[],"mappings":";;;;;AA+BA,MAAM,MAAA,GAAS,oBAAA;AAKf,SAAS,qBAAqB,UAAA,EAA6C;AACzE,EAAA,OAAO,IAAA,CAAK,SAAA,CAAU,cAAA,CAAe,UAAU,CAAC,CAAA;AAClD;AAEA,SAAS,eAAe,KAAA,EAAyB;AAC/C,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,KAAA,CAAM,GAAA,CAAI,CAAA,OAAA,KAAW,cAAA,CAAe,OAAO,CAAC,CAAA;AAAA,E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CAAK,GAAA,EAAI;AAAA,MACX;AAAA,IACF;AAEA,IAAA,OAAO,cAAA,CAAe,cAAc,IAAA,EAAM,MAAM,cAAc,KAAA,CAAM,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,EACjF,CAAA;AACF;AAIO,SAAS,yBAAA,GAAqC;AACnD,EAAA,OAAO,CAAC,aAAA,EAAc;AACxB;;;;"} | ||
| {"version":3,"file":"utils.js","sources":["../../../../../../src/integrations/tracing/mongo/vendored/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mongodb\n * - Upstream version: @opentelemetry/instrumentation-mongodb@0.71.0\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n getActiveSpan,\n isObjectLike,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport {\n DB_NAME,\n DB_OPERATION,\n DB_STATEMENT,\n DB_SYSTEM,\n NET_PEER_NAME,\n NET_PEER_PORT,\n} from '@sentry/conventions/attributes';\nimport { ATTR_DB_CONNECTION_STRING, ATTR_DB_MONGODB_COLLECTION, DB_SYSTEM_VALUE_MONGODB } from './semconv';\nimport type { MongodbNamespace, MongoInternalCommand, MongoInternalTopology } from './internal-types';\nimport { MongodbCommandType } from './internal-types';\n\nconst ORIGIN = 'auto.db.otel.mongo';\n\n/**\n * Replaces values in the command object with '?', hiding PII and helping grouping.\n */\nfunction serializeDbStatement(commandObj: Record<string, unknown>): string {\n return JSON.stringify(scrubStatement(commandObj));\n}\n\nfunction scrubStatement(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(element => scrubStatement(element));\n }\n\n if (isCommandObj(value)) {\n const initial: Record<string, unknown> = {};\n return Object.entries(value)\n .map(([key, element]) => [key, scrubStatement(element)])\n .reduce((prev, current) => {\n if (isCommandEntry(current)) {\n prev[current[0]] = current[1];\n }\n return prev;\n }, initial);\n }\n\n // A value like string or number, possibly contains PII, scrub it\n return '?';\n}\n\nfunction isCommandObj(value: Record<string, unknown> | unknown): value is Record<string, unknown> {\n return isObjectLike(value) && !isBuffer(value);\n}\n\nfunction isBuffer(value: unknown): boolean {\n return typeof Buffer !== 'undefined' && Buffer.isBuffer(value);\n}\n\nfunction isCommandEntry(value: [string, unknown] | unknown): value is [string, unknown] {\n return Array.isArray(value);\n}\n\n/**\n * Get the mongodb command type from the object.\n */\nexport function getCommandType(command: MongoInternalCommand): MongodbCommandType {\n if (command.createIndexes !== undefined) {\n return MongodbCommandType.CREATE_INDEXES;\n } else if (command.findandmodify !== undefined) {\n return MongodbCommandType.FIND_AND_MODIFY;\n } else if (command.ismaster !== undefined) {\n return MongodbCommandType.IS_MASTER;\n } else if (command.count !== undefined) {\n return MongodbCommandType.COUNT;\n } else if (command.aggregate !== undefined) {\n return MongodbCommandType.AGGREGATE;\n } else {\n return MongodbCommandType.UNKNOWN;\n }\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v4 connection context.\n */\nexport function getV4SpanAttributes(\n connectionCtx: any,\n ns: MongodbNamespace,\n command?: any,\n operation?: string,\n): SpanAttributes {\n let host, port: undefined | string;\n if (connectionCtx) {\n const hostParts = typeof connectionCtx.address === 'string' ? connectionCtx.address.split(':') : '';\n if (hostParts.length === 2) {\n host = hostParts[0];\n port = hostParts[1];\n }\n }\n let commandObj: Record<string, unknown>;\n if (command?.documents && command.documents[0]) {\n commandObj = command.documents[0];\n } else if (command?.cursors) {\n commandObj = command.cursors;\n } else {\n commandObj = command;\n }\n\n return getSpanAttributes(ns.db, ns.collection, host, port, commandObj, operation);\n}\n\n/**\n * Determine a span's attributes by fetching related metadata from the v3 topology.\n */\nexport function getV3SpanAttributes(\n ns: string,\n topology: MongoInternalTopology,\n command?: MongoInternalCommand,\n operation?: string | undefined,\n): SpanAttributes {\n let host: undefined | string;\n let port: undefined | string;\n if (topology?.s) {\n host = topology.s.options?.host ?? topology.s.host;\n port = (topology.s.options?.port ?? topology.s.port)?.toString();\n if (host == null || port == null) {\n const address = topology.description?.address;\n if (address) {\n const addressSegments = address.split(':');\n host = addressSegments[0];\n port = addressSegments[1];\n }\n }\n }\n\n // The namespace is a combination of the database name and the name of the\n // collection or index, like so: [database-name].[collection-or-index-name].\n // It could be a string or an instance of MongoDBNamespace, as such we\n // always coerce to a string to extract db and collection.\n const [dbName, dbCollection] = ns.toString().split('.');\n const commandObj = command?.query ?? command?.q ?? command;\n\n return getSpanAttributes(dbName, dbCollection, host, port, commandObj, operation);\n}\n\nfunction getSpanAttributes(\n dbName?: string,\n dbCollection?: string,\n host?: undefined | string,\n port?: undefined | string,\n commandObj?: any,\n operation?: string | undefined,\n): SpanAttributes {\n const attributes: SpanAttributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MONGODB,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_NAME]: dbName,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_MONGODB_COLLECTION]: dbCollection,\n // eslint-disable-next-line typescript/no-deprecated\n [DB_OPERATION]: operation,\n // eslint-disable-next-line typescript/no-deprecated\n [ATTR_DB_CONNECTION_STRING]: `mongodb://${host}:${port}/${dbName}`,\n };\n\n if (host && port) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_NAME] = host;\n const portNumber = parseInt(port, 10);\n if (!isNaN(portNumber)) {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[NET_PEER_PORT] = portNumber;\n }\n }\n\n if (commandObj) {\n try {\n // eslint-disable-next-line typescript/no-deprecated\n attributes[DB_STATEMENT] = serializeDbStatement(commandObj);\n } catch {\n // ignore serialization errors — the statement is best-effort metadata\n }\n }\n\n return attributes;\n}\n\nexport function startMongoSpan(attributes: SpanAttributes): Span {\n return startInactiveSpan({\n // eslint-disable-next-line typescript/no-deprecated\n name: `mongodb.${attributes[DB_OPERATION] || 'command'}`,\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n}\n\n/**\n * Wraps the result handler so it ends the span (with error status on failure) and runs the\n * original callback re-activated under the parent span — mongodb loses the async context when\n * it invokes the callback on a later tick.\n */\nexport function patchEnd(span: Span | undefined, resultHandler: Function): Function {\n const parentSpan = getActiveSpan();\n let spanEnded = false;\n\n return function patchedEnd(this: {}, ...args: unknown[]) {\n if (!spanEnded) {\n spanEnded = true;\n const error = args[0];\n if (span) {\n if (error instanceof Error) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });\n }\n span.end();\n }\n }\n\n return withActiveSpan(parentSpan ?? null, () => resultHandler.apply(this, args));\n };\n}\n\n// The instrumentation only creates spans when there is an active parent span, to avoid emitting\n// orphaned mongodb spans.\nexport function shouldSkipInstrumentation(): boolean {\n return !getActiveSpan();\n}\n"],"names":[],"mappings":";;;;;AAgCA,MAAM,MAAA,GAAS,oBAAA;AAKf,SAAS,qBAAqB,UAAA,EAA6C;AACzE,EAAA,OAAO,IAAA,CAAK,SAAA,CAAU,cAAA,CAAe,UAAU,CAAC,CAAA;AAClD;AAEA,SAAS,eAAe,KAAA,EAAyB;AAC/C,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,KAAA,CAAM,GAAA,CAAI,CAAA,OAAA,KAAW,cAAA,CAAe,OAAO,CAAC,CAAA;AAAA,EACrD;AAEA,EAAA,IAAI,YAAA,CAAa,KAAK,CAAA,EAAG;AACvB,IAAA,MAAM,UAAmC,EAAC;AAC1C,IAAA,OAAO,MAAA,CAAO,QAAQ,KAAK,CAAA,CACxB,IAAI,CAAC,CAAC,KAA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AA,GAAqC;AACnD,EAAA,OAAO,CAAC,aAAA,EAAc;AACxB;;;;"} |
| import { MySQL2Instrumentation } from './vendored/instrumentation.js'; | ||
| import { defineIntegration } from '@sentry/core'; | ||
| import { defineIntegration, extendIntegration } from '@sentry/core'; | ||
| import { generateInstrumentOnce } from '@sentry/node-core'; | ||
| import { mysql2Integration as mysql2Integration$1 } from '@sentry/server-utils'; | ||
@@ -8,3 +9,3 @@ const INTEGRATION_NAME = "Mysql2"; | ||
| const _mysql2Integration = (() => { | ||
| return { | ||
| return extendIntegration(mysql2Integration$1(), { | ||
| name: INTEGRATION_NAME, | ||
@@ -14,3 +15,3 @@ setupOnce() { | ||
| } | ||
| }; | ||
| }); | ||
| }); | ||
@@ -17,0 +18,0 @@ const mysql2Integration = defineIntegration(_mysql2Integration); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/mysql2/index.ts"],"sourcesContent":["import { MySQL2Instrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\n\nconst INTEGRATION_NAME = 'Mysql2' as const;\n\nexport const instrumentMysql2 = generateInstrumentOnce(INTEGRATION_NAME, () => new MySQL2Instrumentation());\n\nconst _mysql2Integration = (() => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentMysql2();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.\n *\n * For more information, see the [`mysql2Integration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.mysqlIntegration()],\n * });\n * ```\n */\nexport const mysql2Integration = defineIntegration(_mysql2Integration);\n"],"names":[],"mappings":";;;;AAKA,MAAM,gBAAA,GAAmB,QAAA;AAElB,MAAM,mBAAmB,sBAAA,CAAuB,gBAAA,EAAkB,MAAM,IAAI,uBAAuB;AAE1G,MAAM,sBAAsB,MAAM;AAChC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,gBAAA,EAAiB;AAAA,IACnB;AAAA,GACF;AACF,CAAA,CAAA;AAgBO,MAAM,iBAAA,GAAoB,kBAAkB,kBAAkB;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/mysql2/index.ts"],"sourcesContent":["import { MySQL2Instrumentation } from './vendored/instrumentation';\nimport type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, extendIntegration } from '@sentry/core';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { mysql2Integration as mysql2ChannelIntegration } from '@sentry/server-utils';\n\nconst INTEGRATION_NAME = 'Mysql2' as const;\n\nexport const instrumentMysql2 = generateInstrumentOnce(INTEGRATION_NAME, () => new MySQL2Instrumentation());\n\nconst _mysql2Integration = (() => {\n // The diagnostics_channel subscription (mysql2 >= 3.20.0) lives in server-utils so it is shared\n // across server runtimes; we extend it here to also run the vendored OTel patcher for mysql2 < 3.20.0.\n return extendIntegration(mysql2ChannelIntegration(), {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentMysql2();\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [mysql2](https://www.npmjs.com/package/mysql2) library.\n *\n * For more information, see the [`mysql2Integration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/mysql2/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.mysqlIntegration()],\n * });\n * ```\n */\nexport const mysql2Integration = defineIntegration(_mysql2Integration);\n"],"names":["mysql2ChannelIntegration"],"mappings":";;;;;AAMA,MAAM,gBAAA,GAAmB,QAAA;AAElB,MAAM,mBAAmB,sBAAA,CAAuB,gBAAA,EAAkB,MAAM,IAAI,uBAAuB;AAE1G,MAAM,sBAAsB,MAAM;AAGhC,EAAA,OAAO,iBAAA,CAAkBA,qBAAyB,EAAG;AAAA,IACnD,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,gBAAA,EAAiB;AAAA,IACnB;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAgBO,MAAM,iBAAA,GAAoB,kBAAkB,kBAAkB;;;;"} |
@@ -10,3 +10,3 @@ import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation'; | ||
| const ORIGIN = "auto.db.otel.mysql2"; | ||
| const supportedVersions = [">=1.4.2 <4"]; | ||
| const supportedVersions = [">=1.4.2 <3.20.0"]; | ||
| class MySQL2Instrumentation extends InstrumentationBase { | ||
@@ -13,0 +13,0 @@ constructor(config = {}) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/mysql2/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mysql2\n * - Upstream version: @opentelemetry/instrumentation-mysql2@0.64.0\n * - Types from 'mysql2' inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport { DB_STATEMENT, DB_SYSTEM } from '@sentry/conventions/attributes';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n} from '@sentry/core';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport type { Connection, FormatFunction, Query, QueryError, QueryOptions } from './mysql2-types';\nimport { DB_SYSTEM_VALUE_MYSQL } from './semconv';\nimport { getConnectionAttributes, getConnectionPrototypeToInstrument, getQueryText, getSpanName, once } from './utils';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-mysql2';\nconst ORIGIN = 'auto.db.otel.mysql2';\n\nconst supportedVersions = ['>=1.4.2 <4'];\n\n// The raw imported `mysql2` module exposes the `format` helper used to render\n// parameterized queries. Typed shallowly since it is only read internally.\ntype MySQL2Module = { format?: FormatFunction; [key: string]: unknown };\n\nexport class MySQL2Instrumentation extends InstrumentationBase<InstrumentationConfig> {\n public constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init(): InstrumentationNodeModuleDefinition[] {\n let format: FormatFunction | undefined;\n function setFormatFunction(moduleExports: MySQL2Module): void {\n if (!format && moduleExports.format) {\n format = moduleExports.format;\n }\n }\n const patch = (ConnectionPrototype: Connection): void => {\n if (isWrapped(ConnectionPrototype.query)) {\n this._unwrap(ConnectionPrototype, 'query');\n }\n this._wrap(ConnectionPrototype, 'query', this._patchQuery(format) as any);\n if (isWrapped(ConnectionPrototype.execute)) {\n this._unwrap(ConnectionPrototype, 'execute');\n }\n this._wrap(ConnectionPrototype, 'execute', this._patchQuery(format) as any);\n };\n const unpatch = (ConnectionPrototype: Connection): void => {\n this._unwrap(ConnectionPrototype, 'query');\n this._unwrap(ConnectionPrototype, 'execute');\n };\n return [\n new InstrumentationNodeModuleDefinition(\n 'mysql2',\n supportedVersions,\n (moduleExports: MySQL2Module) => {\n setFormatFunction(moduleExports);\n return moduleExports;\n },\n () => {},\n [\n new InstrumentationNodeModuleFile(\n 'mysql2/promise.js',\n supportedVersions,\n (moduleExports: MySQL2Module) => {\n setFormatFunction(moduleExports);\n return moduleExports;\n },\n () => {},\n ),\n new InstrumentationNodeModuleFile(\n 'mysql2/lib/connection.js',\n supportedVersions,\n (moduleExports: any) => {\n const ConnectionPrototype: Connection = getConnectionPrototypeToInstrument(moduleExports);\n patch(ConnectionPrototype);\n return moduleExports;\n },\n (moduleExports: any) => {\n if (moduleExports === undefined) return;\n const ConnectionPrototype: Connection = getConnectionPrototypeToInstrument(moduleExports);\n unpatch(ConnectionPrototype);\n },\n ),\n ],\n ),\n ];\n }\n\n private _patchQuery(format: FormatFunction | undefined) {\n const thisPlugin = this;\n return (originalQuery: Function): Function => {\n return function query(\n this: Connection,\n query: string | Query | QueryOptions,\n _valuesOrCallback?: unknown[] | Function,\n _callback?: Function,\n ) {\n let values;\n if (Array.isArray(_valuesOrCallback)) {\n values = _valuesOrCallback;\n } else if (arguments[2]) {\n values = [_valuesOrCallback];\n }\n\n const attributes: SpanAttributes = {\n ...getConnectionAttributes(this.config),\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MYSQL,\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_STATEMENT]: getQueryText(query, format, values),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n\n const span = startInactiveSpan({\n name: getSpanName(query),\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n\n const endSpan = once((err?: QueryError | null) => {\n if (err) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err.message });\n }\n span.end();\n });\n\n if (arguments.length === 1) {\n if (typeof (query as any).onResult === 'function') {\n thisPlugin._wrap(query as any, 'onResult', thisPlugin._patchCallbackQuery(endSpan));\n }\n\n const streamableQuery: Query = originalQuery.apply(this, arguments);\n\n streamableQuery\n .once('error', (err: any) => {\n endSpan(err);\n })\n .once('result', () => {\n endSpan();\n });\n\n return streamableQuery;\n }\n\n if (typeof arguments[1] === 'function') {\n thisPlugin._wrap(arguments, 1, thisPlugin._patchCallbackQuery(endSpan));\n } else if (typeof arguments[2] === 'function') {\n thisPlugin._wrap(arguments, 2, thisPlugin._patchCallbackQuery(endSpan));\n }\n\n return originalQuery.apply(this, arguments);\n };\n };\n }\n\n private _patchCallbackQuery(endSpan: (err?: QueryError | null) => void) {\n return (originalCallback: Function) => {\n return function (...args: [err: QueryError | null, ...rest: unknown[]]) {\n endSpan(args[0]);\n return originalCallback(...args);\n };\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;AA4BA,MAAM,YAAA,GAAe,gCAAA;AACrB,MAAM,MAAA,GAAS,qBAAA;AAEf,MAAM,iBAAA,GAAoB,CAAC,YAAY,CAAA;AAMhC,MAAM,8BAA8B,mBAAA,CAA2C;AAAA,EAC7E,WAAA,CAAY,MAAA,GAAgC,EAAC,EAAG;AACrD,IAAA,KAAA,CAAM,YAAA,EAAc,aAAa,MAAM,CAAA;AAAA,EACzC;AAAA,EAEU,IAAA,GAA8C;AACtD,IAAA,IAAI,MAAA;AACJ,IAAA,SAAS,kBAAkB,aAAA,EAAmC;AAC5D,MAAA,IAAI,CAAC,MAAA,IAAU,aAAA,CAAc,MAAA,EAAQ;AACnC,QAAA,MAAA,GAAS,aAAA,CAAc,MAAA;AAAA,MACzB;AAAA,IACF;AACA,IAAA,MAAM,KAAA,GAAQ,CAAC,mBAAA,KAA0C;AACvD,MAAA,IAAI,SAAA,CAAU,mBAAA,CAAoB,KAAK,CAAA,EAAG;AACxC,QAAA,IAAA,CAAK,OAAA,CAAQ,qBAAqB,OAAO,CAAA;AAAA,MAC3C;AACA,MAAA,IAAA,CAAK,MAAM,mBAAA,EAAqB,OAAA,EAAS,IAAA,CAAK,WAAA,CAAY,MAAM,CAAQ,CAAA;AACxE,MAAA,IAAI,SAAA,CAAU,mBAAA,CAAoB,OAAO,CAAA,EAAG;AAC1C,QAAA,IAAA,CAAK,OAAA,CAAQ,qBAAqB,SAAS,CAAA;AAAA,MAC7C;AACA,MAAA,IAAA,CAAK,MAAM,mBAAA,EAAqB,SAAA,EAAW,IAAA,CAAK,WAA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AAS,CAAA;AAElE,UAAA,eAAA,CACG,IAAA,CAAK,OAAA,EAAS,CAAC,GAAA,KAAa;AAC3B,YAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,UACb,CAAC,CAAA,CACA,IAAA,CAAK,QAAA,EAAU,MAAM;AACpB,YAAA,OAAA,EAAQ;AAAA,UACV,CAAC,CAAA;AAEH,UAAA,OAAO,eAAA;AAAA,QACT;AAEA,QAAA,IAAI,OAAO,SAAA,CAAU,CAAC,CAAA,KAAM,UAAA,EAAY;AACtC,UAAA,UAAA,CAAW,MAAM,SAAA,EAAW,CAAA,EAAG,UAAA,CAAW,mBAAA,CAAoB,OAAO,CAAC,CAAA;AAAA,QACxE,CAAA,MAAA,IAAW,OAAO,SAAA,CAAU,CAAC,MAAM,UAAA,EAAY;AAC7C,UAAA,UAAA,CAAW,MAAM,SAAA,EAAW,CAAA,EAAG,UAAA,CAAW,mBAAA,CAAoB,OAAO,CAAC,CAAA;AAAA,QACxE;AAEA,QAAA,OAAO,aAAA,CAAc,KAAA,CAAM,IAAA,EAAM,SAAS,CAAA;AAAA,MAC5C,CAAA;AAAA,IACF,CAAA;AAAA,EACF;AAAA,EAEQ,oBAAoB,OAAA,EAA4C;AACtE,IAAA,OAAO,CAAC,gBAAA,KAA+B;AACrC,MAAA,OAAO,YAAa,IAAA,EAAoD;AACtE,QAAA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,gBAAA,CAAiB,GAAG,IAAI,CAAA;AAAA,MACjC,CAAA;AAAA,IACF,CAAA;AAAA,EACF;AACF;;;;"} | ||
| {"version":3,"file":"instrumentation.js","sources":["../../../../../../src/integrations/tracing/mysql2/vendored/instrumentation.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n *\n * NOTICE from the Sentry authors:\n * - Vendored from: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/15ef7506553f631ea4181391e0c5725a56f0d082/packages/instrumentation-mysql2\n * - Upstream version: @opentelemetry/instrumentation-mysql2@0.64.0\n * - Types from 'mysql2' inlined as simplified interfaces\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n */\n\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';\nimport { DB_STATEMENT, DB_SYSTEM } from '@sentry/conventions/attributes';\nimport type { SpanAttributes } from '@sentry/core';\nimport {\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SPAN_KIND,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n} from '@sentry/core';\nimport { InstrumentationNodeModuleFile } from '../../InstrumentationNodeModuleFile';\nimport type { Connection, FormatFunction, Query, QueryError, QueryOptions } from './mysql2-types';\nimport { DB_SYSTEM_VALUE_MYSQL } from './semconv';\nimport { getConnectionAttributes, getConnectionPrototypeToInstrument, getQueryText, getSpanName, once } from './utils';\n\nconst PACKAGE_NAME = '@sentry/instrumentation-mysql2';\nconst ORIGIN = 'auto.db.otel.mysql2';\n\n// mysql2 >= 3.20.0 publishes via diagnostics_channel and is instrumented by\n// `subscribeMysql2DiagnosticChannels` instead, so this IITM patcher must not\n// overlap it — otherwise every query would emit two mysql2 spans.\nconst supportedVersions = ['>=1.4.2 <3.20.0'];\n\n// The raw imported `mysql2` module exposes the `format` helper used to render\n// parameterized queries. Typed shallowly since it is only read internally.\ntype MySQL2Module = { format?: FormatFunction; [key: string]: unknown };\n\nexport class MySQL2Instrumentation extends InstrumentationBase<InstrumentationConfig> {\n public constructor(config: InstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n protected init(): InstrumentationNodeModuleDefinition[] {\n let format: FormatFunction | undefined;\n function setFormatFunction(moduleExports: MySQL2Module): void {\n if (!format && moduleExports.format) {\n format = moduleExports.format;\n }\n }\n const patch = (ConnectionPrototype: Connection): void => {\n if (isWrapped(ConnectionPrototype.query)) {\n this._unwrap(ConnectionPrototype, 'query');\n }\n this._wrap(ConnectionPrototype, 'query', this._patchQuery(format) as any);\n if (isWrapped(ConnectionPrototype.execute)) {\n this._unwrap(ConnectionPrototype, 'execute');\n }\n this._wrap(ConnectionPrototype, 'execute', this._patchQuery(format) as any);\n };\n const unpatch = (ConnectionPrototype: Connection): void => {\n this._unwrap(ConnectionPrototype, 'query');\n this._unwrap(ConnectionPrototype, 'execute');\n };\n return [\n new InstrumentationNodeModuleDefinition(\n 'mysql2',\n supportedVersions,\n (moduleExports: MySQL2Module) => {\n setFormatFunction(moduleExports);\n return moduleExports;\n },\n () => {},\n [\n new InstrumentationNodeModuleFile(\n 'mysql2/promise.js',\n supportedVersions,\n (moduleExports: MySQL2Module) => {\n setFormatFunction(moduleExports);\n return moduleExports;\n },\n () => {},\n ),\n new InstrumentationNodeModuleFile(\n 'mysql2/lib/connection.js',\n supportedVersions,\n (moduleExports: any) => {\n const ConnectionPrototype: Connection = getConnectionPrototypeToInstrument(moduleExports);\n patch(ConnectionPrototype);\n return moduleExports;\n },\n (moduleExports: any) => {\n if (moduleExports === undefined) return;\n const ConnectionPrototype: Connection = getConnectionPrototypeToInstrument(moduleExports);\n unpatch(ConnectionPrototype);\n },\n ),\n ],\n ),\n ];\n }\n\n private _patchQuery(format: FormatFunction | undefined) {\n const thisPlugin = this;\n return (originalQuery: Function): Function => {\n return function query(\n this: Connection,\n query: string | Query | QueryOptions,\n _valuesOrCallback?: unknown[] | Function,\n _callback?: Function,\n ) {\n let values;\n if (Array.isArray(_valuesOrCallback)) {\n values = _valuesOrCallback;\n } else if (arguments[2]) {\n values = [_valuesOrCallback];\n }\n\n const attributes: SpanAttributes = {\n ...getConnectionAttributes(this.config),\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_SYSTEM]: DB_SYSTEM_VALUE_MYSQL,\n // oxlint-disable-next-line typescript/no-deprecated\n [DB_STATEMENT]: getQueryText(query, format, values),\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,\n };\n\n const span = startInactiveSpan({\n name: getSpanName(query),\n kind: SPAN_KIND.CLIENT,\n attributes,\n });\n\n const endSpan = once((err?: QueryError | null) => {\n if (err) {\n span.setStatus({ code: SPAN_STATUS_ERROR, message: err.message });\n }\n span.end();\n });\n\n if (arguments.length === 1) {\n if (typeof (query as any).onResult === 'function') {\n thisPlugin._wrap(query as any, 'onResult', thisPlugin._patchCallbackQuery(endSpan));\n }\n\n const streamableQuery: Query = originalQuery.apply(this, arguments);\n\n streamableQuery\n .once('error', (err: any) => {\n endSpan(err);\n })\n .once('result', () => {\n endSpan();\n });\n\n return streamableQuery;\n }\n\n if (typeof arguments[1] === 'function') {\n thisPlugin._wrap(arguments, 1, thisPlugin._patchCallbackQuery(endSpan));\n } else if (typeof arguments[2] === 'function') {\n thisPlugin._wrap(arguments, 2, thisPlugin._patchCallbackQuery(endSpan));\n }\n\n return originalQuery.apply(this, arguments);\n };\n };\n }\n\n private _patchCallbackQuery(endSpan: (err?: QueryError | null) => void) {\n return (originalCallback: Function) => {\n return function (...args: [err: QueryError | null, ...rest: unknown[]]) {\n endSpan(args[0]);\n return originalCallback(...args);\n };\n };\n }\n}\n"],"names":[],"mappings":";;;;;;;AA4BA,MAAM,YAAA,GAAe,gCAAA;AACrB,MAAM,MAAA,GAAS,qBAAA;AAKf,MAAM,iBAAA,GAAoB,CAAC,iBAAiB,CAAA;AAMrC,MAAM,8BAA8B,mBAAA,CAA2C;AAAA,EAC7E,WAAA,CAAY,MAAA,GAAgC,EAAC,EAAG;AACrD,IAAA,KAAA,CAAM,YAAA,EAAc,aAAa,MAAM,CAAA;AAAA,EACzC;AAAA,EAEU,IAAA,GAA8C;AACtD,IAAA,IAAI,MAAA;AACJ,IAAA,SAAS,kBAAkB,aAAA,EAAmC;AAC5D,MAAA,IAAI,CAAC,MAAA,IAAU,aAAA,CAAc,MAAA,EAAQ;AACn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,CAAA;AAAA,IACF,CAAA;AAAA,EACF;AAAA,EAEQ,oBAAoB,OAAA,EAA4C;AACtE,IAAA,OAAO,CAAC,gBAAA,KAA+B;AACrC,MAAA,OAAO,YAAa,IAAA,EAAoD;AACtE,QAAA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAC,CAAA;AACf,QAAA,OAAO,gBAAA,CAAiB,GAAG,IAAI,CAAA;AAAA,MACjC,CAAA;AAAA,IACF,CAAA;AAAA,EACF;AACF;;;;"} |
@@ -1,4 +0,4 @@ | ||
| import { waitForTracingChannelBinding, defineIntegration } from '@sentry/core'; | ||
| import { defineIntegration, extendIntegration } from '@sentry/core'; | ||
| import * as dc from 'node:diagnostics_channel'; | ||
| import { subscribeRedisDiagnosticChannels } from '@sentry/server-utils'; | ||
| import { redisIntegration as redisIntegration$1 } from '@sentry/server-utils'; | ||
| import { generateInstrumentOnce } from '@sentry/node-core'; | ||
@@ -26,9 +26,4 @@ import { isDiagnosticsChannelInjectionEnabled } from '../../../sdk/diagnosticsChannelInjection.js'; | ||
| instrumentIORedis(); | ||
| instrumentRedisModule(); | ||
| } | ||
| instrumentRedisModule(); | ||
| if (dc.tracingChannel) { | ||
| waitForTracingChannelBinding(() => { | ||
| subscribeRedisDiagnosticChannels(dc.tracingChannel, cacheResponseHook); | ||
| }); | ||
| } | ||
| }, | ||
@@ -38,3 +33,3 @@ { id: INTEGRATION_NAME } | ||
| const _redisIntegration = ((options = {}) => { | ||
| return { | ||
| return extendIntegration(redisIntegration$1({ responseHook: cacheResponseHook }), { | ||
| name: INTEGRATION_NAME, | ||
@@ -45,3 +40,3 @@ setupOnce() { | ||
| } | ||
| }; | ||
| }); | ||
| }); | ||
@@ -48,0 +43,0 @@ const redisIntegration = defineIntegration(_redisIntegration); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/redis/index.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, waitForTracingChannelBinding } from '@sentry/core';\nimport * as dc from 'node:diagnostics_channel';\nimport { subscribeRedisDiagnosticChannels, type RedisTracingChannelFactory } from '@sentry/server-utils';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { isDiagnosticsChannelInjectionEnabled } from '../../../sdk/diagnosticsChannelInjection';\nimport { cacheResponseHook, type RedisOptions, setRedisOptions } from './cache';\nimport { IORedisInstrumentation } from './vendored/ioredis-instrumentation';\nimport { RedisInstrumentation } from './vendored/redis-instrumentation';\n\n// `cacheResponseHook`/`_redisOptions` live in `./cache` (which has no OTel\n// instrumentation imports) so the orchestrion opt-in can pull the hook without\n// dragging the OTel redis instrumentation in. Re-exported here for tests.\nexport { _redisOptions, cacheResponseHook } from './cache';\n\nconst INTEGRATION_NAME = 'Redis' as const;\n\nconst instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME}.IORedis`, () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME}.Redis`, () => {\n return new RedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\n/**\n * To be able to preload all Redis OTel instrumentations with just one ID\n * (\"Redis\"), all the instrumentations are generated in this one function\n */\nexport const instrumentRedis = Object.assign(\n (): void => {\n // When diagnostics-channel injection is opted in, orchestrion owns ioredis\n // `<5.11.0`, so skip the OTel ioredis monkey-patch to avoid double instrumentation.\n // On Node without `tracingChannel` (<18.19) orchestrion can't run, so keep the\n // OTel patch there — otherwise ioredis `<5.11.0` would not be traced at all.\n if (!isDiagnosticsChannelInjectionEnabled() || !dc.tracingChannel) {\n instrumentIORedis();\n }\n instrumentRedisModule();\n // node-redis >= 5.12.0 and ioredis >= 5.11.0 publish via diagnostics_channel.\n // `bindTracingChannelToSpan` (inside the subscriber) makes the span the active\n // OTel context via `bindStore`, which needs the Sentry OTel context manager to\n // be registered — `initOpenTelemetry()` does that after integration `setupOnce`,\n // so defer to the next tick.\n // Check this here to ensure this does not fail at runtime for Node <= 18.18.0\n if (dc.tracingChannel) {\n waitForTracingChannelBinding(() => {\n subscribeRedisDiagnosticChannels(dc.tracingChannel as RedisTracingChannelFactory, cacheResponseHook);\n });\n }\n\n // todo: implement them gradually\n // new LegacyRedisInstrumentation({}),\n },\n { id: INTEGRATION_NAME },\n);\n\nconst _redisIntegration = ((options: RedisOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n setRedisOptions(options);\n instrumentRedis();\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries.\n *\n * For more information, see the [`redisIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.redisIntegration()],\n * });\n * ```\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":[],"mappings":";;;;;;;;;;AAeA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,iBAAA,GAAoB,sBAAA,CAAuB,CAAA,EAAG,gBAAgB,YAAY,MAAM;AACpF,EAAA,OAAO,IAAI,sBAAA,CAAuB;AAAA,IAChC,YAAA,EAAc;AAAA,GACf,CAAA;AACH,CAAC,CAAA;AAED,MAAM,qBAAA,GAAwB,sBAAA,CAAuB,CAAA,EAAG,gBAAgB,UAAU,MAAM;AACtF,EAAA,OAAO,IAAI,oBAAA,CAAqB;AAAA,IAC9B,YAAA,EAAc;AAAA,GACf,CAAA;AACH,CAAC,CAAA;AAMM,MAAM,kBAAkB,MAAA,CAAO,MAAA;AAAA,EACpC,MAAY;AAKV,IAAA,IAAI,CAAC,oCAAA,EAAqC,IAAK,CAAC,GAAG,cAAA,EAAgB;AACjE,MAAA,iBAAA,EAAkB;AAAA,IACpB;AACA,IAAA,qBAAA,EAAsB;AAOtB,IAAA,IAAI,GAAG,cAAA,EAAgB;AACrB,MAAA,4BAAA,CAA6B,MAAM;AACjC,QAAA,gCAAA,CAAiC,EAAA,CAAG,gBAA8C,iBAAiB,CAAA;AAAA,MACrG,CAAC,CAAA;AAAA,IACH;AAAA,EAIF,CAAA;AAAA,EACA,EAAE,IAAI,gBAAA;AACR;AAEA,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAAwB,EAAC,KAAM;AACzD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,eAAA,CAAgB,OAAO,CAAA;AACvB,MAAA,eAAA,EAAgB;AAAA,IAClB;AAAA,GACF;AACF,CAAA,CAAA;AAiBO,MAAM,gBAAA,GAAmB,kBAAkB,iBAAiB;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../../src/integrations/tracing/redis/index.ts"],"sourcesContent":["import type { IntegrationFn } from '@sentry/core';\nimport { defineIntegration, extendIntegration } from '@sentry/core';\nimport * as dc from 'node:diagnostics_channel';\nimport { redisIntegration as redisChannelIntegration } from '@sentry/server-utils';\nimport { generateInstrumentOnce } from '@sentry/node-core';\nimport { isDiagnosticsChannelInjectionEnabled } from '../../../sdk/diagnosticsChannelInjection';\nimport { cacheResponseHook, type RedisOptions, setRedisOptions } from './cache';\nimport { IORedisInstrumentation } from './vendored/ioredis-instrumentation';\nimport { RedisInstrumentation } from './vendored/redis-instrumentation';\n\n// `cacheResponseHook`/`_redisOptions` live in `./cache` (which has no OTel\n// instrumentation imports) so the orchestrion opt-in can pull the hook without\n// dragging the OTel redis instrumentation in. Re-exported here for tests.\nexport { _redisOptions, cacheResponseHook } from './cache';\n\nconst INTEGRATION_NAME = 'Redis' as const;\n\nconst instrumentIORedis = generateInstrumentOnce(`${INTEGRATION_NAME}.IORedis`, () => {\n return new IORedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\nconst instrumentRedisModule = generateInstrumentOnce(`${INTEGRATION_NAME}.Redis`, () => {\n return new RedisInstrumentation({\n responseHook: cacheResponseHook,\n });\n});\n\n/**\n * To be able to preload all Redis OTel instrumentations with just one ID\n * (\"Redis\"), all the instrumentations are generated in this one function\n */\nexport const instrumentRedis = Object.assign(\n (): void => {\n // When diagnostics-channel injection is opted in, orchestrion fully owns the older\n // ioredis (`<5.11.0`) and redis/node-redis (`<5.12.0`) ranges — commands, connect, and\n // batches — so skip both OTel monkey-patches to avoid double instrumentation. On Node\n // without `tracingChannel` (<18.19) orchestrion can't run, so keep the OTel patches there.\n if (!isDiagnosticsChannelInjectionEnabled() || !dc.tracingChannel) {\n instrumentIORedis();\n instrumentRedisModule();\n }\n\n // todo: implement them gradually\n // new LegacyRedisInstrumentation({}),\n },\n { id: INTEGRATION_NAME },\n);\n\nconst _redisIntegration = ((options: RedisOptions = {}) => {\n // The diagnostics_channel subscription (node-redis >= 5.12.0, ioredis >= 5.11.0) lives in\n // server-utils so it is shared across server runtimes; we extend it here to also run the vendored\n // OTel patchers for older client versions. `cacheResponseHook` reads options set in the extension's\n // `setupOnce` below, but it only runs at command time, by which point those options are set.\n return extendIntegration(redisChannelIntegration({ responseHook: cacheResponseHook }), {\n name: INTEGRATION_NAME,\n setupOnce() {\n setRedisOptions(options);\n instrumentRedis();\n },\n });\n}) satisfies IntegrationFn;\n\n/**\n * Adds Sentry tracing instrumentation for the [redis](https://www.npmjs.com/package/redis) and\n * [ioredis](https://www.npmjs.com/package/ioredis) libraries.\n *\n * For more information, see the [`redisIntegration` documentation](https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/redis/).\n *\n * @example\n * ```javascript\n * const Sentry = require('@sentry/node');\n *\n * Sentry.init({\n * integrations: [Sentry.redisIntegration()],\n * });\n * ```\n */\nexport const redisIntegration = defineIntegration(_redisIntegration);\n"],"names":["redisChannelIntegration"],"mappings":";;;;;;;;;;AAeA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,iBAAA,GAAoB,sBAAA,CAAuB,CAAA,EAAG,gBAAgB,YAAY,MAAM;AACpF,EAAA,OAAO,IAAI,sBAAA,CAAuB;AAAA,IAChC,YAAA,EAAc;AAAA,GACf,CAAA;AACH,CAAC,CAAA;AAED,MAAM,qBAAA,GAAwB,sBAAA,CAAuB,CAAA,EAAG,gBAAgB,UAAU,MAAM;AACtF,EAAA,OAAO,IAAI,oBAAA,CAAqB;AAAA,IAC9B,YAAA,EAAc;AAAA,GACf,CAAA;AACH,CAAC,CAAA;AAMM,MAAM,kBAAkB,MAAA,CAAO,MAAA;AAAA,EACpC,MAAY;AAKV,IAAA,IAAI,CAAC,oCAAA,EAAqC,IAAK,CAAC,GAAG,cAAA,EAAgB;AACjE,MAAA,iBAAA,EAAkB;AAClB,MAAA,qBAAA,EAAsB;AAAA,IACxB;AAAA,EAIF,CAAA;AAAA,EACA,EAAE,IAAI,gBAAA;AACR;AAEA,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAAwB,EAAC,KAAM;AAKzD,EAAA,OAAO,kBAAkBA,kBAAA,CAAwB,EAAE,YAAA,EAAc,iBAAA,EAAmB,CAAA,EAAG;AAAA,IACrF,IAAA,EAAM,gBAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,eAAA,CAAgB,OAAO,CAAA;AACvB,MAAA,eAAA,EAAgB;AAAA,IAClB;AAAA,GACD,CAAA;AACH,CAAA,CAAA;AAiBO,MAAM,gBAAA,GAAmB,kBAAkB,iBAAiB;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"type":"module","version":"10.64.0","sideEffects":false} | ||
| {"type":"module","version":"10.65.0","sideEffects":false} |
@@ -1,2 +0,2 @@ | ||
| import { channelIntegrations, detectOrchestrionSetup, ioredisChannelIntegration } from '@sentry/server-utils/orchestrion'; | ||
| import { channelIntegrations, detectOrchestrionSetup, ioredisChannelIntegration, redisChannelIntegration } from '@sentry/server-utils/orchestrion'; | ||
| import { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register'; | ||
@@ -14,8 +14,10 @@ import { cacheResponseHook } from '../integrations/tracing/redis/cache.js'; | ||
| return { | ||
| // ioredis is wired here rather than in the shared `channelIntegrations` registry: it needs | ||
| // the node redis cache `responseHook`, and it only partially replaces the composite OTel | ||
| // `Redis` integration (which also covers node-redis and ioredis >=5.11 native diagnostics_channel). | ||
| // So it's added to the integration set but kept OUT of `replacedOtelIntegrationNames` — `Redis` | ||
| // must stay; its ioredis <5.11 monkey-patch is gated off in `redisIntegration` instead. | ||
| integrations: [...integrations, ioredisChannelIntegration({ responseHook: cacheResponseHook })], | ||
| // ioredis and redis are wired separately (not in `channelIntegrations`): they need the node | ||
| // redis cache `responseHook` and only partially replace the composite OTel `Redis` integration, | ||
| // so they're kept OUT of `replacedOtelIntegrationNames` — `Redis` must stay (batch + >=5.11 native DC). | ||
| integrations: [ | ||
| ...integrations, | ||
| ioredisChannelIntegration({ responseHook: cacheResponseHook }), | ||
| redisChannelIntegration({ responseHook: cacheResponseHook }) | ||
| ], | ||
| replacedOtelIntegrationNames, | ||
@@ -22,0 +24,0 @@ register: registerDiagnosticsChannelInjection, |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"experimentalUseDiagnosticsChannelInjection.js","sources":["../../../src/sdk/experimentalUseDiagnosticsChannelInjection.ts"],"sourcesContent":["import {\n channelIntegrations,\n ioredisChannelIntegration,\n detectOrchestrionSetup,\n} from '@sentry/server-utils/orchestrion';\nimport { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';\nimport { cacheResponseHook } from '../integrations/tracing/redis/cache';\nimport type { DiagnosticsChannelInjection } from './diagnosticsChannelInjection';\nimport { setDiagnosticsChannelInjectionLoader } from './diagnosticsChannelInjection';\n\nexport function diagnosticsChannelInjectionIntegrations(): typeof channelIntegrations {\n return channelIntegrations;\n}\n\n/**\n * EXPERIMENTAL: opt into diagnostics-channel-based auto-instrumentation.\n *\n * Call this BEFORE `Sentry.init()`:\n *\n * ```ts\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.experimentalUseDiagnosticsChannelInjection();\n * Sentry.init({\n * dsn: '__DSN__',\n * // other settings...\n * });\n * ```\n *\n * When this has been called AND span recording is enabled, `Sentry.init()`\n * uses the diagnostics-channel-injection-based integrations instead of the\n * OpenTelemetry ones, and installs the module hooks that inject the channels\n * (so libraries imported after `init()` publish the channel events).\n *\n * This is a standalone function rather than an `init()` option so that a\n * bundler drops all of it (and its transitive deps) when this function isn't\n * called. `init()` reads the loader registered below.\n *\n * An app that DOES call it gets the orchestrion code bundled as intended.\n *\n * In an unbundled (server-side runtime) app this eagerly loads only the small\n * subscriber/channel modules; the heavy code-transform dependencies stay lazy\n * inside `register()` and load only when injection actually runs.\n *\n * @experimental May change or be removed in any release.\n */\nexport function experimentalUseDiagnosticsChannelInjection(): void {\n setDiagnosticsChannelInjectionLoader((): DiagnosticsChannelInjection => {\n // The registry integrations 1:1 replace the OTel integration of the same name.\n const integrations = Object.values(channelIntegrations).map(createIntegration => createIntegration());\n const replacedOtelIntegrationNames = integrations.map(i => i.name);\n\n return {\n // ioredis is wired here rather than in the shared `channelIntegrations` registry: it needs\n // the node redis cache `responseHook`, and it only partially replaces the composite OTel\n // `Redis` integration (which also covers node-redis and ioredis >=5.11 native diagnostics_channel).\n // So it's added to the integration set but kept OUT of `replacedOtelIntegrationNames` — `Redis`\n // must stay; its ioredis <5.11 monkey-patch is gated off in `redisIntegration` instead.\n integrations: [...integrations, ioredisChannelIntegration({ responseHook: cacheResponseHook })],\n replacedOtelIntegrationNames,\n register: registerDiagnosticsChannelInjection,\n detect: detectOrchestrionSetup,\n };\n });\n}\n"],"names":[],"mappings":";;;;;AAUO,SAAS,uCAAA,GAAsE;AACpF,EAAA,OAAO,mBAAA;AACT;AAkCO,SAAS,0CAAA,GAAmD;AACjE,EAAA,oCAAA,CAAqC,MAAmC;AAEtE,IAAA,MAAM,YAAA,GAAe,OAAO,MAAA,CAAO,mBAAmB,EAAE,GAAA,CAAI,CAAA,iBAAA,KAAqB,mBAAmB,CAAA;AACpG,IAAA,MAAM,4BAAA,GAA+B,YAAA,CAAa,GAAA,CAAI,CAAA,CAAA,KAAK,EAAE,IAAI,CAAA;AAEjE,IAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAML,YAAA,EAAc,CAAC,GAAG,YAAA,EAAc,0BAA0B,EAAE,YAAA,EAAc,iBAAA,EAAmB,CAAC,CAAA;AAAA,MAC9F,4BAAA;AAAA,MACA,QAAA,EAAU,mCAAA;AAAA,MACV,MAAA,EAAQ;AAAA,KACV;AAAA,EACF,CAAC,CAAA;AACH;;;;"} | ||
| {"version":3,"file":"experimentalUseDiagnosticsChannelInjection.js","sources":["../../../src/sdk/experimentalUseDiagnosticsChannelInjection.ts"],"sourcesContent":["import {\n channelIntegrations,\n ioredisChannelIntegration,\n redisChannelIntegration,\n detectOrchestrionSetup,\n} from '@sentry/server-utils/orchestrion';\nimport { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';\nimport { cacheResponseHook } from '../integrations/tracing/redis/cache';\nimport type { DiagnosticsChannelInjection } from './diagnosticsChannelInjection';\nimport { setDiagnosticsChannelInjectionLoader } from './diagnosticsChannelInjection';\n\nexport function diagnosticsChannelInjectionIntegrations(): typeof channelIntegrations {\n return channelIntegrations;\n}\n\n/**\n * EXPERIMENTAL: opt into diagnostics-channel-based auto-instrumentation.\n *\n * Call this BEFORE `Sentry.init()`:\n *\n * ```ts\n * import * as Sentry from '@sentry/node';\n *\n * Sentry.experimentalUseDiagnosticsChannelInjection();\n * Sentry.init({\n * dsn: '__DSN__',\n * // other settings...\n * });\n * ```\n *\n * When this has been called AND span recording is enabled, `Sentry.init()`\n * uses the diagnostics-channel-injection-based integrations instead of the\n * OpenTelemetry ones, and installs the module hooks that inject the channels\n * (so libraries imported after `init()` publish the channel events).\n *\n * This is a standalone function rather than an `init()` option so that a\n * bundler drops all of it (and its transitive deps) when this function isn't\n * called. `init()` reads the loader registered below.\n *\n * An app that DOES call it gets the orchestrion code bundled as intended.\n *\n * In an unbundled (server-side runtime) app this eagerly loads only the small\n * subscriber/channel modules; the heavy code-transform dependencies stay lazy\n * inside `register()` and load only when injection actually runs.\n *\n * @experimental May change or be removed in any release.\n */\nexport function experimentalUseDiagnosticsChannelInjection(): void {\n setDiagnosticsChannelInjectionLoader((): DiagnosticsChannelInjection => {\n // The registry integrations 1:1 replace the OTel integration of the same name.\n const integrations = Object.values(channelIntegrations).map(createIntegration => createIntegration());\n const replacedOtelIntegrationNames = integrations.map(i => i.name);\n\n return {\n // ioredis and redis are wired separately (not in `channelIntegrations`): they need the node\n // redis cache `responseHook` and only partially replace the composite OTel `Redis` integration,\n // so they're kept OUT of `replacedOtelIntegrationNames` — `Redis` must stay (batch + >=5.11 native DC).\n integrations: [\n ...integrations,\n ioredisChannelIntegration({ responseHook: cacheResponseHook }),\n redisChannelIntegration({ responseHook: cacheResponseHook }),\n ],\n replacedOtelIntegrationNames,\n register: registerDiagnosticsChannelInjection,\n detect: detectOrchestrionSetup,\n };\n });\n}\n"],"names":[],"mappings":";;;;;AAWO,SAAS,uCAAA,GAAsE;AACpF,EAAA,OAAO,mBAAA;AACT;AAkCO,SAAS,0CAAA,GAAmD;AACjE,EAAA,oCAAA,CAAqC,MAAmC;AAEtE,IAAA,MAAM,YAAA,GAAe,OAAO,MAAA,CAAO,mBAAmB,EAAE,GAAA,CAAI,CAAA,iBAAA,KAAqB,mBAAmB,CAAA;AACpG,IAAA,MAAM,4BAAA,GAA+B,YAAA,CAAa,GAAA,CAAI,CAAA,CAAA,KAAK,EAAE,IAAI,CAAA;AAEjE,IAAA,OAAO;AAAA;AAAA;AAAA;AAAA,MAIL,YAAA,EAAc;AAAA,QACZ,GAAG,YAAA;AAAA,QACH,yBAAA,CAA0B,EAAE,YAAA,EAAc,iBAAA,EAAmB,CAAA;AAAA,QAC7D,uBAAA,CAAwB,EAAE,YAAA,EAAc,iBAAA,EAAmB;AAAA,OAC7D;AAAA,MACA,4BAAA;AAAA,MACA,QAAA,EAAU,mCAAA;AAAA,MACV,MAAA,EAAQ;AAAA,KACV;AAAA,EACF,CAAC,CAAA;AACH;;;;"} |
| import { RequestOptions } from 'node:http'; | ||
| import { HttpClientRequest, HttpIncomingMessage, HttpServerResponse, Span } from '@sentry/core'; | ||
| import { SentryHttpInstrumentationOptions } from '@sentry/node-core'; | ||
| import { instrumentHttpOutgoingRequests } from '@sentry/node-core'; | ||
| interface HttpOptions { | ||
@@ -123,3 +123,3 @@ /** | ||
| } | ||
| export declare const instrumentSentryHttp: ((options?: SentryHttpInstrumentationOptions | undefined) => import("@opentelemetry/instrumentation").Instrumentation<import("@opentelemetry/instrumentation").InstrumentationConfig>) & { | ||
| export declare const instrumentSentryHttp: typeof instrumentHttpOutgoingRequests & { | ||
| id: string; | ||
@@ -126,0 +126,0 @@ }; |
@@ -1,136 +0,2 @@ | ||
| export type PromiseOrValue<T> = T | Promise<T>; | ||
| export type Maybe<T> = null | undefined | T; | ||
| export interface Location { | ||
| start: number; | ||
| end: number; | ||
| startToken: Token; | ||
| source: Source; | ||
| [key: string]: any; | ||
| } | ||
| export interface Token { | ||
| kind: string; | ||
| start: number; | ||
| end: number; | ||
| line: number; | ||
| column: number; | ||
| value: string; | ||
| prev: Token | null; | ||
| next: Token | null; | ||
| [key: string]: any; | ||
| } | ||
| export interface Source { | ||
| body: string; | ||
| name: string; | ||
| locationOffset: Location; | ||
| [key: string]: any; | ||
| } | ||
| export interface DocumentNode { | ||
| kind: string; | ||
| definitions: ReadonlyArray<DefinitionNode>; | ||
| loc?: Location; | ||
| [key: string]: any; | ||
| } | ||
| export interface DefinitionNode { | ||
| kind: string; | ||
| loc?: Location; | ||
| [key: string]: any; | ||
| } | ||
| export interface OperationDefinitionNode extends DefinitionNode { | ||
| operation: string; | ||
| name?: { | ||
| kind: string; | ||
| value: string; | ||
| loc?: Location; | ||
| }; | ||
| [key: string]: any; | ||
| } | ||
| export interface ParseOptions { | ||
| noLocation?: boolean; | ||
| [key: string]: any; | ||
| } | ||
| export interface ExecutionArgs { | ||
| schema: GraphQLSchema; | ||
| document: DocumentNode; | ||
| rootValue?: any; | ||
| contextValue?: any; | ||
| variableValues?: Maybe<{ | ||
| [key: string]: any; | ||
| }>; | ||
| operationName?: Maybe<string>; | ||
| fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>; | ||
| typeResolver?: Maybe<GraphQLTypeResolver<any, any>>; | ||
| [key: string]: any; | ||
| } | ||
| export interface ExecutionResult { | ||
| errors?: ReadonlyArray<GraphQLError>; | ||
| data?: Record<string, any> | null; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLError { | ||
| message: string; | ||
| locations?: ReadonlyArray<{ | ||
| line: number; | ||
| column: number; | ||
| }>; | ||
| path?: ReadonlyArray<string | number>; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLSchema { | ||
| getQueryType(): GraphQLObjectType | undefined | null; | ||
| getMutationType(): GraphQLObjectType | undefined | null; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLObjectType { | ||
| name: string; | ||
| getFields(): { | ||
| [key: string]: GraphQLField; | ||
| }; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLField { | ||
| name: string; | ||
| type: GraphQLOutputType; | ||
| resolve?: GraphQLFieldResolver<any, any>; | ||
| [key: string]: any; | ||
| } | ||
| export type GraphQLOutputType = GraphQLNamedOutputType | GraphQLWrappingType; | ||
| interface GraphQLNamedOutputType { | ||
| name: string; | ||
| [key: string]: any; | ||
| } | ||
| interface GraphQLWrappingType { | ||
| ofType: GraphQLOutputType; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLUnionType { | ||
| name: string; | ||
| getTypes(): ReadonlyArray<GraphQLObjectType>; | ||
| [key: string]: any; | ||
| } | ||
| export type GraphQLType = GraphQLOutputType | GraphQLUnionType; | ||
| export type GraphQLFieldResolver<TSource, TContext, TArgs = any> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => any; | ||
| export type GraphQLTypeResolver<TSource, TContext> = (value: TSource, context: TContext, info: GraphQLResolveInfo, abstractType: any) => any; | ||
| export interface GraphQLResolveInfo { | ||
| fieldName: string; | ||
| fieldNodes: ReadonlyArray<{ | ||
| kind: string; | ||
| loc?: Location; | ||
| [key: string]: any; | ||
| }>; | ||
| returnType: { | ||
| toString(): string; | ||
| [key: string]: any; | ||
| }; | ||
| parentType: { | ||
| name: string; | ||
| [key: string]: any; | ||
| }; | ||
| path: any; | ||
| [key: string]: any; | ||
| } | ||
| export type ValidationRule = any; | ||
| export interface TypeInfo { | ||
| [key: string]: any; | ||
| } | ||
| export {}; | ||
| export { DefinitionNode, DocumentNode, ExecutionArgs, ExecutionResult, GraphQLError, GraphQLFieldResolver, GraphQLObjectType, GraphQLOutputType, GraphQLResolveInfo, GraphQLSchema, GraphQLType, GraphQLTypeResolver, GraphQLUnionType, Location, Maybe, OperationDefinitionNode, ParseOptions, PromiseOrValue, Source, Token, TypeInfo, ValidationRule, } from '@sentry/server-utils/orchestrion'; | ||
| //# sourceMappingURL=graphql-types.d.ts.map |
| import type { RequestOptions } from 'node:http'; | ||
| import type { HttpClientRequest, HttpIncomingMessage, HttpServerResponse, Span } from '@sentry/core'; | ||
| import type { SentryHttpInstrumentationOptions } from '@sentry/node-core'; | ||
| import { instrumentHttpOutgoingRequests } from '@sentry/node-core'; | ||
| interface HttpOptions { | ||
@@ -120,3 +120,3 @@ /** | ||
| } | ||
| export declare const instrumentSentryHttp: ((options?: SentryHttpInstrumentationOptions | undefined) => import("@opentelemetry/instrumentation").Instrumentation<import("@opentelemetry/instrumentation").InstrumentationConfig>) & { | ||
| export declare const instrumentSentryHttp: typeof instrumentHttpOutgoingRequests & { | ||
| id: string; | ||
@@ -123,0 +123,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/integrations/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,m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index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAKpE,UAAU,cAAc;IACtB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;;;;OASG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAID,eAAO,MAAM,iBAAiB;;CAI7B,CAAC;AAcF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB;;CAAyC,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/graphql/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAMpE,UAAU,cAAc;IACtB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;;;;OASG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAID,eAAO,MAAM,iBAAiB;;CAI7B,CAAC;AAiBF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB;;CAAyC,CAAC"} |
@@ -1,136 +0,2 @@ | ||
| export type PromiseOrValue<T> = T | Promise<T>; | ||
| export type Maybe<T> = null | undefined | T; | ||
| export interface Location { | ||
| start: number; | ||
| end: number; | ||
| startToken: Token; | ||
| source: Source; | ||
| [key: string]: any; | ||
| } | ||
| export interface Token { | ||
| kind: string; | ||
| start: number; | ||
| end: number; | ||
| line: number; | ||
| column: number; | ||
| value: string; | ||
| prev: Token | null; | ||
| next: Token | null; | ||
| [key: string]: any; | ||
| } | ||
| export interface Source { | ||
| body: string; | ||
| name: string; | ||
| locationOffset: Location; | ||
| [key: string]: any; | ||
| } | ||
| export interface DocumentNode { | ||
| kind: string; | ||
| definitions: ReadonlyArray<DefinitionNode>; | ||
| loc?: Location; | ||
| [key: string]: any; | ||
| } | ||
| export interface DefinitionNode { | ||
| kind: string; | ||
| loc?: Location; | ||
| [key: string]: any; | ||
| } | ||
| export interface OperationDefinitionNode extends DefinitionNode { | ||
| operation: string; | ||
| name?: { | ||
| kind: string; | ||
| value: string; | ||
| loc?: Location; | ||
| }; | ||
| [key: string]: any; | ||
| } | ||
| export interface ParseOptions { | ||
| noLocation?: boolean; | ||
| [key: string]: any; | ||
| } | ||
| export interface ExecutionArgs { | ||
| schema: GraphQLSchema; | ||
| document: DocumentNode; | ||
| rootValue?: any; | ||
| contextValue?: any; | ||
| variableValues?: Maybe<{ | ||
| [key: string]: any; | ||
| }>; | ||
| operationName?: Maybe<string>; | ||
| fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>; | ||
| typeResolver?: Maybe<GraphQLTypeResolver<any, any>>; | ||
| [key: string]: any; | ||
| } | ||
| export interface ExecutionResult { | ||
| errors?: ReadonlyArray<GraphQLError>; | ||
| data?: Record<string, any> | null; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLError { | ||
| message: string; | ||
| locations?: ReadonlyArray<{ | ||
| line: number; | ||
| column: number; | ||
| }>; | ||
| path?: ReadonlyArray<string | number>; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLSchema { | ||
| getQueryType(): GraphQLObjectType | undefined | null; | ||
| getMutationType(): GraphQLObjectType | undefined | null; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLObjectType { | ||
| name: string; | ||
| getFields(): { | ||
| [key: string]: GraphQLField; | ||
| }; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLField { | ||
| name: string; | ||
| type: GraphQLOutputType; | ||
| resolve?: GraphQLFieldResolver<any, any>; | ||
| [key: string]: any; | ||
| } | ||
| export type GraphQLOutputType = GraphQLNamedOutputType | GraphQLWrappingType; | ||
| interface GraphQLNamedOutputType { | ||
| name: string; | ||
| [key: string]: any; | ||
| } | ||
| interface GraphQLWrappingType { | ||
| ofType: GraphQLOutputType; | ||
| [key: string]: any; | ||
| } | ||
| export interface GraphQLUnionType { | ||
| name: string; | ||
| getTypes(): ReadonlyArray<GraphQLObjectType>; | ||
| [key: string]: any; | ||
| } | ||
| export type GraphQLType = GraphQLOutputType | GraphQLUnionType; | ||
| export type GraphQLFieldResolver<TSource, TContext, TArgs = any> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => any; | ||
| export type GraphQLTypeResolver<TSource, TContext> = (value: TSource, context: TContext, info: GraphQLResolveInfo, abstractType: any) => any; | ||
| export interface GraphQLResolveInfo { | ||
| fieldName: string; | ||
| fieldNodes: ReadonlyArray<{ | ||
| kind: string; | ||
| loc?: Location; | ||
| [key: string]: any; | ||
| }>; | ||
| returnType: { | ||
| toString(): string; | ||
| [key: string]: any; | ||
| }; | ||
| parentType: { | ||
| name: string; | ||
| [key: string]: any; | ||
| }; | ||
| path: any; | ||
| [key: string]: any; | ||
| } | ||
| export type ValidationRule = any; | ||
| export interface TypeInfo { | ||
| [key: string]: any; | ||
| } | ||
| export {}; | ||
| export type { DefinitionNode, DocumentNode, ExecutionArgs, ExecutionResult, GraphQLError, GraphQLFieldResolver, GraphQLObjectType, GraphQLOutputType, GraphQLResolveInfo, GraphQLSchema, GraphQLType, GraphQLTypeResolver, GraphQLUnionType, Location, Maybe, OperationDefinitionNode, ParseOptions, PromiseOrValue, Source, Token, TypeInfo, ValidationRule, } from '@sentry/server-utils/orchestrion'; | ||
| //# sourceMappingURL=graphql-types.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"graphql-types.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/graphql/vendored/graphql-types.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE/C,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,IAAI,GAAG,SAAS,GAAG,C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,EACjB,IAAI,EAAE,kBAAkB,KACrB,GAAG,CAAC;AAET,MAAM,MAAM,mBAAmB,CAAC,OAAO,EAAE,QAAQ,IAAI,CACnD,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,QAAQ,EACjB,IAAI,EAAE,kBAAkB,EACxB,YAAY,EAAE,GAAG,KACd,GAAG,CAAC;AAET,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,CAAC;IAChF,UAAU,EAAE;QAAE,QAAQ,IAAI,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACvD,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACjD,IAAI,EAAE,GAAG,CAAC;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC;AAEjC,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"} | ||
| {"version":3,"file":"graphql-types.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/graphql/vendored/graphql-types.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,QAAQ,EACR,KAAK,EACL,uBAAuB,EACvB,YAAY,EACZ,cAAc,EACd,MAAM,EACN,KAAK,EACL,QAAQ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;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,EAAE,aAAa,EAAE,QAAQ,GAAG,QAAQ,CAkBlF;AAID,wBAAgB,yBAAyB,IAAI,OAAO,CAEnD"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/mysql2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAOnE,eAAO,MAAM,gBAAgB;;CAA8E,CAAC;AAW5G;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB;;CAAwC,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/mysql2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAQnE,eAAO,MAAM,gBAAgB;;CAA8E,CAAC;AAa5G;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB;;CAAwC,CAAC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/mysql2/vendored/instrumentation.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mCAAmC,EAAa,MAAM,gCAAgC,CAAC;AAwBrH,qBAAa,qBAAsB,SAAQ,mBAAmB,CAAC,qBAAqB,CAAC;gBAChE,MAAM,GAAE,qBAA0B;IAIrD,SAAS,CAAC,IAAI,IAAI,mCAAmC,EAAE;IA2DvD,OAAO,CAAC,WAAW;IAmEnB,OAAO,CAAC,mBAAmB;CAQ5B"} | ||
| {"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../../../../../src/integrations/tracing/mysql2/vendored/instrumentation.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mCAAmC,EAAa,MAAM,gCAAgC,CAAC;AA2BrH,qBAAa,qBAAsB,SAAQ,mBAAmB,CAAC,qBAAqB,CAAC;gBAChE,MAAM,GAAE,qBAA0B;IAIrD,SAAS,CAAC,IAAI,IAAI,mCAAmC,EAAE;IA2DvD,OAAO,CAAC,WAAW;IAmEnB,OAAO,CAAC,mBAAmB;CAQ5B"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/redis/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAqB,KAAK,YAAY,EAAmB,MAAM,SAAS,CAAC;AAOhF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAgB3D;;;GAGG;AACH,eAAO,MAAM,eAAe,SACtB,IAAI;;CAyBT,CAAC;AAYF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB;;CAAuC,CAAC"} | ||
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/integrations/tracing/redis/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAqB,KAAK,YAAY,EAAmB,MAAM,SAAS,CAAC;AAOhF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAgB3D;;;GAGG;AACH,eAAO,MAAM,eAAe,SACtB,IAAI;;CAcT,CAAC;AAgBF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB;;CAAuC,CAAC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"experimentalUseDiagnosticsChannelInjection.d.ts","sourceRoot":"","sources":["../../../src/sdk/experimentalUseDiagnosticsChannelInjection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAGpB,MAAM,kCAAkC,CAAC;AAM1C,wBAAgB,uCAAuC,IAAI,OAAO,mBAAmB,CAEpF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,0CAA0C,IAAI,IAAI,CAkBjE"} | ||
| {"version":3,"file":"experimentalUseDiagnosticsChannelInjection.d.ts","sourceRoot":"","sources":["../../../src/sdk/experimentalUseDiagnosticsChannelInjection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAIpB,MAAM,kCAAkC,CAAC;AAM1C,wBAAgB,uCAAuC,IAAI,OAAO,mBAAmB,CAEpF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,0CAA0C,IAAI,IAAI,CAoBjE"} |
+5
-5
| { | ||
| "name": "@sentry/node", | ||
| "version": "10.64.0", | ||
| "version": "10.65.0", | ||
| "description": "Sentry Node SDK using OpenTelemetry for performance instrumentation", | ||
@@ -72,6 +72,6 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
| "@sentry/conventions": "^0.15.1", | ||
| "@sentry/core": "10.64.0", | ||
| "@sentry/node-core": "10.64.0", | ||
| "@sentry/opentelemetry": "10.64.0", | ||
| "@sentry/server-utils": "10.64.0", | ||
| "@sentry/core": "10.65.0", | ||
| "@sentry/node-core": "10.65.0", | ||
| "@sentry/opentelemetry": "10.65.0", | ||
| "@sentry/server-utils": "10.65.0", | ||
| "import-in-the-middle": "^3.0.0" | ||
@@ -78,0 +78,0 @@ }, |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
2873924
-0.3%27015
-1.03%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated