@sentry/node 10.59.0 → 10.60.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/index.js +1 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/node-fetch/index.js +7 -8
- package/build/cjs/integrations/node-fetch/index.js.map +1 -1
- package/build/cjs/integrations/node-fetch/vendored/semconv.js +28 -0
- package/build/cjs/integrations/node-fetch/vendored/semconv.js.map +1 -0
- package/build/cjs/integrations/node-fetch/vendored/undici.js +91 -127
- package/build/cjs/integrations/node-fetch/vendored/undici.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka/index.js +1 -11
- package/build/cjs/integrations/tracing/kafka/index.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka/vendored/instrumentation.js +45 -247
- package/build/cjs/integrations/tracing/kafka/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka/vendored/semconv.js +4 -8
- package/build/cjs/integrations/tracing/kafka/vendored/semconv.js.map +1 -1
- package/build/cjs/integrations/tracing/kafka/vendored/utils.js +113 -0
- package/build/cjs/integrations/tracing/kafka/vendored/utils.js.map +1 -0
- package/build/cjs/sdk/initOtel.js +2 -1
- package/build/cjs/sdk/initOtel.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/integrations/node-fetch/index.js +8 -9
- package/build/esm/integrations/node-fetch/index.js.map +1 -1
- package/build/esm/integrations/node-fetch/vendored/semconv.js +15 -0
- package/build/esm/integrations/node-fetch/vendored/semconv.js.map +1 -0
- package/build/esm/integrations/node-fetch/vendored/undici.js +80 -116
- package/build/esm/integrations/node-fetch/vendored/undici.js.map +1 -1
- package/build/esm/integrations/tracing/kafka/index.js +2 -12
- package/build/esm/integrations/tracing/kafka/index.js.map +1 -1
- package/build/esm/integrations/tracing/kafka/vendored/instrumentation.js +47 -249
- package/build/esm/integrations/tracing/kafka/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/kafka/vendored/semconv.js +3 -5
- package/build/esm/integrations/tracing/kafka/vendored/semconv.js.map +1 -1
- package/build/esm/integrations/tracing/kafka/vendored/utils.js +107 -0
- package/build/esm/integrations/tracing/kafka/vendored/utils.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/sdk/initOtel.js +2 -1
- package/build/esm/sdk/initOtel.js.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/index.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/vendored/internal-types.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/vendored/semconv.d.ts +13 -0
- package/build/types/integrations/node-fetch/vendored/semconv.d.ts.map +1 -0
- package/build/types/integrations/node-fetch/vendored/types.d.ts +2 -4
- package/build/types/integrations/node-fetch/vendored/types.d.ts.map +1 -1
- package/build/types/integrations/node-fetch/vendored/undici.d.ts +6 -7
- package/build/types/integrations/node-fetch/vendored/undici.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/vendored/instrumentation.d.ts +3 -13
- package/build/types/integrations/tracing/kafka/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/vendored/kafkajs-types.d.ts +0 -32
- package/build/types/integrations/tracing/kafka/vendored/kafkajs-types.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/vendored/semconv.d.ts +9 -28
- package/build/types/integrations/tracing/kafka/vendored/semconv.d.ts.map +1 -1
- package/build/types/integrations/tracing/kafka/vendored/utils.d.ts +29 -0
- package/build/types/integrations/tracing/kafka/vendored/utils.d.ts.map +1 -0
- package/build/types/sdk/initOtel.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +1 -1
- package/build/types-ts3.8/integrations/node-fetch/vendored/semconv.d.ts +13 -0
- package/build/types-ts3.8/integrations/node-fetch/vendored/types.d.ts +2 -4
- package/build/types-ts3.8/integrations/node-fetch/vendored/undici.d.ts +6 -7
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/instrumentation.d.ts +3 -13
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/kafkajs-types.d.ts +0 -32
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/semconv.d.ts +9 -28
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/utils.d.ts +29 -0
- package/package.json +5 -6
- package/build/cjs/integrations/tracing/kafka/vendored/internal-types.js +0 -6
- package/build/cjs/integrations/tracing/kafka/vendored/internal-types.js.map +0 -1
- package/build/cjs/integrations/tracing/kafka/vendored/propagator.js +0 -22
- package/build/cjs/integrations/tracing/kafka/vendored/propagator.js.map +0 -1
- package/build/esm/integrations/tracing/kafka/vendored/internal-types.js +0 -4
- package/build/esm/integrations/tracing/kafka/vendored/internal-types.js.map +0 -1
- package/build/esm/integrations/tracing/kafka/vendored/propagator.js +0 -20
- package/build/esm/integrations/tracing/kafka/vendored/propagator.js.map +0 -1
- package/build/types/integrations/tracing/kafka/vendored/internal-types.d.ts +0 -9
- package/build/types/integrations/tracing/kafka/vendored/internal-types.d.ts.map +0 -1
- package/build/types/integrations/tracing/kafka/vendored/propagator.d.ts +0 -3
- package/build/types/integrations/tracing/kafka/vendored/propagator.d.ts.map +0 -1
- package/build/types/integrations/tracing/kafka/vendored/types.d.ts +0 -26
- package/build/types/integrations/tracing/kafka/vendored/types.d.ts.map +0 -1
- package/build/types/integrations/tracing/utils/sql-common.d.ts +0 -3
- package/build/types/integrations/tracing/utils/sql-common.d.ts.map +0 -1
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/internal-types.d.ts +0 -9
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/propagator.d.ts +0 -3
- package/build/types-ts3.8/integrations/tracing/kafka/vendored/types.d.ts +0 -26
- package/build/types-ts3.8/integrations/tracing/utils/sql-common.d.ts +0 -3
package/build/cjs/index.js
CHANGED
|
@@ -110,6 +110,7 @@ exports.Scope = core.Scope;
|
|
|
110
110
|
exports.addBreadcrumb = core.addBreadcrumb;
|
|
111
111
|
exports.addEventProcessor = core.addEventProcessor;
|
|
112
112
|
exports.addIntegration = core.addIntegration;
|
|
113
|
+
exports.bindScopeToEmitter = core.bindScopeToEmitter;
|
|
113
114
|
exports.captureCheckIn = core.captureCheckIn;
|
|
114
115
|
exports.captureConsoleIntegration = core.captureConsoleIntegration;
|
|
115
116
|
exports.captureEvent = core.captureEvent;
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -5,13 +5,13 @@ const core = require('@sentry/core');
|
|
|
5
5
|
const nodeCore = require('@sentry/node-core');
|
|
6
6
|
|
|
7
7
|
const INTEGRATION_NAME = "NodeFetch";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return _getConfigWithDefaults(options);
|
|
8
|
+
let _undiciInstrumentation;
|
|
9
|
+
function instrumentNodeFetchSpans(options) {
|
|
10
|
+
if (!_undiciInstrumentation) {
|
|
11
|
+
_undiciInstrumentation = new undici.UndiciInstrumentation(_getConfigWithDefaults(options));
|
|
13
12
|
}
|
|
14
|
-
);
|
|
13
|
+
_undiciInstrumentation.enable();
|
|
14
|
+
}
|
|
15
15
|
const instrumentSentryNodeFetch = nodeCore.generateInstrumentOnce(
|
|
16
16
|
`${INTEGRATION_NAME}.sentry`,
|
|
17
17
|
nodeCore.SentryNodeFetchInstrumentation,
|
|
@@ -25,7 +25,7 @@ const _nativeNodeFetchIntegration = ((options = {}) => {
|
|
|
25
25
|
setupOnce() {
|
|
26
26
|
const instrumentSpans = _shouldInstrumentSpans(options, core.getClient()?.getOptions());
|
|
27
27
|
if (instrumentSpans) {
|
|
28
|
-
|
|
28
|
+
instrumentNodeFetchSpans(options);
|
|
29
29
|
}
|
|
30
30
|
instrumentSentryNodeFetch(options);
|
|
31
31
|
}
|
|
@@ -47,7 +47,6 @@ function _shouldInstrumentSpans(options, clientOptions = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
function _getConfigWithDefaults(options = {}) {
|
|
49
49
|
const instrumentationConfig = {
|
|
50
|
-
requireParentforSpans: false,
|
|
51
50
|
ignoreRequestHook: (request) => {
|
|
52
51
|
const url = getAbsoluteUrl(request.origin, request.path);
|
|
53
52
|
const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/integrations/node-fetch/index.ts"],"sourcesContent":["import type { UndiciInstrumentationConfig } from './vendored/types';\nimport { UndiciInstrumentation } from './vendored/undici';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n getClient,\n hasSpansEnabled,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n stripDataUrlContent,\n} from '@sentry/core';\nimport type { NodeClient } from '@sentry/node-core';\nimport { generateInstrumentOnce, SentryNodeFetchInstrumentation } from '@sentry/node-core';\nimport type { NodeClientOptions } from '../../types';\n\nconst INTEGRATION_NAME = 'NodeFetch';\n\ninterface NodeFetchOptions extends Pick<\n UndiciInstrumentationConfig,\n 'requestHook' | 'responseHook' | 'headersToSpanAttributes'\n> {\n /**\n * Whether breadcrumbs should be recorded for 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 UndiciInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for breadcrumbs & trace propagation 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 to inject trace propagation headers (sentry-trace, baggage, traceparent) into outgoing fetch 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 UndiciInstrumentation.\n *\n * @default `true`\n */\n tracePropagation?: boolean;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing fetch 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 ignoreOutgoingRequests?: (url: string) => boolean;\n}\n\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/integrations/node-fetch/index.ts"],"sourcesContent":["import type { UndiciInstrumentationConfig } from './vendored/types';\nimport { UndiciInstrumentation } from './vendored/undici';\nimport type { IntegrationFn } from '@sentry/core';\nimport {\n defineIntegration,\n getClient,\n hasSpansEnabled,\n SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_URL_FULL,\n stripDataUrlContent,\n} from '@sentry/core';\nimport type { NodeClient } from '@sentry/node-core';\nimport { generateInstrumentOnce, SentryNodeFetchInstrumentation } from '@sentry/node-core';\nimport type { NodeClientOptions } from '../../types';\n\nconst INTEGRATION_NAME = 'NodeFetch';\n\ninterface NodeFetchOptions extends Pick<\n UndiciInstrumentationConfig,\n 'requestHook' | 'responseHook' | 'headersToSpanAttributes'\n> {\n /**\n * Whether breadcrumbs should be recorded for 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 UndiciInstrumentation from OpenTelemetry is not setup,\n * only the Sentry-specific instrumentation for breadcrumbs & trace propagation 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 to inject trace propagation headers (sentry-trace, baggage, traceparent) into outgoing fetch 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 UndiciInstrumentation.\n *\n * @default `true`\n */\n tracePropagation?: boolean;\n\n /**\n * Do not capture spans or breadcrumbs for outgoing fetch 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 ignoreOutgoingRequests?: (url: string) => boolean;\n}\n\nlet _undiciInstrumentation: UndiciInstrumentation | undefined;\n\n// Sets up the vendored undici instrumentation (emits `http.client` spans & propagates traces).\n// The module-level singleton mirrors `generateInstrumentOnce`'s \"instrument once per process\" behavior.\nfunction instrumentNodeFetchSpans(options: NodeFetchOptions): void {\n if (!_undiciInstrumentation) {\n _undiciInstrumentation = new UndiciInstrumentation(_getConfigWithDefaults(options));\n }\n _undiciInstrumentation.enable();\n}\n\nconst instrumentSentryNodeFetch = generateInstrumentOnce(\n `${INTEGRATION_NAME}.sentry`,\n SentryNodeFetchInstrumentation,\n (options: NodeFetchOptions) => {\n return options;\n },\n);\n\nconst _nativeNodeFetchIntegration = ((options: NodeFetchOptions = {}) => {\n return {\n name: 'NodeFetch',\n setupOnce() {\n const instrumentSpans = _shouldInstrumentSpans(options, getClient<NodeClient>()?.getOptions());\n\n // This is the instrumentation that emits spans & propagates traces for outgoing fetch requests\n if (instrumentSpans) {\n instrumentNodeFetchSpans(options);\n }\n\n // This is the Sentry-specific instrumentation that creates breadcrumbs & propagates traces.\n // It must subscribe to the diagnostics channels after the span instrumentation above, so the core\n // trace propagation logic takes precedence. Otherwise, the sentry-trace header may be set multiple times.\n instrumentSentryNodeFetch(options);\n },\n };\n}) satisfies IntegrationFn;\n\nexport const nativeNodeFetchIntegration = defineIntegration(_nativeNodeFetchIntegration);\n\n// Matching the behavior of the base instrumentation\nfunction getAbsoluteUrl(origin: string, path: string = '/'): string {\n const url = `${origin}`;\n\n if (url.endsWith('/') && path.startsWith('/')) {\n return `${url}${path.slice(1)}`;\n }\n\n if (!url.endsWith('/') && !path.startsWith('/')) {\n return `${url}/${path}`;\n }\n\n return `${url}${path}`;\n}\n\nfunction _shouldInstrumentSpans(options: NodeFetchOptions, 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` or spans are not enabled\n return typeof options.spans === 'boolean'\n ? options.spans\n : !clientOptions.skipOpenTelemetrySetup && hasSpansEnabled(clientOptions);\n}\n\n/** Exported only for tests. */\nexport function _getConfigWithDefaults(options: Partial<NodeFetchOptions> = {}): UndiciInstrumentationConfig {\n const instrumentationConfig = {\n ignoreRequestHook: request => {\n const url = getAbsoluteUrl(request.origin, request.path);\n const _ignoreOutgoingRequests = options.ignoreOutgoingRequests;\n const shouldIgnore = _ignoreOutgoingRequests && url && _ignoreOutgoingRequests(url);\n\n return !!shouldIgnore;\n },\n startSpanHook: request => {\n const url = getAbsoluteUrl(request.origin, request.path);\n\n // Sanitize data URLs to prevent long base64 strings in span attributes\n if (url.startsWith('data:')) {\n const sanitizedUrl = stripDataUrlContent(url);\n return {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.node_fetch',\n 'http.url': sanitizedUrl,\n [SEMANTIC_ATTRIBUTE_URL_FULL]: sanitizedUrl,\n [SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME]: `${request.method || 'GET'} ${sanitizedUrl}`,\n };\n }\n\n return {\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.http.otel.node_fetch',\n };\n },\n requestHook: options.requestHook,\n responseHook: options.responseHook,\n headersToSpanAttributes: options.headersToSpanAttributes,\n } satisfies UndiciInstrumentationConfig;\n\n return instrumentationConfig;\n}\n"],"names":["UndiciInstrumentation","generateInstrumentOnce","SentryNodeFetchInstrumentation","getClient","defineIntegration","hasSpansEnabled","stripDataUrlContent","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_URL_FULL","SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME"],"mappings":";;;;;;AAgBA,MAAM,gBAAA,GAAmB,WAAA;AAuCzB,IAAI,sBAAA;AAIJ,SAAS,yBAAyB,OAAA,EAAiC;AACjE,EAAA,IAAI,CAAC,sBAAA,EAAwB;AAC3B,IAAA,sBAAA,GAAyB,IAAIA,4BAAA,CAAsB,sBAAA,CAAuB,OAAO,CAAC,CAAA;AAAA,EACpF;AACA,EAAA,sBAAA,CAAuB,MAAA,EAAO;AAChC;AAEA,MAAM,yBAAA,GAA4BC,+BAAA;AAAA,EAChC,GAAG,gBAAgB,CAAA,OAAA,CAAA;AAAA,EACnBC,uCAAA;AAAA,EACA,CAAC,OAAA,KAA8B;AAC7B,IAAA,OAAO,OAAA;AAAA,EACT;AACF,CAAA;AAEA,MAAM,2BAAA,IAA+B,CAAC,OAAA,GAA4B,EAAC,KAAM;AACvE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,SAAA,GAAY;AACV,MAAA,MAAM,kBAAkB,sBAAA,CAAuB,OAAA,EAASC,cAAA,EAAsB,EAAG,YAAY,CAAA;AAG7F,MAAA,IAAI,eAAA,EAAiB;AACnB,QAAA,wBAAA,CAAyB,OAAO,CAAA;AAAA,MAClC;AAKA,MAAA,yBAAA,CAA0B,OAAO,CAAA;AAAA,IACnC;AAAA,GACF;AACF,CAAA,CAAA;AAEO,MAAM,0BAAA,GAA6BC,uBAA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ACxB,MAAA,MAAM,GAAA,GAAM,cAAA,CAAe,OAAA,CAAQ,MAAA,EAAQ,QAAQ,IAAI,CAAA;AAGvD,MAAA,IAAI,GAAA,CAAI,UAAA,CAAW,OAAO,CAAA,EAAG;AAC3B,QAAA,MAAM,YAAA,GAAeC,yBAAoB,GAAG,CAAA;AAC5C,QAAA,OAAO;AAAA,UACL,CAACC,qCAAgC,GAAG,2BAAA;AAAA,UACpC,UAAA,EAAY,YAAA;AAAA,UACZ,CAACC,gCAA2B,GAAG,YAAA;AAAA,UAC/B,CAACC,+CAA0C,GAAG,CAAA,EAAG,QAAQ,MAAA,IAAU,KAAK,IAAI,YAAY,CAAA;AAAA,SAC1F;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,CAACF,qCAAgC,GAAG;AAAA,OACtC;AAAA,IACF,CAAA;AAAA,IACA,aAAa,OAAA,CAAQ,WAAA;AAAA,IACrB,cAAc,OAAA,CAAQ,YAAA;AAAA,IACtB,yBAAyB,OAAA,CAAQ;AAAA,GACnC;AAEA,EAAA,OAAO,qBAAA;AACT;;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const ATTR_HTTP_REQUEST_METHOD = "http.request.method";
|
|
4
|
+
const ATTR_HTTP_REQUEST_METHOD_ORIGINAL = "http.request.method_original";
|
|
5
|
+
const ATTR_HTTP_RESPONSE_STATUS_CODE = "http.response.status_code";
|
|
6
|
+
const ATTR_NETWORK_PEER_ADDRESS = "network.peer.address";
|
|
7
|
+
const ATTR_NETWORK_PEER_PORT = "network.peer.port";
|
|
8
|
+
const ATTR_SERVER_ADDRESS = "server.address";
|
|
9
|
+
const ATTR_SERVER_PORT = "server.port";
|
|
10
|
+
const ATTR_URL_FULL = "url.full";
|
|
11
|
+
const ATTR_URL_PATH = "url.path";
|
|
12
|
+
const ATTR_URL_QUERY = "url.query";
|
|
13
|
+
const ATTR_URL_SCHEME = "url.scheme";
|
|
14
|
+
const ATTR_USER_AGENT_ORIGINAL = "user_agent.original";
|
|
15
|
+
|
|
16
|
+
exports.ATTR_HTTP_REQUEST_METHOD = ATTR_HTTP_REQUEST_METHOD;
|
|
17
|
+
exports.ATTR_HTTP_REQUEST_METHOD_ORIGINAL = ATTR_HTTP_REQUEST_METHOD_ORIGINAL;
|
|
18
|
+
exports.ATTR_HTTP_RESPONSE_STATUS_CODE = ATTR_HTTP_RESPONSE_STATUS_CODE;
|
|
19
|
+
exports.ATTR_NETWORK_PEER_ADDRESS = ATTR_NETWORK_PEER_ADDRESS;
|
|
20
|
+
exports.ATTR_NETWORK_PEER_PORT = ATTR_NETWORK_PEER_PORT;
|
|
21
|
+
exports.ATTR_SERVER_ADDRESS = ATTR_SERVER_ADDRESS;
|
|
22
|
+
exports.ATTR_SERVER_PORT = ATTR_SERVER_PORT;
|
|
23
|
+
exports.ATTR_URL_FULL = ATTR_URL_FULL;
|
|
24
|
+
exports.ATTR_URL_PATH = ATTR_URL_PATH;
|
|
25
|
+
exports.ATTR_URL_QUERY = ATTR_URL_QUERY;
|
|
26
|
+
exports.ATTR_URL_SCHEME = ATTR_URL_SCHEME;
|
|
27
|
+
exports.ATTR_USER_AGENT_ORIGINAL = ATTR_USER_AGENT_ORIGINAL;
|
|
28
|
+
//# sourceMappingURL=semconv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semconv.js","sources":["../../../../../src/integrations/node-fetch/vendored/semconv.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/ed97091c9890dd18e52759f2ea98e9d7593b3ae4/packages/instrumentation-undici\n * - Upstream version: @opentelemetry/instrumentation-undici@0.24.0\n * - The semantic-convention constants this package emits, inlined from\n * `@opentelemetry/semantic-conventions` (matching the sibling vendored dirs).\n */\n\nexport const ATTR_HTTP_REQUEST_METHOD = 'http.request.method' as const;\nexport const ATTR_HTTP_REQUEST_METHOD_ORIGINAL = 'http.request.method_original' as const;\nexport const ATTR_HTTP_RESPONSE_STATUS_CODE = 'http.response.status_code' as const;\nexport const ATTR_NETWORK_PEER_ADDRESS = 'network.peer.address' as const;\nexport const ATTR_NETWORK_PEER_PORT = 'network.peer.port' as const;\nexport const ATTR_SERVER_ADDRESS = 'server.address' as const;\nexport const ATTR_SERVER_PORT = 'server.port' as const;\nexport const ATTR_URL_FULL = 'url.full' as const;\nexport const ATTR_URL_PATH = 'url.path' as const;\nexport const ATTR_URL_QUERY = 'url.query' as const;\nexport const ATTR_URL_SCHEME = 'url.scheme' as const;\nexport const ATTR_USER_AGENT_ORIGINAL = 'user_agent.original' as const;\n"],"names":[],"mappings":";;AAWO,MAAM,wBAAA,GAA2B;AACjC,MAAM,iCAAA,GAAoC;AAC1C,MAAM,8BAAA,GAAiC;AACvC,MAAM,yBAAA,GAA4B;AAClC,MAAM,sBAAA,GAAyB;AAC/B,MAAM,mBAAA,GAAsB;AAC5B,MAAM,gBAAA,GAAmB;AACzB,MAAM,aAAA,GAAgB;AACtB,MAAM,aAAA,GAAgB;AACtB,MAAM,cAAA,GAAiB;AACvB,MAAM,eAAA,GAAkB;AACxB,MAAM,wBAAA,GAA2B;;;;;;;;;;;;;;;"}
|
|
@@ -2,29 +2,34 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
|
|
3
3
|
const diagch = require('diagnostics_channel');
|
|
4
4
|
const url = require('url');
|
|
5
|
-
const instrumentation = require('@opentelemetry/instrumentation');
|
|
6
|
-
const api = require('@opentelemetry/api');
|
|
7
|
-
const semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
8
5
|
const core = require('@sentry/core');
|
|
6
|
+
const debugBuild = require('../../../debug-build.js');
|
|
7
|
+
const semconv = require('./semconv.js');
|
|
9
8
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// No need to instrument files/modules
|
|
17
|
-
init() {
|
|
9
|
+
const SPAN_KIND_CLIENT = 2;
|
|
10
|
+
function safeExecute(fn, onError) {
|
|
11
|
+
try {
|
|
12
|
+
return fn();
|
|
13
|
+
} catch (error) {
|
|
14
|
+
onError(error);
|
|
18
15
|
return void 0;
|
|
19
16
|
}
|
|
17
|
+
}
|
|
18
|
+
class UndiciInstrumentation {
|
|
19
|
+
constructor(config = {}) {
|
|
20
|
+
// Keep ref to avoid https://github.com/nodejs/node/issues/42170 bug and for unsubscribing.
|
|
21
|
+
this._channelSubs = [];
|
|
22
|
+
this._spanFromReq = /* @__PURE__ */ new WeakMap();
|
|
23
|
+
// Caches trace-propagation decisions per URL so we don't recompute the `tracePropagationTargets` regexes per request.
|
|
24
|
+
this._propagationDecisionMap = new core.LRUMap(100);
|
|
25
|
+
this._config = config;
|
|
26
|
+
}
|
|
20
27
|
disable() {
|
|
21
|
-
super.disable();
|
|
22
28
|
this._channelSubs.forEach((sub) => sub.unsubscribe());
|
|
23
29
|
this._channelSubs.length = 0;
|
|
24
30
|
}
|
|
31
|
+
/** Subscribe to the undici diagnostics channels (idempotent). */
|
|
25
32
|
enable() {
|
|
26
|
-
super.enable();
|
|
27
|
-
this._channelSubs = this._channelSubs || [];
|
|
28
33
|
if (this._channelSubs.length > 0) {
|
|
29
34
|
return;
|
|
30
35
|
}
|
|
@@ -34,16 +39,6 @@ class UndiciInstrumentation extends instrumentation.InstrumentationBase {
|
|
|
34
39
|
this.subscribeToChannel("undici:request:trailers", this.onDone.bind(this));
|
|
35
40
|
this.subscribeToChannel("undici:request:error", this.onError.bind(this));
|
|
36
41
|
}
|
|
37
|
-
_updateMetricInstruments() {
|
|
38
|
-
this._httpClientDurationHistogram = this.meter.createHistogram(semanticConventions.METRIC_HTTP_CLIENT_REQUEST_DURATION, {
|
|
39
|
-
description: "Measures the duration of outbound HTTP requests.",
|
|
40
|
-
unit: "s",
|
|
41
|
-
valueType: api.ValueType.DOUBLE,
|
|
42
|
-
advice: {
|
|
43
|
-
explicitBucketBoundaries: [5e-3, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10]
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
42
|
subscribeToChannel(diagnosticChannel, onMessage) {
|
|
48
43
|
const [major = 0, minor = 0] = process.version.replace("v", "").split(".").map((n) => Number(n));
|
|
49
44
|
const useNewSubscribe = major > 18 || major === 18 && minor >= 19;
|
|
@@ -99,112 +94,79 @@ class UndiciInstrumentation extends instrumentation.InstrumentationBase {
|
|
|
99
94
|
// create the span and populate some atttributes, then link the span to the request for further
|
|
100
95
|
// span processing
|
|
101
96
|
onRequestCreated({ request }) {
|
|
102
|
-
const config = this.
|
|
97
|
+
const config = this._config;
|
|
103
98
|
const enabled = config.enabled !== false;
|
|
104
|
-
const shouldIgnoreReq =
|
|
99
|
+
const shouldIgnoreReq = safeExecute(
|
|
105
100
|
() => !enabled || request.method === "CONNECT" || config.ignoreRequestHook?.(request),
|
|
106
|
-
(e) => e &&
|
|
107
|
-
true
|
|
101
|
+
(e) => e && debugBuild.DEBUG_BUILD && core.debug.error("caught ignoreRequestHook error: ", e)
|
|
108
102
|
);
|
|
109
103
|
if (shouldIgnoreReq) {
|
|
110
104
|
return;
|
|
111
105
|
}
|
|
112
|
-
const startTime = core.timestampInSeconds();
|
|
113
106
|
let requestUrl;
|
|
114
107
|
try {
|
|
115
108
|
requestUrl = new url.URL(request.path, request.origin);
|
|
116
109
|
} catch (err) {
|
|
117
|
-
|
|
110
|
+
debugBuild.DEBUG_BUILD && core.debug.warn("could not determine url.full:", err);
|
|
118
111
|
return;
|
|
119
112
|
}
|
|
120
113
|
const urlScheme = requestUrl.protocol.replace(":", "");
|
|
121
114
|
const requestMethod = this.getRequestMethod(request.method);
|
|
122
115
|
const attributes = {
|
|
123
|
-
[
|
|
124
|
-
[
|
|
125
|
-
[
|
|
126
|
-
[
|
|
127
|
-
[
|
|
128
|
-
[
|
|
116
|
+
[semconv.ATTR_HTTP_REQUEST_METHOD]: requestMethod,
|
|
117
|
+
[semconv.ATTR_HTTP_REQUEST_METHOD_ORIGINAL]: request.method,
|
|
118
|
+
[semconv.ATTR_URL_FULL]: requestUrl.toString(),
|
|
119
|
+
[semconv.ATTR_URL_PATH]: requestUrl.pathname,
|
|
120
|
+
[semconv.ATTR_URL_QUERY]: requestUrl.search,
|
|
121
|
+
[semconv.ATTR_URL_SCHEME]: urlScheme
|
|
129
122
|
};
|
|
130
123
|
const schemePorts = { https: "443", http: "80" };
|
|
131
124
|
const serverAddress = requestUrl.hostname;
|
|
132
125
|
const serverPort = requestUrl.port || schemePorts[urlScheme];
|
|
133
|
-
attributes[
|
|
126
|
+
attributes[semconv.ATTR_SERVER_ADDRESS] = serverAddress;
|
|
134
127
|
if (serverPort && !isNaN(Number(serverPort))) {
|
|
135
|
-
attributes[
|
|
128
|
+
attributes[semconv.ATTR_SERVER_PORT] = Number(serverPort);
|
|
136
129
|
}
|
|
137
130
|
const headersMap = this.parseRequestHeaders(request);
|
|
138
131
|
const userAgentValues = headersMap.get("user-agent");
|
|
139
132
|
if (userAgentValues) {
|
|
140
133
|
const userAgent = Array.isArray(userAgentValues) ? userAgentValues[userAgentValues.length - 1] : userAgentValues;
|
|
141
|
-
attributes[
|
|
134
|
+
attributes[semconv.ATTR_USER_AGENT_ORIGINAL] = userAgent;
|
|
142
135
|
}
|
|
143
|
-
const hookAttributes =
|
|
136
|
+
const hookAttributes = safeExecute(
|
|
144
137
|
() => config.startSpanHook?.(request),
|
|
145
|
-
(e) => e &&
|
|
146
|
-
true
|
|
138
|
+
(e) => e && debugBuild.DEBUG_BUILD && core.debug.error("caught startSpanHook error: ", e)
|
|
147
139
|
);
|
|
148
140
|
if (hookAttributes) {
|
|
149
141
|
Object.entries(hookAttributes).forEach(([key, val]) => {
|
|
150
142
|
attributes[key] = val;
|
|
151
143
|
});
|
|
152
144
|
}
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
span = this.tracer.startSpan(
|
|
160
|
-
requestMethod === "_OTHER" ? "HTTP" : requestMethod,
|
|
161
|
-
{
|
|
162
|
-
kind: api.SpanKind.CLIENT,
|
|
163
|
-
attributes
|
|
164
|
-
},
|
|
165
|
-
activeCtx
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
instrumentation.safeExecuteInTheMiddle(
|
|
145
|
+
const span = core.startInactiveSpan({
|
|
146
|
+
name: requestMethod === "_OTHER" ? "HTTP" : requestMethod,
|
|
147
|
+
kind: SPAN_KIND_CLIENT,
|
|
148
|
+
attributes
|
|
149
|
+
});
|
|
150
|
+
safeExecute(
|
|
169
151
|
() => config.requestHook?.(span, request),
|
|
170
|
-
(e) => e &&
|
|
171
|
-
true
|
|
152
|
+
(e) => e && debugBuild.DEBUG_BUILD && core.debug.error("caught requestHook error: ", e)
|
|
172
153
|
);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
api.propagation.inject(requestContext, addedHeaders);
|
|
176
|
-
const headerEntries = Object.entries(addedHeaders);
|
|
177
|
-
for (let i = 0; i < headerEntries.length; i++) {
|
|
178
|
-
const pair = headerEntries[i];
|
|
179
|
-
if (!pair) {
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
const [k, v] = pair;
|
|
183
|
-
if (typeof request.addHeader === "function") {
|
|
184
|
-
request.addHeader(k, v);
|
|
185
|
-
} else if (typeof request.headers === "string") {
|
|
186
|
-
request.headers += `${k}: ${v}\r
|
|
187
|
-
`;
|
|
188
|
-
} else if (Array.isArray(request.headers)) {
|
|
189
|
-
request.headers.push(k, v);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
this._recordFromReq.set(request, { span, attributes, startTime });
|
|
154
|
+
this.injectTracePropagationHeaders(span, request, requestUrl.toString());
|
|
155
|
+
this._spanFromReq.set(request, span);
|
|
193
156
|
}
|
|
194
157
|
// This is the 2nd message we receive for each request. It is fired when connection with
|
|
195
158
|
// the remote is established and about to send the first byte. Here we do have info about the
|
|
196
159
|
// remote address and port so we can populate some `network.*` attributes into the span
|
|
197
160
|
onRequestHeaders({ request, socket }) {
|
|
198
|
-
const
|
|
199
|
-
if (!
|
|
161
|
+
const span = this._spanFromReq.get(request);
|
|
162
|
+
if (!span) {
|
|
200
163
|
return;
|
|
201
164
|
}
|
|
202
|
-
const config = this.
|
|
203
|
-
const { span } = record;
|
|
165
|
+
const config = this._config;
|
|
204
166
|
const { remoteAddress, remotePort } = socket;
|
|
205
167
|
const spanAttributes = {
|
|
206
|
-
[
|
|
207
|
-
[
|
|
168
|
+
[semconv.ATTR_NETWORK_PEER_ADDRESS]: remoteAddress,
|
|
169
|
+
[semconv.ATTR_NETWORK_PEER_PORT]: remotePort
|
|
208
170
|
};
|
|
209
171
|
if (config.headersToSpanAttributes?.requestHeaders) {
|
|
210
172
|
const headersToAttribs = new Set(config.headersToSpanAttributes.requestHeaders.map((n) => n.toLowerCase()));
|
|
@@ -222,19 +184,17 @@ class UndiciInstrumentation extends instrumentation.InstrumentationBase {
|
|
|
222
184
|
// headers are received, body may not be accessible yet.
|
|
223
185
|
// From the response headers we can set the status and content length
|
|
224
186
|
onResponseHeaders({ request, response }) {
|
|
225
|
-
const
|
|
226
|
-
if (!
|
|
187
|
+
const span = this._spanFromReq.get(request);
|
|
188
|
+
if (!span) {
|
|
227
189
|
return;
|
|
228
190
|
}
|
|
229
|
-
const { span, attributes } = record;
|
|
230
191
|
const spanAttributes = {
|
|
231
|
-
[
|
|
192
|
+
[semconv.ATTR_HTTP_RESPONSE_STATUS_CODE]: response.statusCode
|
|
232
193
|
};
|
|
233
|
-
const config = this.
|
|
234
|
-
|
|
194
|
+
const config = this._config;
|
|
195
|
+
safeExecute(
|
|
235
196
|
() => config.responseHook?.(span, { request, response }),
|
|
236
|
-
(e) => e &&
|
|
237
|
-
true
|
|
197
|
+
(e) => e && debugBuild.DEBUG_BUILD && core.debug.error("caught responseHook error: ", e)
|
|
238
198
|
);
|
|
239
199
|
if (config.headersToSpanAttributes?.responseHeaders) {
|
|
240
200
|
const headersToAttribs = /* @__PURE__ */ new Set();
|
|
@@ -258,21 +218,18 @@ class UndiciInstrumentation extends instrumentation.InstrumentationBase {
|
|
|
258
218
|
}
|
|
259
219
|
}
|
|
260
220
|
span.setAttributes(spanAttributes);
|
|
261
|
-
|
|
262
|
-
code:
|
|
263
|
-
}
|
|
264
|
-
record.attributes = Object.assign(attributes, spanAttributes);
|
|
221
|
+
if (response.statusCode >= 400) {
|
|
222
|
+
span.setStatus({ code: core.SPAN_STATUS_ERROR });
|
|
223
|
+
}
|
|
265
224
|
}
|
|
266
225
|
// This is the last event we receive if the request went without any errors
|
|
267
226
|
onDone({ request }) {
|
|
268
|
-
const
|
|
269
|
-
if (!
|
|
227
|
+
const span = this._spanFromReq.get(request);
|
|
228
|
+
if (!span) {
|
|
270
229
|
return;
|
|
271
230
|
}
|
|
272
|
-
const { span, attributes, startTime } = record;
|
|
273
231
|
span.end();
|
|
274
|
-
this.
|
|
275
|
-
this.recordRequestDuration(attributes, startTime);
|
|
232
|
+
this._spanFromReq.delete(request);
|
|
276
233
|
}
|
|
277
234
|
// This is the event we get when something is wrong in the request like
|
|
278
235
|
// - invalid options when calling `fetch` global API or any undici method for request
|
|
@@ -281,38 +238,45 @@ class UndiciInstrumentation extends instrumentation.InstrumentationBase {
|
|
|
281
238
|
// NOTE: server errors are considered valid responses and it's the lib consumer
|
|
282
239
|
// who should deal with that.
|
|
283
240
|
onError({ request, error }) {
|
|
284
|
-
const
|
|
285
|
-
if (!
|
|
241
|
+
const span = this._spanFromReq.get(request);
|
|
242
|
+
if (!span) {
|
|
286
243
|
return;
|
|
287
244
|
}
|
|
288
|
-
const { span, attributes, startTime } = record;
|
|
289
|
-
span.recordException(error);
|
|
290
245
|
span.setStatus({
|
|
291
|
-
code:
|
|
246
|
+
code: core.SPAN_STATUS_ERROR,
|
|
292
247
|
message: error.message
|
|
293
248
|
});
|
|
294
249
|
span.end();
|
|
295
|
-
this.
|
|
296
|
-
attributes[semanticConventions.ATTR_ERROR_TYPE] = error.message;
|
|
297
|
-
this.recordRequestDuration(attributes, startTime);
|
|
250
|
+
this._spanFromReq.delete(request);
|
|
298
251
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
252
|
+
// Propagate the trace data of the given (client) span into the outgoing request headers, gated by
|
|
253
|
+
// `tracePropagationTargets`. Mirrors what `propagation.inject()` did with the SentryPropagator, but
|
|
254
|
+
// via Sentry's `getTraceData()` so we stay off OpenTelemetry's propagation API.
|
|
255
|
+
injectTracePropagationHeaders(span, request, url) {
|
|
256
|
+
const { tracePropagationTargets, propagateTraceparent } = core.getClient()?.getOptions() ?? {};
|
|
257
|
+
if (!core.shouldPropagateTraceForUrl(url, tracePropagationTargets, this._propagationDecisionMap)) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const addedHeaders = core.withActiveSpan(span, () => core.getTraceData({ propagateTraceparent }));
|
|
261
|
+
const headerEntries = Object.entries(addedHeaders);
|
|
262
|
+
for (let i = 0; i < headerEntries.length; i++) {
|
|
263
|
+
const pair = headerEntries[i];
|
|
264
|
+
if (!pair) {
|
|
265
|
+
continue;
|
|
312
266
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
267
|
+
const [k, v] = pair;
|
|
268
|
+
if (!v) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (typeof request.addHeader === "function") {
|
|
272
|
+
request.addHeader(k, v);
|
|
273
|
+
} else if (typeof request.headers === "string") {
|
|
274
|
+
request.headers += `${k}: ${v}\r
|
|
275
|
+
`;
|
|
276
|
+
} else if (Array.isArray(request.headers)) {
|
|
277
|
+
request.headers.push(k, v);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
316
280
|
}
|
|
317
281
|
getRequestMethod(original) {
|
|
318
282
|
const knownMethods = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undici.js","sources":["../../../../../src/integrations/node-fetch/vendored/undici.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/ed97091c9890dd18e52759f2ea98e9d7593b3ae4/packages/instrumentation-undici\n * - Upstream version: @opentelemetry/instrumentation-undici@0.24.0\n * - Tracking issue: https://github.com/getsentry/sentry-javascript/issues/20165\n * - Minor TypeScript strictness adjustments for this repository's compiler settings\n */\n/* eslint-disable -- vendored @opentelemetry/instrumentation-undici (#20165) */\n\nimport * as diagch from 'diagnostics_channel';\nimport { URL } from 'url';\n\nimport { InstrumentationBase, safeExecuteInTheMiddle } from '@opentelemetry/instrumentation';\nimport type { Attributes, Histogram, Span } from '@opentelemetry/api';\nimport {\n context,\n INVALID_SPAN_CONTEXT,\n propagation,\n SpanKind,\n SpanStatusCode,\n trace,\n ValueType,\n} from '@opentelemetry/api';\nimport {\n ATTR_ERROR_TYPE,\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_REQUEST_METHOD_ORIGINAL,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_NETWORK_PEER_ADDRESS,\n ATTR_NETWORK_PEER_PORT,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n ATTR_URL_FULL,\n ATTR_URL_PATH,\n ATTR_URL_QUERY,\n ATTR_URL_SCHEME,\n ATTR_USER_AGENT_ORIGINAL,\n METRIC_HTTP_CLIENT_REQUEST_DURATION,\n} from '@opentelemetry/semantic-conventions';\n\nimport type {\n ListenerRecord,\n RequestHeadersMessage,\n RequestMessage,\n RequestTrailersMessage,\n ResponseHeadersMessage,\n} from './internal-types';\nimport type { UndiciInstrumentationConfig, UndiciRequest } from './types';\n\nimport { SDK_VERSION, timestampInSeconds } from '@sentry/core';\n\ninterface InstrumentationRecord {\n span: Span;\n attributes: Attributes;\n startTime: number;\n}\n\nconst PACKAGE_NAME = '@sentry/instrumentation-undici';\n\n// A combination of https://github.com/elastic/apm-agent-nodejs and\n// https://github.com/gadget-inc/opentelemetry-instrumentations/blob/main/packages/opentelemetry-instrumentation-undici/src/index.ts\nexport class UndiciInstrumentation extends InstrumentationBase<UndiciInstrumentationConfig> {\n // Keep ref to avoid https://github.com/nodejs/node/issues/42170 bug and for\n // unsubscribing.\n declare private _channelSubs: Array<ListenerRecord>;\n private _recordFromReq = new WeakMap<UndiciRequest, InstrumentationRecord>();\n\n declare private _httpClientDurationHistogram: Histogram;\n\n constructor(config: UndiciInstrumentationConfig = {}) {\n super(PACKAGE_NAME, SDK_VERSION, config);\n }\n\n // No need to instrument files/modules\n protected override init() {\n return undefined;\n }\n\n override disable(): void {\n super.disable();\n this._channelSubs.forEach(sub => sub.unsubscribe());\n this._channelSubs.length = 0;\n }\n\n override enable(): void {\n // \"enabled\" handling is currently a bit messy with InstrumentationBase.\n // If constructed with `{enabled: false}`, this `.enable()` is still called,\n // and `this.getConfig().enabled !== this.isEnabled()`, creating confusion.\n //\n // For now, this class will setup for instrumenting if `.enable()` is\n // called, but use `this.getConfig().enabled` to determine if\n // instrumentation should be generated. This covers the more likely common\n // case of config being given a construction time, rather than later via\n // `instance.enable()`, `.disable()`, or `.setConfig()` calls.\n super.enable();\n\n // This method is called by the super-class constructor before ours is\n // called. So we need to ensure the property is initalized.\n this._channelSubs = this._channelSubs || [];\n\n // Avoid to duplicate subscriptions\n if (this._channelSubs.length > 0) {\n return;\n }\n\n this.subscribeToChannel('undici:request:create', this.onRequestCreated.bind(this));\n this.subscribeToChannel('undici:client:sendHeaders', this.onRequestHeaders.bind(this));\n this.subscribeToChannel('undici:request:headers', this.onResponseHeaders.bind(this));\n this.subscribeToChannel('undici:request:trailers', this.onDone.bind(this));\n this.subscribeToChannel('undici:request:error', this.onError.bind(this));\n }\n\n protected override _updateMetricInstruments() {\n this._httpClientDurationHistogram = this.meter.createHistogram(METRIC_HTTP_CLIENT_REQUEST_DURATION, {\n description: 'Measures the duration of outbound HTTP requests.',\n unit: 's',\n valueType: ValueType.DOUBLE,\n advice: {\n explicitBucketBoundaries: [0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10],\n },\n });\n }\n\n private subscribeToChannel(diagnosticChannel: string, onMessage: (message: any, name: string | symbol) => void) {\n // `diagnostics_channel` had a ref counting bug until v18.19.0.\n // https://github.com/nodejs/node/pull/47520\n const [major = 0, minor = 0] = process.version\n .replace('v', '')\n .split('.')\n .map(n => Number(n));\n const useNewSubscribe = major > 18 || (major === 18 && minor >= 19);\n\n let unsubscribe: () => void;\n if (useNewSubscribe) {\n diagch.subscribe?.(diagnosticChannel, onMessage);\n unsubscribe = () => diagch.unsubscribe?.(diagnosticChannel, onMessage);\n } else {\n const channel = diagch.channel(diagnosticChannel);\n channel.subscribe(onMessage);\n unsubscribe = () => channel.unsubscribe(onMessage);\n }\n\n this._channelSubs.push({\n name: diagnosticChannel,\n unsubscribe,\n });\n }\n\n private parseRequestHeaders(request: UndiciRequest) {\n const result = new Map<string, string | string[]>();\n\n if (Array.isArray(request.headers)) {\n // headers are an array [k1, v2, k2, v2] (undici v6+)\n // values could be string or a string[] for multiple values\n for (let i = 0; i < request.headers.length; i += 2) {\n const key = request.headers[i];\n const value = request.headers[i + 1];\n\n // Key should always be a string, but the types don't know that, and let's be safe\n if (typeof key === 'string' && value !== undefined) {\n result.set(key.toLowerCase(), value);\n }\n }\n } else if (typeof request.headers === 'string') {\n // headers are a raw string (undici v5)\n // headers could be repeated in several lines for multiple values\n const headers = request.headers.split('\\r\\n');\n for (const line of headers) {\n if (!line) {\n continue;\n }\n const colonIndex = line.indexOf(':');\n if (colonIndex === -1) {\n // Invalid header? Probably this can't happen, but again let's be safe.\n continue;\n }\n const key = line.substring(0, colonIndex).toLowerCase();\n const value = line.substring(colonIndex + 1).trim();\n const allValues = result.get(key);\n\n if (allValues && Array.isArray(allValues)) {\n allValues.push(value);\n } else if (allValues) {\n result.set(key, [allValues, value]);\n } else {\n result.set(key, value);\n }\n }\n }\n return result;\n }\n\n // This is the 1st message we receive for each request (fired after request creation). Here we will\n // create the span and populate some atttributes, then link the span to the request for further\n // span processing\n private onRequestCreated({ request }: RequestMessage): void {\n // Ignore if:\n // - instrumentation is disabled\n // - ignored by config\n // - method is 'CONNECT'\n const config = this.getConfig();\n const enabled = config.enabled !== false;\n const shouldIgnoreReq = safeExecuteInTheMiddle(\n () => !enabled || request.method === 'CONNECT' || config.ignoreRequestHook?.(request),\n e => e && this._diag.error('caught ignoreRequestHook error: ', e),\n true,\n );\n\n if (shouldIgnoreReq) {\n return;\n }\n\n const startTime = timestampInSeconds();\n let requestUrl;\n try {\n requestUrl = new URL(request.path, request.origin);\n } catch (err) {\n this._diag.warn('could not determine url.full:', err);\n // Skip instrumenting this request.\n return;\n }\n const urlScheme = requestUrl.protocol.replace(':', '');\n const requestMethod = this.getRequestMethod(request.method);\n const attributes: Attributes = {\n [ATTR_HTTP_REQUEST_METHOD]: requestMethod,\n [ATTR_HTTP_REQUEST_METHOD_ORIGINAL]: request.method,\n [ATTR_URL_FULL]: requestUrl.toString(),\n [ATTR_URL_PATH]: requestUrl.pathname,\n [ATTR_URL_QUERY]: requestUrl.search,\n [ATTR_URL_SCHEME]: urlScheme,\n };\n\n const schemePorts: Record<string, string> = { https: '443', http: '80' };\n const serverAddress = requestUrl.hostname;\n const serverPort = requestUrl.port || schemePorts[urlScheme];\n\n attributes[ATTR_SERVER_ADDRESS] = serverAddress;\n if (serverPort && !isNaN(Number(serverPort))) {\n attributes[ATTR_SERVER_PORT] = Number(serverPort);\n }\n\n // Get user agent from headers\n const headersMap = this.parseRequestHeaders(request);\n const userAgentValues = headersMap.get('user-agent');\n\n if (userAgentValues) {\n // NOTE: having multiple user agents is not expected so\n // we're going to take last one like `curl` does\n // ref: https://curl.se/docs/manpage.html#-A\n const userAgent = Array.isArray(userAgentValues) ? userAgentValues[userAgentValues.length - 1] : userAgentValues;\n attributes[ATTR_USER_AGENT_ORIGINAL] = userAgent;\n }\n\n // Get attributes from the hook if present\n const hookAttributes = safeExecuteInTheMiddle(\n () => config.startSpanHook?.(request),\n e => e && this._diag.error('caught startSpanHook error: ', e),\n true,\n );\n if (hookAttributes) {\n Object.entries(hookAttributes).forEach(([key, val]) => {\n attributes[key] = val;\n });\n }\n\n // Check if parent span is required via config and:\n // - if a parent is required but not present, we use a `NoopSpan` to still\n // propagate context without recording it.\n // - create a span otherwise\n const activeCtx = context.active();\n const currentSpan = trace.getSpan(activeCtx);\n let span: Span;\n\n if (config.requireParentforSpans && (!currentSpan || !trace.isSpanContextValid(currentSpan.spanContext()))) {\n span = trace.wrapSpanContext(INVALID_SPAN_CONTEXT);\n } else {\n span = this.tracer.startSpan(\n requestMethod === '_OTHER' ? 'HTTP' : requestMethod,\n {\n kind: SpanKind.CLIENT,\n attributes: attributes,\n },\n activeCtx,\n );\n }\n\n // Execute the request hook if defined\n safeExecuteInTheMiddle(\n () => config.requestHook?.(span, request),\n e => e && this._diag.error('caught requestHook error: ', e),\n true,\n );\n\n // Context propagation goes last so no hook can tamper\n // the propagation headers\n const requestContext = trace.setSpan(context.active(), span);\n const addedHeaders: Record<string, string> = {};\n propagation.inject(requestContext, addedHeaders);\n\n const headerEntries = Object.entries(addedHeaders);\n\n for (let i = 0; i < headerEntries.length; i++) {\n const pair = headerEntries[i];\n if (!pair) {\n continue;\n }\n const [k, v] = pair;\n\n if (typeof request.addHeader === 'function') {\n request.addHeader(k, v);\n } else if (typeof request.headers === 'string') {\n request.headers += `${k}: ${v}\\r\\n`;\n } else if (Array.isArray(request.headers)) {\n // undici@6.11.0 accidentally, briefly removed `request.addHeader()`.\n request.headers.push(k, v);\n }\n }\n this._recordFromReq.set(request, { span, attributes, startTime });\n }\n\n // This is the 2nd message we receive for each request. It is fired when connection with\n // the remote is established and about to send the first byte. Here we do have info about the\n // remote address and port so we can populate some `network.*` attributes into the span\n private onRequestHeaders({ request, socket }: RequestHeadersMessage): void {\n const record = this._recordFromReq.get(request);\n\n if (!record) {\n return;\n }\n\n const config = this.getConfig();\n const { span } = record;\n const { remoteAddress, remotePort } = socket;\n const spanAttributes: Attributes = {\n [ATTR_NETWORK_PEER_ADDRESS]: remoteAddress,\n [ATTR_NETWORK_PEER_PORT]: remotePort,\n };\n\n // After hooks have been processed (which may modify request headers)\n // we can collect the headers based on the configuration\n if (config.headersToSpanAttributes?.requestHeaders) {\n const headersToAttribs = new Set(config.headersToSpanAttributes.requestHeaders.map(n => n.toLowerCase()));\n const headersMap = this.parseRequestHeaders(request);\n\n for (const [name, value] of headersMap.entries()) {\n if (headersToAttribs.has(name)) {\n const attrValue = Array.isArray(value) ? value : [value];\n spanAttributes[`http.request.header.${name}`] = attrValue;\n }\n }\n }\n\n span.setAttributes(spanAttributes);\n }\n\n // This is the 3rd message we get for each request and it's fired when the server\n // headers are received, body may not be accessible yet.\n // From the response headers we can set the status and content length\n private onResponseHeaders({ request, response }: ResponseHeadersMessage): void {\n const record = this._recordFromReq.get(request);\n\n if (!record) {\n return;\n }\n\n const { span, attributes } = record;\n const spanAttributes: Attributes = {\n [ATTR_HTTP_RESPONSE_STATUS_CODE]: response.statusCode,\n };\n\n const config = this.getConfig();\n\n // Execute the response hook if defined\n safeExecuteInTheMiddle(\n () => config.responseHook?.(span, { request, response }),\n e => e && this._diag.error('caught responseHook error: ', e),\n true,\n );\n\n if (config.headersToSpanAttributes?.responseHeaders) {\n const headersToAttribs = new Set();\n config.headersToSpanAttributes?.responseHeaders.forEach(name => headersToAttribs.add(name.toLowerCase()));\n\n for (let idx = 0; idx < response.headers.length; idx = idx + 2) {\n const nameBuf = response.headers[idx];\n const valueBuf = response.headers[idx + 1];\n if (nameBuf === undefined || valueBuf === undefined) {\n continue;\n }\n const name = nameBuf.toString().toLowerCase();\n const value = valueBuf;\n\n if (headersToAttribs.has(name)) {\n const attrName = `http.response.header.${name}`;\n if (!Object.prototype.hasOwnProperty.call(spanAttributes, attrName)) {\n spanAttributes[attrName] = [value.toString()];\n } else {\n (spanAttributes[attrName] as string[]).push(value.toString());\n }\n }\n }\n }\n\n span.setAttributes(spanAttributes);\n span.setStatus({\n code: response.statusCode >= 400 ? SpanStatusCode.ERROR : SpanStatusCode.UNSET,\n });\n record.attributes = Object.assign(attributes, spanAttributes);\n }\n\n // This is the last event we receive if the request went without any errors\n private onDone({ request }: RequestTrailersMessage): void {\n const record = this._recordFromReq.get(request);\n\n if (!record) {\n return;\n }\n\n const { span, attributes, startTime } = record;\n\n // End the span\n span.end();\n this._recordFromReq.delete(request);\n\n // Record metrics\n this.recordRequestDuration(attributes, startTime);\n }\n\n // This is the event we get when something is wrong in the request like\n // - invalid options when calling `fetch` global API or any undici method for request\n // - connectivity errors such as unreachable host\n // - requests aborted through an `AbortController.signal`\n // NOTE: server errors are considered valid responses and it's the lib consumer\n // who should deal with that.\n private onError({ request, error }: any): void {\n const record = this._recordFromReq.get(request);\n\n if (!record) {\n return;\n }\n\n const { span, attributes, startTime } = record;\n\n // NOTE: in `undici@6.3.0` when request aborted the error type changes from\n // a custom error (`RequestAbortedError`) to a built-in `DOMException` carrying\n // some differences:\n // - `code` is from DOMEXception (ABORT_ERR: 20)\n // - `message` changes\n // - stacktrace is smaller and contains node internal frames\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n span.end();\n this._recordFromReq.delete(request);\n\n // Record metrics (with the error)\n attributes[ATTR_ERROR_TYPE] = error.message;\n this.recordRequestDuration(attributes, startTime);\n }\n\n private recordRequestDuration(attributes: Attributes, startTime: number) {\n // Time to record metrics\n const metricsAttributes: Attributes = {};\n // Get the attribs already in span attributes\n const keysToCopy = [\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n ATTR_URL_SCHEME,\n ATTR_ERROR_TYPE,\n ];\n keysToCopy.forEach(key => {\n if (key in attributes) {\n metricsAttributes[key] = attributes[key];\n }\n });\n\n // Take the duration and record it\n const durationSeconds = timestampInSeconds() - startTime;\n this._httpClientDurationHistogram.record(durationSeconds, metricsAttributes);\n }\n\n private getRequestMethod(original: string): string {\n const knownMethods = {\n CONNECT: true,\n OPTIONS: true,\n HEAD: true,\n GET: true,\n POST: true,\n PUT: true,\n PATCH: true,\n DELETE: true,\n TRACE: true,\n // QUERY from https://datatracker.ietf.org/doc/draft-ietf-httpbis-safe-method-w-body/\n QUERY: true,\n };\n\n if (original.toUpperCase() in knownMethods) {\n return original.toUpperCase();\n }\n\n return '_OTHER';\n }\n}\n"],"names":["InstrumentationBase","SDK_VERSION","METRIC_HTTP_CLIENT_REQUEST_DURATION","ValueType","safeExecuteInTheMiddle","timestampInSeconds","URL","ATTR_HTTP_REQUEST_METHOD","ATTR_HTTP_REQUEST_METHOD_ORIGINAL","ATTR_URL_FULL","ATTR_URL_PATH","ATTR_URL_QUERY","ATTR_URL_SCHEME","ATTR_SERVER_ADDRESS","ATTR_SERVER_PORT","ATTR_USER_AGENT_ORIGINAL","context","trace","INVALID_SPAN_CONTEXT","SpanKind","propagation","ATTR_NETWORK_PEER_ADDRESS","ATTR_NETWORK_PEER_PORT","ATTR_HTTP_RESPONSE_STATUS_CODE","SpanStatusCode","ATTR_ERROR_TYPE"],"mappings":";;;;;;;;;AA4DA,MAAM,YAAA,GAAe,gCAAA;AAId,MAAM,8BAA8BA,mCAAA,CAAiD;AAAA,EAQ1F,WAAA,CAAY,MAAA,GAAsC,EAAC,EAAG;AACpD,IAAA,KAAA,CAAM,YAAA,EAAcC,kBAAa,MAAM,CAAA;AALz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ACR,KAAA,EAAO,IAAA;AAAA;AAAA,MAEP,KAAA,EAAO;AAAA,KACT;AAEA,IAAA,IAAI,QAAA,CAAS,WAAA,EAAY,IAAK,YAAA,EAAc;AAC1C,MAAA,OAAO,SAAS,WAAA,EAAY;AAAA,IAC9B;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"undici.js","sources":["../../../../../src/integrations/node-fetch/vendored/undici.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/ed97091c9890dd18e52759f2ea98e9d7593b3ae4/packages/instrumentation-undici\n * - Upstream version: @opentelemetry/instrumentation-undici@0.24.0\n * - Tracking issue: https://github.com/getsentry/sentry-javascript/issues/20165\n * - Refactored to use Sentry's span APIs instead of OpenTelemetry tracing APIs\n * - Dropped the OTel metrics (no MeterProvider is wired up) and the dead\n * `requireParentforSpans` code path (the SDK always passes `false`)\n * - Dropped the `@opentelemetry/instrumentation` base (undici reports via `diagnostics_channel`,\n * so no module patching was needed) — now a plain class wired up directly by the integration\n */\n\nimport * as diagch from 'diagnostics_channel';\nimport { URL } from 'url';\n\nimport type { Span, SpanAttributes } from '@sentry/core';\nimport {\n debug,\n getClient,\n getTraceData,\n LRUMap,\n shouldPropagateTraceForUrl,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n withActiveSpan,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../../debug-build';\nimport {\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_REQUEST_METHOD_ORIGINAL,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_NETWORK_PEER_ADDRESS,\n ATTR_NETWORK_PEER_PORT,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n ATTR_URL_FULL,\n ATTR_URL_PATH,\n ATTR_URL_QUERY,\n ATTR_URL_SCHEME,\n ATTR_USER_AGENT_ORIGINAL,\n} from './semconv';\n\nimport type {\n ListenerRecord,\n RequestErrorMessage,\n RequestHeadersMessage,\n RequestMessage,\n RequestTrailersMessage,\n ResponseHeadersMessage,\n} from './internal-types';\nimport type { UndiciInstrumentationConfig, UndiciRequest } from './types';\n\n// `SpanKind.CLIENT`, inlined to avoid importing from `@opentelemetry/api`.\nconst SPAN_KIND_CLIENT = 2;\n\n/** Replaces OTel's `safeExecuteInTheMiddle`: run `fn`, route any error to `onError`, and swallow it. */\nfunction safeExecute<T>(fn: () => T, onError: (error: unknown) => void): T | undefined {\n try {\n return fn();\n } catch (error) {\n onError(error);\n return undefined;\n }\n}\n\n// A combination of https://github.com/elastic/apm-agent-nodejs and\n// https://github.com/gadget-inc/opentelemetry-instrumentations/blob/main/packages/opentelemetry-instrumentation-undici/src/index.ts\n//\n// Not an OTel `InstrumentationBase` (undici reports via `diagnostics_channel`, not module patching);\n// the integration wires this up directly via `enable()` / `disable()`.\nexport class UndiciInstrumentation {\n // Keep ref to avoid https://github.com/nodejs/node/issues/42170 bug and for unsubscribing.\n private _channelSubs: Array<ListenerRecord> = [];\n private _spanFromReq = new WeakMap<UndiciRequest, Span>();\n // Caches trace-propagation decisions per URL so we don't recompute the `tracePropagationTargets` regexes per request.\n private _propagationDecisionMap = new LRUMap<string, boolean>(100);\n private _config: UndiciInstrumentationConfig;\n\n constructor(config: UndiciInstrumentationConfig = {}) {\n this._config = config;\n }\n\n public disable(): void {\n this._channelSubs.forEach(sub => sub.unsubscribe());\n this._channelSubs.length = 0;\n }\n\n /** Subscribe to the undici diagnostics channels (idempotent). */\n public enable(): void {\n // Avoid duplicate subscriptions\n if (this._channelSubs.length > 0) {\n return;\n }\n\n this.subscribeToChannel('undici:request:create', this.onRequestCreated.bind(this));\n this.subscribeToChannel('undici:client:sendHeaders', this.onRequestHeaders.bind(this));\n this.subscribeToChannel('undici:request:headers', this.onResponseHeaders.bind(this));\n this.subscribeToChannel('undici:request:trailers', this.onDone.bind(this));\n this.subscribeToChannel('undici:request:error', this.onError.bind(this));\n }\n\n private subscribeToChannel(\n diagnosticChannel: string,\n onMessage: (message: any, name: string | symbol) => void,\n ): void {\n // `diagnostics_channel` had a ref counting bug until v18.19.0.\n // https://github.com/nodejs/node/pull/47520\n const [major = 0, minor = 0] = process.version\n .replace('v', '')\n .split('.')\n .map(n => Number(n));\n const useNewSubscribe = major > 18 || (major === 18 && minor >= 19);\n\n let unsubscribe: () => void;\n if (useNewSubscribe) {\n diagch.subscribe?.(diagnosticChannel, onMessage);\n unsubscribe = () => diagch.unsubscribe?.(diagnosticChannel, onMessage);\n } else {\n const channel = diagch.channel(diagnosticChannel);\n channel.subscribe(onMessage);\n unsubscribe = () => channel.unsubscribe(onMessage);\n }\n\n this._channelSubs.push({\n name: diagnosticChannel,\n unsubscribe,\n });\n }\n\n private parseRequestHeaders(request: UndiciRequest): Map<string, string | string[]> {\n const result = new Map<string, string | string[]>();\n\n if (Array.isArray(request.headers)) {\n // headers are an array [k1, v2, k2, v2] (undici v6+)\n // values could be string or a string[] for multiple values\n for (let i = 0; i < request.headers.length; i += 2) {\n const key = request.headers[i];\n const value = request.headers[i + 1];\n\n // Key should always be a string, but the types don't know that, and let's be safe\n if (typeof key === 'string' && value !== undefined) {\n result.set(key.toLowerCase(), value);\n }\n }\n } else if (typeof request.headers === 'string') {\n // headers are a raw string (undici v5)\n // headers could be repeated in several lines for multiple values\n const headers = request.headers.split('\\r\\n');\n for (const line of headers) {\n if (!line) {\n continue;\n }\n const colonIndex = line.indexOf(':');\n if (colonIndex === -1) {\n // Invalid header? Probably this can't happen, but again let's be safe.\n continue;\n }\n const key = line.substring(0, colonIndex).toLowerCase();\n const value = line.substring(colonIndex + 1).trim();\n const allValues = result.get(key);\n\n if (allValues && Array.isArray(allValues)) {\n allValues.push(value);\n } else if (allValues) {\n result.set(key, [allValues, value]);\n } else {\n result.set(key, value);\n }\n }\n }\n return result;\n }\n\n // This is the 1st message we receive for each request (fired after request creation). Here we will\n // create the span and populate some atttributes, then link the span to the request for further\n // span processing\n private onRequestCreated({ request }: RequestMessage): void {\n // Ignore if:\n // - instrumentation is disabled\n // - ignored by config\n // - method is 'CONNECT'\n const config = this._config;\n const enabled = config.enabled !== false;\n const shouldIgnoreReq = safeExecute(\n () => !enabled || request.method === 'CONNECT' || config.ignoreRequestHook?.(request),\n e => e && DEBUG_BUILD && debug.error('caught ignoreRequestHook error: ', e),\n );\n\n if (shouldIgnoreReq) {\n return;\n }\n\n let requestUrl;\n try {\n requestUrl = new URL(request.path, request.origin);\n } catch (err) {\n DEBUG_BUILD && debug.warn('could not determine url.full:', err);\n // Skip instrumenting this request.\n return;\n }\n const urlScheme = requestUrl.protocol.replace(':', '');\n const requestMethod = this.getRequestMethod(request.method);\n const attributes: SpanAttributes = {\n [ATTR_HTTP_REQUEST_METHOD]: requestMethod,\n [ATTR_HTTP_REQUEST_METHOD_ORIGINAL]: request.method,\n [ATTR_URL_FULL]: requestUrl.toString(),\n [ATTR_URL_PATH]: requestUrl.pathname,\n [ATTR_URL_QUERY]: requestUrl.search,\n [ATTR_URL_SCHEME]: urlScheme,\n };\n\n const schemePorts: Record<string, string> = { https: '443', http: '80' };\n const serverAddress = requestUrl.hostname;\n const serverPort = requestUrl.port || schemePorts[urlScheme];\n\n attributes[ATTR_SERVER_ADDRESS] = serverAddress;\n if (serverPort && !isNaN(Number(serverPort))) {\n attributes[ATTR_SERVER_PORT] = Number(serverPort);\n }\n\n // Get user agent from headers\n const headersMap = this.parseRequestHeaders(request);\n const userAgentValues = headersMap.get('user-agent');\n\n if (userAgentValues) {\n // NOTE: having multiple user agents is not expected so\n // we're going to take last one like `curl` does\n // ref: https://curl.se/docs/manpage.html#-A\n const userAgent = Array.isArray(userAgentValues) ? userAgentValues[userAgentValues.length - 1] : userAgentValues;\n attributes[ATTR_USER_AGENT_ORIGINAL] = userAgent;\n }\n\n // Get attributes from the hook if present\n const hookAttributes = safeExecute(\n () => config.startSpanHook?.(request),\n e => e && DEBUG_BUILD && debug.error('caught startSpanHook error: ', e),\n );\n if (hookAttributes) {\n Object.entries(hookAttributes).forEach(([key, val]) => {\n attributes[key] = val;\n });\n }\n\n const span = startInactiveSpan({\n name: requestMethod === '_OTHER' ? 'HTTP' : requestMethod,\n kind: SPAN_KIND_CLIENT,\n attributes,\n });\n\n // Execute the request hook if defined\n safeExecute(\n () => config.requestHook?.(span, request),\n e => e && DEBUG_BUILD && debug.error('caught requestHook error: ', e),\n );\n\n // Context propagation goes last so no hook can tamper the propagation headers.\n // We propagate the trace data of the freshly created client span (not the active parent span)\n // so downstream services are parented to the http.client span, matching the upstream behavior.\n this.injectTracePropagationHeaders(span, request, requestUrl.toString());\n\n this._spanFromReq.set(request, span);\n }\n\n // This is the 2nd message we receive for each request. It is fired when connection with\n // the remote is established and about to send the first byte. Here we do have info about the\n // remote address and port so we can populate some `network.*` attributes into the span\n private onRequestHeaders({ request, socket }: RequestHeadersMessage): void {\n const span = this._spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n const config = this._config;\n const { remoteAddress, remotePort } = socket;\n const spanAttributes: SpanAttributes = {\n [ATTR_NETWORK_PEER_ADDRESS]: remoteAddress,\n [ATTR_NETWORK_PEER_PORT]: remotePort,\n };\n\n // After hooks have been processed (which may modify request headers)\n // we can collect the headers based on the configuration\n if (config.headersToSpanAttributes?.requestHeaders) {\n const headersToAttribs = new Set(config.headersToSpanAttributes.requestHeaders.map(n => n.toLowerCase()));\n const headersMap = this.parseRequestHeaders(request);\n\n for (const [name, value] of headersMap.entries()) {\n if (headersToAttribs.has(name)) {\n const attrValue = Array.isArray(value) ? value : [value];\n spanAttributes[`http.request.header.${name}`] = attrValue;\n }\n }\n }\n\n span.setAttributes(spanAttributes);\n }\n\n // This is the 3rd message we get for each request and it's fired when the server\n // headers are received, body may not be accessible yet.\n // From the response headers we can set the status and content length\n private onResponseHeaders({ request, response }: ResponseHeadersMessage): void {\n const span = this._spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n const spanAttributes: SpanAttributes = {\n [ATTR_HTTP_RESPONSE_STATUS_CODE]: response.statusCode,\n };\n\n const config = this._config;\n\n // Execute the response hook if defined\n safeExecute(\n () => config.responseHook?.(span, { request, response }),\n e => e && DEBUG_BUILD && debug.error('caught responseHook error: ', e),\n );\n\n if (config.headersToSpanAttributes?.responseHeaders) {\n const headersToAttribs = new Set<string>();\n config.headersToSpanAttributes?.responseHeaders.forEach(name => headersToAttribs.add(name.toLowerCase()));\n\n for (let idx = 0; idx < response.headers.length; idx = idx + 2) {\n const nameBuf = response.headers[idx];\n const valueBuf = response.headers[idx + 1];\n if (nameBuf === undefined || valueBuf === undefined) {\n continue;\n }\n const name = nameBuf.toString().toLowerCase();\n const value = valueBuf;\n\n if (headersToAttribs.has(name)) {\n const attrName = `http.response.header.${name}`;\n if (!Object.prototype.hasOwnProperty.call(spanAttributes, attrName)) {\n spanAttributes[attrName] = [value.toString()];\n } else {\n (spanAttributes[attrName] as string[]).push(value.toString());\n }\n }\n }\n }\n\n span.setAttributes(spanAttributes);\n\n // The Sentry pipeline infers `ok` / `not_found` / etc. from `http.response.status_code` when the\n // status is left unset, so we only need to flag erroneous responses explicitly.\n if (response.statusCode >= 400) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n }\n }\n\n // This is the last event we receive if the request went without any errors\n private onDone({ request }: RequestTrailersMessage): void {\n const span = this._spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n span.end();\n this._spanFromReq.delete(request);\n }\n\n // This is the event we get when something is wrong in the request like\n // - invalid options when calling `fetch` global API or any undici method for request\n // - connectivity errors such as unreachable host\n // - requests aborted through an `AbortController.signal`\n // NOTE: server errors are considered valid responses and it's the lib consumer\n // who should deal with that.\n private onError({ request, error }: RequestErrorMessage): void {\n const span = this._spanFromReq.get(request);\n\n if (!span) {\n return;\n }\n\n // NOTE: in `undici@6.3.0` when request aborted the error type changes from\n // a custom error (`RequestAbortedError`) to a built-in `DOMException` carrying\n // some differences:\n // - `code` is from DOMEXception (ABORT_ERR: 20)\n // - `message` changes\n // - stacktrace is smaller and contains node internal frames\n span.setStatus({\n code: SPAN_STATUS_ERROR,\n message: error.message,\n });\n span.end();\n this._spanFromReq.delete(request);\n }\n\n // Propagate the trace data of the given (client) span into the outgoing request headers, gated by\n // `tracePropagationTargets`. Mirrors what `propagation.inject()` did with the SentryPropagator, but\n // via Sentry's `getTraceData()` so we stay off OpenTelemetry's propagation API.\n private injectTracePropagationHeaders(span: Span, request: UndiciRequest, url: string): void {\n const { tracePropagationTargets, propagateTraceparent } = getClient()?.getOptions() ?? {};\n\n if (!shouldPropagateTraceForUrl(url, tracePropagationTargets, this._propagationDecisionMap)) {\n return;\n }\n\n // We make the freshly created client span active so the propagated headers reference it (and not\n // the parent span). Passing `{ span }` to `getTraceData()` is not enough: for an inactive span it\n // resolves to the span's *captured* scope, whose active span is still the parent.\n const addedHeaders = withActiveSpan(span, () => getTraceData({ propagateTraceparent }));\n\n const headerEntries = Object.entries(addedHeaders);\n\n for (let i = 0; i < headerEntries.length; i++) {\n const pair = headerEntries[i];\n if (!pair) {\n continue;\n }\n const [k, v] = pair;\n if (!v) {\n continue;\n }\n\n if (typeof request.addHeader === 'function') {\n request.addHeader(k, v);\n } else if (typeof request.headers === 'string') {\n request.headers += `${k}: ${v}\\r\\n`;\n } else if (Array.isArray(request.headers)) {\n // undici@6.11.0 accidentally, briefly removed `request.addHeader()`.\n request.headers.push(k, v);\n }\n }\n }\n\n private getRequestMethod(original: string): string {\n const knownMethods = {\n CONNECT: true,\n OPTIONS: true,\n HEAD: true,\n GET: true,\n POST: true,\n PUT: true,\n PATCH: true,\n DELETE: true,\n TRACE: true,\n // QUERY from https://datatracker.ietf.org/doc/draft-ietf-httpbis-safe-method-w-body/\n QUERY: true,\n };\n\n if (original.toUpperCase() in knownMethods) {\n return original.toUpperCase();\n }\n\n return '_OTHER';\n }\n}\n"],"names":["LRUMap","DEBUG_BUILD","debug","URL","ATTR_HTTP_REQUEST_METHOD","ATTR_HTTP_REQUEST_METHOD_ORIGINAL","ATTR_URL_FULL","ATTR_URL_PATH","ATTR_URL_QUERY","ATTR_URL_SCHEME","ATTR_SERVER_ADDRESS","ATTR_SERVER_PORT","ATTR_USER_AGENT_ORIGINAL","startInactiveSpan","ATTR_NETWORK_PEER_ADDRESS","ATTR_NETWORK_PEER_PORT","ATTR_HTTP_RESPONSE_STATUS_CODE","SPAN_STATUS_ERROR","getClient","shouldPropagateTraceForUrl","withActiveSpan","getTraceData"],"mappings":";;;;;;;;AAwDA,MAAM,gBAAA,GAAmB,CAAA;AAGzB,SAAS,WAAA,CAAe,IAAa,OAAA,EAAkD;AACrF,EAAA,IAAI;AACF,IAAA,OAAO,EAAA,EAAG;AAAA,EACZ,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,KAAK,CAAA;AACb,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAOO,MAAM,qBAAA,CAAsB;AAAA,EAQjC,WAAA,CAAY,MAAA,GAAsC,EAAC,EAAG;AANtD;AAAA,IAAA,IAAA,CAAQ,eAAsC,EAAC;AAC/C,IAAA,IAAA,CAAQ,YAAA,uBAAmB,OAAA,EAA6B;AAExD;AAAA,IAAA,IAAA,CAAQ,uBAAA,GAA0B,IAAIA,WAAA,CAAwB,GAAG,CAAA;AAI/D,IAAA,IAAA,CAAK,OAAA,GAAU,MAAA;AAAA,EACjB;AAAA,EAEO,OAAA,GAAgB;AACrB,IAAA,IAAA,CAAK,YAAA,CAAa,OAAA,CAAQ,CAAA,GAAA,KAAO,GAAA,CAAI,aAAa,CAAA;AAClD,IAAA,IAAA,CAAK,aAAa,MAAA,GAAS,CAAA;AAAA,EAC7B;AAAA;AAAA,EAGO,MAAA,GAAe;AAEpB,IAAA,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,GAAS,CAAA,EAAG;AAChC,MAAA;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,mBAAmB,uBAAA,EAAyB,IA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AAA,EAAK,IAAA;AAAA,MACL,KAAA,EAAO,IAAA;AAAA,MACP,MAAA,EAAQ,IAAA;AAAA,MACR,KAAA,EAAO,IAAA;AAAA;AAAA,MAEP,KAAA,EAAO;AAAA,KACT;AAEA,IAAA,IAAI,QAAA,CAAS,WAAA,EAAY,IAAK,YAAA,EAAc;AAC1C,MAAA,OAAO,SAAS,WAAA,EAAY;AAAA,IAC9B;AAEA,IAAA,OAAO,QAAA;AAAA,EACT;AACF;;;;"}
|
|
@@ -5,17 +5,7 @@ const core = require('@sentry/core');
|
|
|
5
5
|
const nodeCore = require('@sentry/node-core');
|
|
6
6
|
|
|
7
7
|
const INTEGRATION_NAME = "Kafka";
|
|
8
|
-
const instrumentKafka = nodeCore.generateInstrumentOnce(
|
|
9
|
-
INTEGRATION_NAME,
|
|
10
|
-
() => new instrumentation.KafkaJsInstrumentation({
|
|
11
|
-
consumerHook(span) {
|
|
12
|
-
nodeCore.addOriginToSpan(span, "auto.kafkajs.otel.consumer");
|
|
13
|
-
},
|
|
14
|
-
producerHook(span) {
|
|
15
|
-
nodeCore.addOriginToSpan(span, "auto.kafkajs.otel.producer");
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
);
|
|
8
|
+
const instrumentKafka = nodeCore.generateInstrumentOnce(INTEGRATION_NAME, () => new instrumentation.KafkaJsInstrumentation());
|
|
19
9
|
const _kafkaIntegration = (() => {
|
|
20
10
|
return {
|
|
21
11
|
name: INTEGRATION_NAME,
|