@sentry/node 9.6.1 → 9.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/integrations/anr/index.js +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js +159 -63
- package/build/cjs/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js +115 -0
- package/build/cjs/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +1 -0
- package/build/cjs/integrations/http/index.js +21 -10
- package/build/cjs/integrations/http/index.js.map +1 -1
- package/build/cjs/integrations/http/utils.js +44 -0
- package/build/cjs/integrations/http/utils.js.map +1 -0
- package/build/cjs/integrations/local-variables/local-variables-async.js +1 -1
- package/build/esm/integrations/anr/index.js +1 -1
- package/build/esm/integrations/anr/worker-script.js +2 -2
- package/build/esm/integrations/http/SentryHttpInstrumentation.js +154 -58
- package/build/esm/integrations/http/SentryHttpInstrumentation.js.map +1 -1
- package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js +113 -0
- package/build/esm/integrations/http/SentryHttpInstrumentationBeforeOtel.js.map +1 -0
- package/build/esm/integrations/http/index.js +21 -10
- package/build/esm/integrations/http/index.js.map +1 -1
- package/build/esm/integrations/http/utils.js +42 -0
- package/build/esm/integrations/http/utils.js.map +1 -0
- package/build/esm/integrations/local-variables/local-variables-async.js +1 -1
- package/build/esm/integrations/local-variables/worker-script.js +2 -2
- package/build/esm/package.json +1 -1
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts +20 -4
- package/build/types/integrations/http/SentryHttpInstrumentation.d.ts.map +1 -1
- package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +17 -0
- package/build/types/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts.map +1 -0
- package/build/types/integrations/http/index.d.ts.map +1 -1
- package/build/types/integrations/http/utils.d.ts +14 -0
- package/build/types/integrations/http/utils.d.ts.map +1 -0
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentation.d.ts +20 -4
- package/build/types-ts3.8/integrations/http/SentryHttpInstrumentationBeforeOtel.d.ts +20 -0
- package/build/types-ts3.8/integrations/http/utils.d.ts +14 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/integrations/http/index.ts"],"sourcesContent":["import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';\nimport { diag } from '@opentelemetry/api';\nimport type { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport type { Span } from '@sentry/core';\nimport { defineIntegration, getClient } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { NodeClient } from '../../sdk/client';\nimport type { HTTPModuleRequestIncomingMessage } from '../../transports/http-module';\nimport type { NodeClientOptions } from '../../types';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport { SentryHttpInstrumentation } from './SentryHttpInstrumentation';\n\nconst INTEGRATION_NAME = 'Http';\n\nconst INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';\n\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n *\n * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;\n responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => void;\n\n /**\n * You can pass any configuration through to the underlying instrumentation.\n * Note that there are no semver guarantees for this!\n */\n _experimentalConfig?: ConstructorParameters<typeof HttpInstrumentation>[0];\n };\n}\n\nconst instrumentSentryHttp = generateInstrumentOnce<{\n breadcrumbs?: HttpOptions['breadcrumbs'];\n ignoreOutgoingRequests?: HttpOptions['ignoreOutgoingRequests'];\n trackIncomingRequestsAsSessions?: HttpOptions['trackIncomingRequestsAsSessions'];\n sessionFlushingDelayMS?: HttpOptions['sessionFlushingDelayMS'];\n}>(`${INTEGRATION_NAME}.sentry`, options => {\n return new SentryHttpInstrumentation({\n breadcrumbs: options?.breadcrumbs,\n ignoreOutgoingRequests: options?.ignoreOutgoingRequests,\n trackIncomingRequestsAsSessions: options?.trackIncomingRequestsAsSessions,\n sessionFlushingDelayMS: options?.sessionFlushingDelayMS,\n });\n});\n\nexport const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConfig>(INTEGRATION_NAME, config => {\n const instrumentation = new HttpInstrumentation(config);\n\n // We want to update the logger namespace so we can better identify what is happening here\n try {\n instrumentation['_diag'] = diag.createComponentLogger({\n namespace: INSTRUMENTATION_NAME,\n });\n // @ts-expect-error We are writing a read-only property here...\n instrumentation.instrumentationName = INSTRUMENTATION_NAME;\n } catch {\n // ignore errors here...\n }\n\n return instrumentation;\n});\n\n/** Exported only for tests. */\nexport function _shouldInstrumentSpans(options: HttpOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true`\n return typeof options.spans === 'boolean' ? options.spans : !clientOptions.skipOpenTelemetrySetup;\n}\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n\n // This is the Sentry-specific instrumentation that isolates requests & creates breadcrumbs\n // Note that this _has_ to be wrapped after the OTEL instrumentation,\n // otherwise the isolation will not work correctly\n instrumentSentryHttp(options);\n },\n };\n});\n\n/**\n * Determines if @param req is a ClientRequest, meaning the request was created within the express app\n * and it's an outgoing request.\n * Checking for properties instead of using `instanceOf` to avoid importing the request classes.\n */\nfunction _isClientRequest(req: ClientRequest | HTTPModuleRequestIncomingMessage): req is ClientRequest {\n return 'outputData' in req && 'outputSize' in req && !('client' in req) && !('statusCode' in req);\n}\n\n/**\n * Detects if an incoming request is a prefetch request.\n */\nfunction isKnownPrefetchRequest(req: HTTPModuleRequestIncomingMessage): boolean {\n // Currently only handles Next.js prefetch requests but may check other frameworks in the future.\n return req.headers['next-router-prefetch'] === '1';\n}\n\nfunction getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrumentationConfig {\n const instrumentationConfig = {\n ...options.instrumentation?._experimentalConfig,\n\n disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,\n\n ignoreOutgoingRequestHook: request => {\n const url = getRequestUrl(request);\n\n if (!url) {\n return false;\n }\n\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n if (_ignoreOutgoingRequests?.(url, request)) {\n return true;\n }\n\n return false;\n },\n\n ignoreIncomingRequestHook: request => {\n // request.url is the only property that holds any information about the url\n // it only consists of the URL path and query string (if any)\n const urlPath = request.url;\n\n const method = request.method?.toUpperCase();\n // We do not capture OPTIONS/HEAD requests as transactions\n if (method === 'OPTIONS' || method === 'HEAD') {\n return true;\n }\n\n const _ignoreIncomingRequests = options.ignoreIncomingRequests;\n if (urlPath && _ignoreIncomingRequests?.(urlPath, request)) {\n return true;\n }\n\n return false;\n },\n\n requireParentforOutgoingSpans: false,\n requireParentforIncomingSpans: false,\n requestHook: (span, req) => {\n addOriginToSpan(span, 'auto.http.otel.http');\n if (!_isClientRequest(req) && isKnownPrefetchRequest(req)) {\n span.setAttribute('sentry.http.prefetch', true);\n }\n\n options.instrumentation?.requestHook?.(span, req);\n },\n responseHook: (span, res) => {\n options.instrumentation?.responseHook?.(span, res);\n },\n applyCustomAttributesOnSpan: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => {\n options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);\n },\n } satisfies HttpInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":[],"mappings":";;;;;;;;AAcA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B,MAAM,oBAAA,GAAuB,oDAAoD;;AAmFjF,MAAM,oBAAA,GAAuB;;AAK7B,CAAG,CAAC,EAAA,gBAAA,CAAA,OAAA,CAAA,EAAA,OAAA,IAAA;AACA,EAAA,OAAA,IAAA,yBAAA,CAAA;AACA,IAAA,WAAA,EAAA,OAAA,EAAA,WAAA;AACA,IAAA,sBAAA,EAAA,OAAA,EAAA,sBAAA;AACA,IAAA,+BAAA,EAAA,OAAA,EAAA,+BAAA;AACA,IAAA,sBAAA,EAAA,OAAA,EAAA,sBAAA;AACA,GAAA,CAAA;AACA,CAAA,CAAA;;AAEA,MAAA,kBAAA,GAAA,sBAAA,CAAA,gBAAA,EAAA,MAAA,IAAA;AACA,EAAA,MAAA,eAAA,GAAA,IAAA,mBAAA,CAAA,MAAA,CAAA;;AAEA;AACA,EAAA,IAAA;AACA,IAAA,eAAA,CAAA,OAAA,CAAA,GAAA,IAAA,CAAA,qBAAA,CAAA;AACA,MAAA,SAAA,EAAA,oBAAA;AACA,KAAA,CAAA;AACA;AACA,IAAA,eAAA,CAAA,mBAAA,GAAA,oBAAA;AACA,GAAA,CAAA,MAAA;AACA;AACA;;AAEA,EAAA,OAAA,eAAA;AACA,CAAA;;AAEA;AACA,SAAA,sBAAA,CAAA,OAAA,EAAA,aAAA,GAAA,EAAA,EAAA;AACA;AACA;AACA,EAAA,OAAA,OAAA,OAAA,CAAA,KAAA,KAAA,SAAA,GAAA,OAAA,CAAA,KAAA,GAAA,CAAA,aAAA,CAAA,sBAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAA,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A;AACA;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/http/index.ts"],"sourcesContent":["import type { ClientRequest, IncomingMessage, RequestOptions, ServerResponse } from 'node:http';\nimport { diag } from '@opentelemetry/api';\nimport type { HttpInstrumentationConfig } from '@opentelemetry/instrumentation-http';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport type { Span } from '@sentry/core';\nimport { defineIntegration, getClient } from '@sentry/core';\nimport { generateInstrumentOnce } from '../../otel/instrument';\nimport type { NodeClient } from '../../sdk/client';\nimport type { HTTPModuleRequestIncomingMessage } from '../../transports/http-module';\nimport type { NodeClientOptions } from '../../types';\nimport { addOriginToSpan } from '../../utils/addOriginToSpan';\nimport { getRequestUrl } from '../../utils/getRequestUrl';\nimport type { SentryHttpInstrumentationOptions } from './SentryHttpInstrumentation';\nimport { SentryHttpInstrumentation } from './SentryHttpInstrumentation';\nimport { SentryHttpInstrumentationBeforeOtel } from './SentryHttpInstrumentationBeforeOtel';\n\nconst INTEGRATION_NAME = 'Http';\n\nconst INSTRUMENTATION_NAME = '@opentelemetry_sentry-patched/instrumentation-http';\n\ninterface HttpOptions {\n /**\n * Whether breadcrumbs should be recorded for outgoing requests.\n * Defaults to true\n */\n breadcrumbs?: boolean;\n\n /**\n * If set to false, do not emit any spans.\n * This will ensure that the default HttpInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for request isolation is applied.\n *\n * If `skipOpenTelemetrySetup: true` is configured, this defaults to `false`, otherwise it defaults to `true`.\n */\n spans?: boolean;\n\n /**\n * Whether the integration should create [Sessions](https://docs.sentry.io/product/releases/health/#sessions) for incoming requests to track the health and crash-free rate of your releases in Sentry.\n * Read more about Release Health: https://docs.sentry.io/product/releases/health/\n *\n * Defaults to `true`.\n */\n trackIncomingRequestsAsSessions?: boolean;\n\n /**\n * Number of milliseconds until sessions tracked with `trackIncomingRequestsAsSessions` will be flushed as a session aggregate.\n *\n * Defaults to `60000` (60s).\n */\n sessionFlushingDelayMS?: number;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.\n * This controls both span & breadcrumb creation - spans will be non recording if tracing is disabled.\n *\n * The `url` param contains the entire URL, including query string (if any), protocol, host, etc. of the outgoing request.\n * For example: `'https://someService.com/users/details?id=123'`\n *\n * The `request` param contains the original {@type RequestOptions} object used to make the outgoing request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreOutgoingRequests?: (url: string, request: RequestOptions) => boolean;\n\n /**\n * Do not capture spans for incoming HTTP requests to URLs where the given callback returns `true`.\n * Spans will be non recording if tracing is disabled.\n *\n * The `urlPath` param consists of the URL path and query string (if any) of the incoming request.\n * For example: `'/users/details?id=123'`\n *\n * The `request` param contains the original {@type IncomingMessage} object of the incoming request.\n * You can use it to filter on additional properties like method, headers, etc.\n */\n ignoreIncomingRequests?: (urlPath: string, request: IncomingMessage) => boolean;\n\n /**\n * If true, do not generate spans for incoming requests at all.\n * This is used by Remix to avoid generating spans for incoming requests, as it generates its own spans.\n */\n disableIncomingRequestSpans?: boolean;\n\n /**\n * Additional instrumentation options that are passed to the underlying HttpInstrumentation.\n */\n instrumentation?: {\n requestHook?: (span: Span, req: ClientRequest | HTTPModuleRequestIncomingMessage) => void;\n responseHook?: (span: Span, response: HTTPModuleRequestIncomingMessage | ServerResponse) => void;\n applyCustomAttributesOnSpan?: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => void;\n\n /**\n * You can pass any configuration through to the underlying instrumentation.\n * Note that there are no semver guarantees for this!\n */\n _experimentalConfig?: ConstructorParameters<typeof HttpInstrumentation>[0];\n };\n}\n\nconst instrumentSentryHttpBeforeOtel = generateInstrumentOnce(`${INTEGRATION_NAME}.sentry-before-otel`, () => {\n return new SentryHttpInstrumentationBeforeOtel();\n});\n\nconst instrumentSentryHttp = generateInstrumentOnce<SentryHttpInstrumentationOptions>(\n `${INTEGRATION_NAME}.sentry`,\n options => {\n return new SentryHttpInstrumentation(options);\n },\n);\n\nexport const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConfig>(INTEGRATION_NAME, config => {\n const instrumentation = new HttpInstrumentation(config);\n\n // We want to update the logger namespace so we can better identify what is happening here\n try {\n instrumentation['_diag'] = diag.createComponentLogger({\n namespace: INSTRUMENTATION_NAME,\n });\n // @ts-expect-error We are writing a read-only property here...\n instrumentation.instrumentationName = INSTRUMENTATION_NAME;\n } catch {\n // ignore errors here...\n }\n\n return instrumentation;\n});\n\n/** Exported only for tests. */\nexport function _shouldInstrumentSpans(options: HttpOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {\n // If `spans` is passed in, it takes precedence\n // Else, we by default emit spans, unless `skipOpenTelemetrySetup` is set to `true`\n return typeof options.spans === 'boolean' ? options.spans : !clientOptions.skipOpenTelemetrySetup;\n}\n\n/**\n * The http integration instruments Node's internal http and https modules.\n * It creates breadcrumbs and spans for outgoing HTTP requests which will be attached to the currently active span.\n */\nexport const httpIntegration = defineIntegration((options: HttpOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n instrumentSentryHttpBeforeOtel();\n\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is the \"regular\" OTEL instrumentation that emits spans\n if (instrumentSpans) {\n const instrumentationConfig = getConfigWithDefaults(options);\n instrumentOtelHttp(instrumentationConfig);\n }\n\n // This is the Sentry-specific instrumentation that isolates requests & creates breadcrumbs\n // Note that this _has_ to be wrapped after the OTEL instrumentation,\n // otherwise the isolation will not work correctly\n instrumentSentryHttp({\n ...options,\n // If spans are not instrumented, it means the HttpInstrumentation has not been added\n // In that case, we want to handle incoming trace extraction ourselves\n extractIncomingTraceFromHeader: !instrumentSpans,\n // If spans are not instrumented, it means the HttpInstrumentation has not been added\n // In that case, we want to handle trace propagation ourselves\n propagateTraceInOutgoingRequests: !instrumentSpans,\n });\n },\n };\n});\n\n/**\n * Determines if @param req is a ClientRequest, meaning the request was created within the express app\n * and it's an outgoing request.\n * Checking for properties instead of using `instanceOf` to avoid importing the request classes.\n */\nfunction _isClientRequest(req: ClientRequest | HTTPModuleRequestIncomingMessage): req is ClientRequest {\n return 'outputData' in req && 'outputSize' in req && !('client' in req) && !('statusCode' in req);\n}\n\n/**\n * Detects if an incoming request is a prefetch request.\n */\nfunction isKnownPrefetchRequest(req: HTTPModuleRequestIncomingMessage): boolean {\n // Currently only handles Next.js prefetch requests but may check other frameworks in the future.\n return req.headers['next-router-prefetch'] === '1';\n}\n\nfunction getConfigWithDefaults(options: Partial<HttpOptions> = {}): HttpInstrumentationConfig {\n const instrumentationConfig = {\n ...options.instrumentation?._experimentalConfig,\n\n disableIncomingRequestInstrumentation: options.disableIncomingRequestSpans,\n\n ignoreOutgoingRequestHook: request => {\n const url = getRequestUrl(request);\n\n if (!url) {\n return false;\n }\n\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n if (_ignoreOutgoingRequests?.(url, request)) {\n return true;\n }\n\n return false;\n },\n\n ignoreIncomingRequestHook: request => {\n // request.url is the only property that holds any information about the url\n // it only consists of the URL path and query string (if any)\n const urlPath = request.url;\n\n const method = request.method?.toUpperCase();\n // We do not capture OPTIONS/HEAD requests as transactions\n if (method === 'OPTIONS' || method === 'HEAD') {\n return true;\n }\n\n const _ignoreIncomingRequests = options.ignoreIncomingRequests;\n if (urlPath && _ignoreIncomingRequests?.(urlPath, request)) {\n return true;\n }\n\n return false;\n },\n\n requireParentforOutgoingSpans: false,\n requireParentforIncomingSpans: false,\n requestHook: (span, req) => {\n addOriginToSpan(span, 'auto.http.otel.http');\n if (!_isClientRequest(req) && isKnownPrefetchRequest(req)) {\n span.setAttribute('sentry.http.prefetch', true);\n }\n\n options.instrumentation?.requestHook?.(span, req);\n },\n responseHook: (span, res) => {\n options.instrumentation?.responseHook?.(span, res);\n },\n applyCustomAttributesOnSpan: (\n span: Span,\n request: ClientRequest | HTTPModuleRequestIncomingMessage,\n response: HTTPModuleRequestIncomingMessage | ServerResponse,\n ) => {\n options.instrumentation?.applyCustomAttributesOnSpan?.(span, request, response);\n },\n } satisfies HttpInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":[],"mappings":";;;;;;;;;AAgBA,MAAM,gBAAA,GAAmB,MAAM;;AAE/B,MAAM,oBAAA,GAAuB,oDAAoD;;AAmFjF,MAAM,8BAA+B,GAAE,sBAAsB,CAAC,CAAC,EAAA,gBAAA,CAAA,mBAAA,CAAA,EAAA,MAAA;AACA,EAAA,OAAA,IAAA,mCAAA,EAAA;AACA,CAAA,CAAA;;AAEA,MAAA,oBAAA,GAAA,sBAAA;AACA,EAAA,CAAA,EAAA,gBAAA,CAAA,OAAA,CAAA;AACA,EAAA,OAAA,IAAA;AACA,IAAA,OAAA,IAAA,yBAAA,CAAA,OAAA,CAAA;AACA,GAAA;AACA,CAAA;;AAEA,MAAA,kBAAA,GAAA,sBAAA,CAAA,gBAAA,EAAA,MAAA,IAAA;AACA,EAAA,MAAA,eAAA,GAAA,IAAA,mBAAA,CAAA,MAAA,CAAA;;AAEA;AACA,EAAA,IAAA;AACA,IAAA,eAAA,CAAA,OAAA,CAAA,GAAA,IAAA,CAAA,qBAAA,CAAA;AACA,MAAA,SAAA,EAAA,oBAAA;AACA,KAAA,CAAA;AACA;AACA,IAAA,eAAA,CAAA,mBAAA,GAAA,oBAAA;AACA,GAAA,CAAA,MAAA;AACA;AACA;;AAEA,EAAA,OAAA,eAAA;AACA,CAAA;;AAEA;AACA,SAAA,sBAAA,CAAA,OAAA,EAAA,aAAA,GAAA,EAAA,EAAA;AACA;AACA;AACA,EAAA,OAAA,OAAA,OAAA,CAAA,KAAA,KAAA,SAAA,GAAA,OAAA,CAAA,KAAA,GAAA,CAAA,aAAA,CAAA,sBAAA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAA,eAAA,GAAA,iBAAA,CAAA,CAAA,OAAA,GAAA,EAAA,KAAA;AACA,EA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,IAAA,EAAA,OAAA,EAAA,QAAA,CAAA;AACA,KAAA;AACA,GAAA;;AAEA,EAAA,OAAA,qBAAA;AACA;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a minimal version of `wrap` from shimmer:
|
|
3
|
+
* https://github.com/othiym23/shimmer/blob/master/index.js
|
|
4
|
+
*
|
|
5
|
+
* In contrast to the original implementation, this version does not allow to unwrap,
|
|
6
|
+
* and does not make it clear that the method is wrapped.
|
|
7
|
+
* This is necessary because we want to wrap the http module with our own code,
|
|
8
|
+
* while still allowing to use the HttpInstrumentation from OTEL.
|
|
9
|
+
*
|
|
10
|
+
* Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,
|
|
11
|
+
* because it only allows any module to be wrapped a single time.
|
|
12
|
+
*/
|
|
13
|
+
function stealthWrap(
|
|
14
|
+
nodule,
|
|
15
|
+
name,
|
|
16
|
+
wrapper,
|
|
17
|
+
) {
|
|
18
|
+
const original = nodule[name];
|
|
19
|
+
const wrapped = wrapper(original);
|
|
20
|
+
|
|
21
|
+
defineProperty(nodule, name, wrapped);
|
|
22
|
+
return wrapped;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Sets a property on an object, preserving its enumerability.
|
|
26
|
+
function defineProperty(
|
|
27
|
+
obj,
|
|
28
|
+
name,
|
|
29
|
+
value,
|
|
30
|
+
) {
|
|
31
|
+
const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);
|
|
32
|
+
|
|
33
|
+
Object.defineProperty(obj, name, {
|
|
34
|
+
configurable: true,
|
|
35
|
+
enumerable: enumerable,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: value,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { stealthWrap };
|
|
42
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/integrations/http/utils.ts"],"sourcesContent":["/**\n * This is a minimal version of `wrap` from shimmer:\n * https://github.com/othiym23/shimmer/blob/master/index.js\n *\n * In contrast to the original implementation, this version does not allow to unwrap,\n * and does not make it clear that the method is wrapped.\n * This is necessary because we want to wrap the http module with our own code,\n * while still allowing to use the HttpInstrumentation from OTEL.\n *\n * Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,\n * because it only allows any module to be wrapped a single time.\n */\nexport function stealthWrap<Nodule extends object, FieldName extends keyof Nodule>(\n nodule: Nodule,\n name: FieldName,\n wrapper: (original: Nodule[FieldName]) => Nodule[FieldName],\n): Nodule[FieldName] {\n const original = nodule[name];\n const wrapped = wrapper(original);\n\n defineProperty(nodule, name, wrapped);\n return wrapped;\n}\n\n// Sets a property on an object, preserving its enumerability.\nfunction defineProperty<Nodule extends object, FieldName extends keyof Nodule>(\n obj: Nodule,\n name: FieldName,\n value: Nodule[FieldName],\n): void {\n const enumerable = !!obj[name] && Object.prototype.propertyIsEnumerable.call(obj, name);\n\n Object.defineProperty(obj, name, {\n configurable: true,\n enumerable: enumerable,\n writable: true,\n value: value,\n });\n}\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW;AAC3B,EAAE,MAAM;AACR,EAAE,IAAI;AACN,EAAE,OAAO;AACT,EAAqB;AACrB,EAAE,MAAM,QAAS,GAAE,MAAM,CAAC,IAAI,CAAC;AAC/B,EAAE,MAAM,OAAQ,GAAE,OAAO,CAAC,QAAQ,CAAC;;AAEnC,EAAE,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC;AACvC,EAAE,OAAO,OAAO;AAChB;;AAEA;AACA,SAAS,cAAc;AACvB,EAAE,GAAG;AACL,EAAE,IAAI;AACN,EAAE,KAAK;AACP,EAAQ;AACR,EAAE,MAAM,aAAa,CAAC,CAAC,GAAG,CAAC,IAAI,CAAE,IAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC;;AAEzF,EAAE,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE;AACnC,IAAI,YAAY,EAAE,IAAI;AACtB,IAAI,UAAU,EAAE,UAAU;AAC1B,IAAI,QAAQ,EAAE,IAAI;AAClB,IAAI,KAAK,EAAE,KAAK;AAChB,GAAG,CAAC;AACJ;;;;"}
|
|
@@ -4,7 +4,7 @@ import { isDebuggerEnabled } from '../../utils/debug.js';
|
|
|
4
4
|
import { LOCAL_VARIABLES_KEY, functionNamesMatch } from './common.js';
|
|
5
5
|
|
|
6
6
|
// This string is a placeholder that gets overwritten with the worker code.
|
|
7
|
-
const base64WorkerScript = '
|
|
7
|
+
const base64WorkerScript = 'LyohIEBzZW50cnkvbm9kZSA5LjcuMC1hbHBoYS4wIChjMDQ3NjA1KSB8IGh0dHBzOi8vZ2l0aHViLmNvbS9nZXRzZW50cnkvc2VudHJ5LWphdmFzY3JpcHQgKi8KaW1wb3J0e1Nlc3Npb24gYXMgZX1mcm9tIm5vZGU6aW5zcGVjdG9yL3Byb21pc2VzIjtpbXBvcnR7d29ya2VyRGF0YSBhcyB0fWZyb20ibm9kZTp3b3JrZXJfdGhyZWFkcyI7Y29uc3Qgbj1nbG9iYWxUaGlzLG89InVuZGVmaW5lZCI9PXR5cGVvZiBfX1NFTlRSWV9ERUJVR19ffHxfX1NFTlRSWV9ERUJVR19fLGE9IjkuNy4wLWFscGhhLjAiO2NvbnN0IGk9WyJkZWJ1ZyIsImluZm8iLCJ3YXJuIiwiZXJyb3IiLCJsb2ciLCJhc3NlcnQiLCJ0cmFjZSJdLHM9e307ZnVuY3Rpb24gYyhlKXtpZighKCJjb25zb2xlImluIG4pKXJldHVybiBlKCk7Y29uc3QgdD1uLmNvbnNvbGUsbz17fSxhPU9iamVjdC5rZXlzKHMpO2EuZm9yRWFjaCgoZT0+e2NvbnN0IG49c1tlXTtvW2Vd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) {
|
|
10
10
|
logger.log('[LocalVariables]', ...args);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! @sentry/node 9.
|
|
2
|
-
import{Session as e}from"node:inspector/promises";import{workerData as t}from"node:worker_threads";const n=globalThis,o="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,
|
|
1
|
+
/*! @sentry/node 9.7.0-alpha.0 (c047605) | https://github.com/getsentry/sentry-javascript */
|
|
2
|
+
import{Session as e}from"node:inspector/promises";import{workerData as t}from"node:worker_threads";const n=globalThis,o="undefined"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,a="9.7.0-alpha.0";const i=["debug","info","warn","error","log","assert","trace"],s={};function c(e){if(!("console"in n))return e();const t=n.console,o={},a=Object.keys(s);a.forEach((e=>{const n=s[e];o[e]=t[e],t[e]=n}));try{return e()}finally{a.forEach((e=>{t[e]=o[e]}))}}!function(e,t,o=n){const i=o.__SENTRY__=o.__SENTRY__||{},s=i[a]=i[a]||{};s[e]||(s[e]=t())}("logger",(function(){let e=!1;const t={enable:()=>{e=!0},disable:()=>{e=!1},isEnabled:()=>e};return o?i.forEach((o=>{t[o]=(...t)=>{e&&c((()=>{n.console[o](`Sentry Logger [${o}]:`,...t)}))}})):i.forEach((e=>{t[e]=()=>{}})),t}));const r="__SENTRY_ERROR_LOCAL_VARIABLES__";const u=t;function l(...e){u.debug&&c((()=>console.log("[LocalVariables Worker]",...e)))}async function f(e,t,n,o){const a=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=a.result.filter((e=>"length"!==e.name&&!isNaN(parseInt(e.name,10)))).sort(((e,t)=>parseInt(e.name,10)-parseInt(t.name,10))).map((e=>e.value?.value))}async function g(e,t,n,o){const a=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0});o[n]=a.result.map((e=>[e.name,e.value?.value])).reduce(((e,[t,n])=>(e[t]=n,e)),{})}function d(e,t){e.value&&("value"in e.value?void 0===e.value.value||null===e.value.value?t[e.name]=`<${e.value.value}>`:t[e.name]=e.value.value:"description"in e.value&&"function"!==e.value.type?t[e.name]=`<${e.value.description}>`:"undefined"===e.value.type&&(t[e.name]="<undefined>"))}async function b(e,t){const n=await e.post("Runtime.getProperties",{objectId:t,ownProperties:!0}),o={};for(const t of n.result)if(t.value?.objectId&&"Array"===t.value.className){const n=t.value.objectId;await f(e,n,t.name,o)}else if(t.value?.objectId&&"Object"===t.value.className){const n=t.value.objectId;await g(e,n,t.name,o)}else t.value&&d(t,o);return o}let p;(async function(){const t=new e;t.connectToMainThread(),l("Connected to main thread");let n=!1;t.on("Debugger.resumed",(()=>{n=!1})),t.on("Debugger.paused",(e=>{n=!0,async function(e,{reason:t,data:{objectId:n},callFrames:o}){if("exception"!==t&&"promiseRejection"!==t)return;if(p?.(),null==n)return;const a=[];for(let t=0;t<o.length;t++){const{scopeChain:n,functionName:i,this:s}=o[t],c=n.find((e=>"local"===e.type)),r="global"!==s.className&&s.className?`${s.className}.${i}`:i;if(void 0===c?.object.objectId)a[t]={function:r};else{const n=await b(e,c.object.objectId);a[t]={function:r,vars:n}}}await e.post("Runtime.callFunctionOn",{functionDeclaration:`function() { this.${r} = this.${r} || ${JSON.stringify(a)}; }`,silent:!0,objectId:n}),await e.post("Runtime.releaseObject",{objectId:n})}(t,e.params).then((async()=>{n&&await t.post("Debugger.resume")}),(async e=>{n&&await t.post("Debugger.resume")}))})),await t.post("Debugger.enable");const o=!1!==u.captureAllExceptions;if(await t.post("Debugger.setPauseOnExceptions",{state:o?"all":"uncaught"}),o){const e=u.maxExceptionsPerSecond||50;p=function(e,t,n){let o=0,a=5,i=0;return setInterval((()=>{0===i?o>e&&(a*=2,n(a),a>86400&&(a=86400),i=a):(i-=1,0===i&&t()),o=0}),1e3).unref(),()=>{o+=1}}(e,(async()=>{l("Rate-limit lifted."),await t.post("Debugger.setPauseOnExceptions",{state:"all"})}),(async e=>{l(`Rate-limit exceeded. Disabling capturing of caught exceptions for ${e} seconds.`),await t.post("Debugger.setPauseOnExceptions",{state:"uncaught"})}))}})().catch((e=>{l("Failed to start debugger",e)})),setInterval((()=>{}),1e4);
|
package/build/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"9.
|
|
1
|
+
{"type":"module","version":"9.7.0-alpha.0","sideEffects":false}
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type { RequestOptions } from 'node:http';
|
|
4
|
-
import type { EventEmitter } from 'node:stream';
|
|
5
3
|
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
6
4
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
7
5
|
import type { Scope } from '@sentry/core';
|
|
8
|
-
type
|
|
6
|
+
import type { RequestOptions } from 'node:http';
|
|
7
|
+
import type { EventEmitter } from 'node:stream';
|
|
8
|
+
export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
|
|
9
9
|
/**
|
|
10
10
|
* Whether breadcrumbs should be recorded for requests.
|
|
11
11
|
*
|
|
12
12
|
* @default `true`
|
|
13
13
|
*/
|
|
14
14
|
breadcrumbs?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to extract the trace ID from the `sentry-trace` header for incoming requests.
|
|
17
|
+
* By default this is done by the HttpInstrumentation, but if that is not added (e.g. because tracing is disabled, ...)
|
|
18
|
+
* then this instrumentation can take over.
|
|
19
|
+
*
|
|
20
|
+
* @default `false`
|
|
21
|
+
*/
|
|
22
|
+
extractIncomingTraceFromHeader?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to propagate Sentry trace headers in ougoing requests.
|
|
25
|
+
* By default this is done by the HttpInstrumentation, but if that is not added (e.g. because tracing is disabled, ...)
|
|
26
|
+
* then this instrumentation can take over.
|
|
27
|
+
*
|
|
28
|
+
* @default `false`
|
|
29
|
+
*/
|
|
30
|
+
propagateTraceInOutgoingRequests?: boolean;
|
|
15
31
|
/**
|
|
16
32
|
* Do not capture breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.
|
|
17
33
|
* For the scope of this instrumentation, this callback only controls breadcrumb creation.
|
|
@@ -50,6 +66,7 @@ type SentryHttpInstrumentationOptions = InstrumentationConfig & {
|
|
|
50
66
|
* https://github.com/open-telemetry/opentelemetry-js/blob/f8ab5592ddea5cba0a3b33bf8d74f27872c0367f/experimental/packages/opentelemetry-instrumentation-http/src/http.ts
|
|
51
67
|
*/
|
|
52
68
|
export declare class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpInstrumentationOptions> {
|
|
69
|
+
private _propagationDecisionMap;
|
|
53
70
|
constructor(config?: SentryHttpInstrumentationOptions);
|
|
54
71
|
/** @inheritdoc */
|
|
55
72
|
init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition];
|
|
@@ -82,5 +99,4 @@ export declare function recordRequestSession({ requestIsolationScope, response,
|
|
|
82
99
|
response: EventEmitter;
|
|
83
100
|
sessionFlushingDelayMS?: number;
|
|
84
101
|
}): void;
|
|
85
|
-
export {};
|
|
86
102
|
//# sourceMappingURL=SentryHttpInstrumentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentryHttpInstrumentation.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"SentryHttpInstrumentation.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/SentryHttpInstrumentation.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAC1G,OAAO,KAAK,EAAqE,KAAK,EAAE,MAAM,cAAc,CAAC;AAqB7G,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,KAAK,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umentation';
|
|
2
|
+
/**
|
|
3
|
+
* A Sentry specific http instrumentation that is applied before the otel instrumentation.
|
|
4
|
+
*/
|
|
5
|
+
export declare class SentryHttpInstrumentationBeforeOtel extends InstrumentationBase {
|
|
6
|
+
constructor();
|
|
7
|
+
init(): [InstrumentationNodeModuleDefinition, InstrumentationNodeModuleDefinition];
|
|
8
|
+
/** Get the instrumentation for the http module. */
|
|
9
|
+
private _getHttpInstrumentation;
|
|
10
|
+
/** Get the instrumentation for the https module. */
|
|
11
|
+
private _getHttpsInstrumentation;
|
|
12
|
+
/**
|
|
13
|
+
* Patch the incoming request function for request isolation.
|
|
14
|
+
*/
|
|
15
|
+
private _getPatchIncomingRequestFunction;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=SentryHttpInstrumentationBeforeOtel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SentryHttpInstrumentationBeforeOtel.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/SentryHttpInstrumentationBeforeOtel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAU1G;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,mBAAmB;;IAMnE,IAAI,IAAI,CAAC,mCAAmC,EAAE,mCAAmC,CAAC;IAIzF,mDAAmD;IACnD,OAAO,CAAC,uBAAuB;IAS/B,oDAAoD;IACpD,OAAO,CAAC,wBAAwB;IAShC;;OAEG;IACH,OAAO,CAAC,gCAAgC;CAoBzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,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,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,GAAG,gCAAgC,KAAK,IAAI,CAAC;QAC1F,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,gCAAgC,GAAG,cAAc,KAAK,IAAI,CAAC;QACjG,2BAA2B,CAAC,EAAE,CAC5B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,aAAa,GAAG,gCAAgC,EACzD,QAAQ,EAAE,gCAAgC,GAAG,cAAc,KACxD,IAAI,CAAC;QAEV;;;WAGG;QACH,mBAAmB,CAAC,EAAE,qBAAqB,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5E,CAAC;CACH;AAaD,eAAO,MAAM,kBAAkB;;CAe7B,CAAC;AAEH,+BAA+B;AAC/B,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,EAAE,aAAa,GAAE,OAAO,CAAC,iBAAiB,CAAM,GAAG,OAAO,CAIpH;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,2EA4B1B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a minimal version of `wrap` from shimmer:
|
|
3
|
+
* https://github.com/othiym23/shimmer/blob/master/index.js
|
|
4
|
+
*
|
|
5
|
+
* In contrast to the original implementation, this version does not allow to unwrap,
|
|
6
|
+
* and does not make it clear that the method is wrapped.
|
|
7
|
+
* This is necessary because we want to wrap the http module with our own code,
|
|
8
|
+
* while still allowing to use the HttpInstrumentation from OTEL.
|
|
9
|
+
*
|
|
10
|
+
* Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,
|
|
11
|
+
* because it only allows any module to be wrapped a single time.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stealthWrap<Nodule extends object, FieldName extends keyof Nodule>(nodule: Nodule, name: FieldName, wrapper: (original: Nodule[FieldName]) => Nodule[FieldName]): Nodule[FieldName];
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/integrations/http/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,MAAM,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM,MAAM,EAC/E,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC,GAC1D,MAAM,CAAC,SAAS,CAAC,CAMnB"}
|
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { RequestOptions } from 'node:http';
|
|
3
|
-
import { EventEmitter } from 'node:stream';
|
|
4
2
|
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
5
3
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
6
4
|
import { Scope } from '@sentry/core';
|
|
7
|
-
|
|
5
|
+
import { RequestOptions } from 'node:http';
|
|
6
|
+
import { EventEmitter } from 'node:stream';
|
|
7
|
+
export type SentryHttpInstrumentationOptions = InstrumentationConfig & {
|
|
8
8
|
/**
|
|
9
9
|
* Whether breadcrumbs should be recorded for requests.
|
|
10
10
|
*
|
|
11
11
|
* @default `true`
|
|
12
12
|
*/
|
|
13
13
|
breadcrumbs?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to extract the trace ID from the `sentry-trace` header for incoming requests.
|
|
16
|
+
* By default this is done by the HttpInstrumentation, but if that is not added (e.g. because tracing is disabled, ...)
|
|
17
|
+
* then this instrumentation can take over.
|
|
18
|
+
*
|
|
19
|
+
* @default `false`
|
|
20
|
+
*/
|
|
21
|
+
extractIncomingTraceFromHeader?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to propagate Sentry trace headers in ougoing requests.
|
|
24
|
+
* By default this is done by the HttpInstrumentation, but if that is not added (e.g. because tracing is disabled, ...)
|
|
25
|
+
* then this instrumentation can take over.
|
|
26
|
+
*
|
|
27
|
+
* @default `false`
|
|
28
|
+
*/
|
|
29
|
+
propagateTraceInOutgoingRequests?: boolean;
|
|
14
30
|
/**
|
|
15
31
|
* Do not capture breadcrumbs for outgoing HTTP requests to URLs where the given callback returns `true`.
|
|
16
32
|
* For the scope of this instrumentation, this callback only controls breadcrumb creation.
|
|
@@ -49,6 +65,7 @@ type SentryHttpInstrumentationOptions = InstrumentationConfig & {
|
|
|
49
65
|
* https://github.com/open-telemetry/opentelemetry-js/blob/f8ab5592ddea5cba0a3b33bf8d74f27872c0367f/experimental/packages/opentelemetry-instrumentation-http/src/http.ts
|
|
50
66
|
*/
|
|
51
67
|
export declare class SentryHttpInstrumentation extends InstrumentationBase<SentryHttpInstrumentationOptions> {
|
|
68
|
+
private _propagationDecisionMap;
|
|
52
69
|
constructor(config?: SentryHttpInstrumentationOptions);
|
|
53
70
|
/** @inheritdoc */
|
|
54
71
|
init(): [
|
|
@@ -84,5 +101,4 @@ export declare function recordRequestSession({ requestIsolationScope, response,
|
|
|
84
101
|
response: EventEmitter;
|
|
85
102
|
sessionFlushingDelayMS?: number;
|
|
86
103
|
}): void;
|
|
87
|
-
export {};
|
|
88
104
|
//# sourceMappingURL=SentryHttpInstrumentation.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
/**
|
|
3
|
+
* A Sentry specific http instrumentation that is applied before the otel instrumentation.
|
|
4
|
+
*/
|
|
5
|
+
export declare class SentryHttpInstrumentationBeforeOtel extends InstrumentationBase {
|
|
6
|
+
constructor();
|
|
7
|
+
init(): [
|
|
8
|
+
InstrumentationNodeModuleDefinition,
|
|
9
|
+
InstrumentationNodeModuleDefinition
|
|
10
|
+
];
|
|
11
|
+
/** Get the instrumentation for the http module. */
|
|
12
|
+
private _getHttpInstrumentation;
|
|
13
|
+
/** Get the instrumentation for the https module. */
|
|
14
|
+
private _getHttpsInstrumentation;
|
|
15
|
+
/**
|
|
16
|
+
* Patch the incoming request function for request isolation.
|
|
17
|
+
*/
|
|
18
|
+
private _getPatchIncomingRequestFunction;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=SentryHttpInstrumentationBeforeOtel.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a minimal version of `wrap` from shimmer:
|
|
3
|
+
* https://github.com/othiym23/shimmer/blob/master/index.js
|
|
4
|
+
*
|
|
5
|
+
* In contrast to the original implementation, this version does not allow to unwrap,
|
|
6
|
+
* and does not make it clear that the method is wrapped.
|
|
7
|
+
* This is necessary because we want to wrap the http module with our own code,
|
|
8
|
+
* while still allowing to use the HttpInstrumentation from OTEL.
|
|
9
|
+
*
|
|
10
|
+
* Without this, if we'd just use `wrap` from shimmer, the OTEL instrumentation would remove our wrapping,
|
|
11
|
+
* because it only allows any module to be wrapped a single time.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stealthWrap<Nodule extends object, FieldName extends keyof Nodule>(nodule: Nodule, name: FieldName, wrapper: (original: Nodule[FieldName]) => Nodule[FieldName]): Nodule[FieldName];
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/node",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.0-alpha.0",
|
|
4
4
|
"description": "Sentry Node SDK using OpenTelemetry for performance instrumentation",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/node",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
97
97
|
"@opentelemetry/semantic-conventions": "^1.30.0",
|
|
98
98
|
"@prisma/instrumentation": "6.5.0",
|
|
99
|
-
"@sentry/core": "9.
|
|
100
|
-
"@sentry/opentelemetry": "9.
|
|
99
|
+
"@sentry/core": "9.7.0-alpha.0",
|
|
100
|
+
"@sentry/opentelemetry": "9.7.0-alpha.0",
|
|
101
101
|
"import-in-the-middle": "^1.13.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|