@sentry/node 10.59.0 → 10.61.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 +3 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/integrations/fs/index.js +8 -17
- package/build/cjs/integrations/fs/index.js.map +1 -1
- package/build/cjs/integrations/fs/vendored/instrumentation.js +110 -161
- package/build/cjs/integrations/fs/vendored/instrumentation.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 +90 -127
- package/build/cjs/integrations/node-fetch/vendored/undici.js.map +1 -1
- package/build/cjs/integrations/tracing/dataloader/vendored/instrumentation.js +5 -6
- package/build/cjs/integrations/tracing/dataloader/vendored/instrumentation.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/integrations/tracing/knex/vendored/instrumentation.js +1 -2
- package/build/cjs/integrations/tracing/knex/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/mongo/vendored/utils.js +1 -2
- package/build/cjs/integrations/tracing/mongo/vendored/utils.js.map +1 -1
- package/build/cjs/integrations/tracing/mongoose/vendored/mongoose.js +1 -2
- package/build/cjs/integrations/tracing/mongoose/vendored/mongoose.js.map +1 -1
- package/build/cjs/integrations/tracing/mysql2/vendored/instrumentation.js +1 -2
- package/build/cjs/integrations/tracing/mysql2/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/postgres/vendored/instrumentation.js +2 -3
- package/build/cjs/integrations/tracing/postgres/vendored/instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/postgres/vendored/utils.js +1 -2
- package/build/cjs/integrations/tracing/postgres/vendored/utils.js.map +1 -1
- package/build/cjs/integrations/tracing/redis/index.js +4 -2
- package/build/cjs/integrations/tracing/redis/index.js.map +1 -1
- package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js +2 -3
- package/build/cjs/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js +3 -4
- package/build/cjs/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -1
- package/build/cjs/integrations/tracing/tedious/vendored/instrumentation.js +1 -2
- package/build/cjs/integrations/tracing/tedious/vendored/instrumentation.js.map +1 -1
- 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/fs/index.js +9 -18
- package/build/esm/integrations/fs/index.js.map +1 -1
- package/build/esm/integrations/fs/vendored/instrumentation.js +111 -162
- package/build/esm/integrations/fs/vendored/instrumentation.js.map +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 +79 -116
- package/build/esm/integrations/node-fetch/vendored/undici.js.map +1 -1
- package/build/esm/integrations/tracing/dataloader/vendored/instrumentation.js +6 -7
- package/build/esm/integrations/tracing/dataloader/vendored/instrumentation.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/integrations/tracing/knex/vendored/instrumentation.js +2 -3
- package/build/esm/integrations/tracing/knex/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/mongo/vendored/utils.js +2 -3
- package/build/esm/integrations/tracing/mongo/vendored/utils.js.map +1 -1
- package/build/esm/integrations/tracing/mongoose/vendored/mongoose.js +2 -3
- package/build/esm/integrations/tracing/mongoose/vendored/mongoose.js.map +1 -1
- package/build/esm/integrations/tracing/mysql2/vendored/instrumentation.js +2 -3
- package/build/esm/integrations/tracing/mysql2/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/postgres/vendored/instrumentation.js +3 -4
- package/build/esm/integrations/tracing/postgres/vendored/instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/postgres/vendored/utils.js +2 -3
- package/build/esm/integrations/tracing/postgres/vendored/utils.js.map +1 -1
- package/build/esm/integrations/tracing/redis/index.js +4 -2
- package/build/esm/integrations/tracing/redis/index.js.map +1 -1
- package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js +3 -4
- package/build/esm/integrations/tracing/redis/vendored/ioredis-instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js +4 -5
- package/build/esm/integrations/tracing/redis/vendored/redis-instrumentation.js.map +1 -1
- package/build/esm/integrations/tracing/tedious/vendored/instrumentation.js +2 -3
- package/build/esm/integrations/tracing/tedious/vendored/instrumentation.js.map +1 -1
- 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/fs/index.d.ts +2 -14
- package/build/types/integrations/fs/index.d.ts.map +1 -1
- package/build/types/integrations/fs/vendored/instrumentation.d.ts +2 -10
- package/build/types/integrations/fs/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/fs/vendored/types.d.ts +1 -2
- package/build/types/integrations/fs/vendored/types.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/dataloader/vendored/instrumentation.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/integrations/tracing/knex/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongo/vendored/utils.d.ts.map +1 -1
- package/build/types/integrations/tracing/mongoose/vendored/mongoose.d.ts.map +1 -1
- package/build/types/integrations/tracing/mysql2/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgres/vendored/instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/postgres/vendored/utils.d.ts.map +1 -1
- package/build/types/integrations/tracing/redis/index.d.ts.map +1 -1
- package/build/types/integrations/tracing/redis/vendored/ioredis-instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/redis/vendored/redis-instrumentation.d.ts.map +1 -1
- package/build/types/integrations/tracing/tedious/vendored/instrumentation.d.ts.map +1 -1
- 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/fs/index.d.ts +2 -14
- package/build/types-ts3.8/integrations/fs/vendored/instrumentation.d.ts +2 -10
- package/build/types-ts3.8/integrations/fs/vendored/types.d.ts +1 -2
- 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
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { UndiciInstrumentation } from './vendored/undici.js';
|
|
2
|
-
import { defineIntegration, stripDataUrlContent, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, SEMANTIC_ATTRIBUTE_URL_FULL, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN
|
|
2
|
+
import { defineIntegration, getClient, hasSpansEnabled, stripDataUrlContent, SEMANTIC_ATTRIBUTE_SENTRY_CUSTOM_SPAN_NAME, SEMANTIC_ATTRIBUTE_URL_FULL, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
3
3
|
import { generateInstrumentOnce, SentryNodeFetchInstrumentation } from '@sentry/node-core';
|
|
4
4
|
|
|
5
5
|
const INTEGRATION_NAME = "NodeFetch";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return _getConfigWithDefaults(options);
|
|
6
|
+
let _undiciInstrumentation;
|
|
7
|
+
function instrumentNodeFetchSpans(options) {
|
|
8
|
+
if (!_undiciInstrumentation) {
|
|
9
|
+
_undiciInstrumentation = new UndiciInstrumentation(_getConfigWithDefaults(options));
|
|
11
10
|
}
|
|
12
|
-
);
|
|
11
|
+
_undiciInstrumentation.enable();
|
|
12
|
+
}
|
|
13
13
|
const instrumentSentryNodeFetch = generateInstrumentOnce(
|
|
14
14
|
`${INTEGRATION_NAME}.sentry`,
|
|
15
15
|
SentryNodeFetchInstrumentation,
|
|
@@ -23,7 +23,7 @@ const _nativeNodeFetchIntegration = ((options = {}) => {
|
|
|
23
23
|
setupOnce() {
|
|
24
24
|
const instrumentSpans = _shouldInstrumentSpans(options, getClient()?.getOptions());
|
|
25
25
|
if (instrumentSpans) {
|
|
26
|
-
|
|
26
|
+
instrumentNodeFetchSpans(options);
|
|
27
27
|
}
|
|
28
28
|
instrumentSentryNodeFetch(options);
|
|
29
29
|
}
|
|
@@ -45,7 +45,6 @@ function _shouldInstrumentSpans(options, clientOptions = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
function _getConfigWithDefaults(options = {}) {
|
|
47
47
|
const instrumentationConfig = {
|
|
48
|
-
requireParentforSpans: false,
|
|
49
48
|
ignoreRequestHook: (request) => {
|
|
50
49
|
const url = getAbsoluteUrl(request.origin, request.path);
|
|
51
50
|
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":[],"mappings":";;;;AAgBA,MAAM,gBAAA,GAAmB,WAAA;AAuCzB,IAAI,sBAAA;AAIJ,SAAS,yBAAyB,OAAA,EAAiC;AACjE,EAAA,IAAI,CAAC,sBAAA,EAAwB;AAC3B,IAAA,sBAAA,GAAyB,IAAI,qBAAA,CAAsB,sBAAA,CAAuB,OAAO,CAAC,CAAA;AAAA,EACpF;AACA,EAAA,sBAAA,CAAuB,MAAA,EAAO;AAChC;AAEA,MAAM,yBAAA,GAA4B,sBAAA;AAAA,EAChC,GAAG,gBAAgB,CAAA,OAAA,CAAA;AAAA,EACnB,8BAAA;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,EAAS,SAAA,EAAsB,EAAG,YAAY,CAAA;AAG7F,MAAA,IAAI,eAAA,EAAiB;AACnB,QAAA,wBAAA,CAAyB,OAAO,CAAA;AAAA,MAClC;AAKA,MAAA,yBAAA,CAA0B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AAA,OAAO,CAAC,CAAC,YAAA;AAAA,IACX,CAAA;AAAA,IACA,eAAe,CAAA,OAAA,KAAW;AACxB,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,GAAe,oBAAoB,GAAG,CAAA;AAC5C,QAAA,OAAO;AAAA,UACL,CAAC,gCAAgC,GAAG,2BAAA;AAAA,UACpC,UAAA,EAAY,YAAA;AAAA,UACZ,CAAC,2BAA2B,GAAG,YAAA;AAAA,UAC/B,CAAC,0CAA0C,GAAG,CAAA,EAAG,QAAQ,MAAA,IAAU,KAAK,IAAI,YAAY,CAAA;AAAA,SAC1F;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,CAAC,gCAAgC,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,15 @@
|
|
|
1
|
+
const ATTR_HTTP_REQUEST_METHOD = "http.request.method";
|
|
2
|
+
const ATTR_HTTP_REQUEST_METHOD_ORIGINAL = "http.request.method_original";
|
|
3
|
+
const ATTR_HTTP_RESPONSE_STATUS_CODE = "http.response.status_code";
|
|
4
|
+
const ATTR_NETWORK_PEER_ADDRESS = "network.peer.address";
|
|
5
|
+
const ATTR_NETWORK_PEER_PORT = "network.peer.port";
|
|
6
|
+
const ATTR_SERVER_ADDRESS = "server.address";
|
|
7
|
+
const ATTR_SERVER_PORT = "server.port";
|
|
8
|
+
const ATTR_URL_FULL = "url.full";
|
|
9
|
+
const ATTR_URL_PATH = "url.path";
|
|
10
|
+
const ATTR_URL_QUERY = "url.query";
|
|
11
|
+
const ATTR_URL_SCHEME = "url.scheme";
|
|
12
|
+
const ATTR_USER_AGENT_ORIGINAL = "user_agent.original";
|
|
13
|
+
|
|
14
|
+
export { ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_REQUEST_METHOD_ORIGINAL, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_NETWORK_PEER_ADDRESS, ATTR_NETWORK_PEER_PORT, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, ATTR_URL_PATH, ATTR_URL_QUERY, ATTR_URL_SCHEME, ATTR_USER_AGENT_ORIGINAL };
|
|
15
|
+
//# 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;;;;"}
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
import * as diagch from 'diagnostics_channel';
|
|
2
2
|
import { URL } from 'url';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { SDK_VERSION, timestampInSeconds } from '@sentry/core';
|
|
3
|
+
import { LRUMap, debug, startInactiveSpan, SPAN_KIND, SPAN_STATUS_ERROR, getClient, shouldPropagateTraceForUrl, withActiveSpan, getTraceData } from '@sentry/core';
|
|
4
|
+
import { DEBUG_BUILD } from '../../../debug-build.js';
|
|
5
|
+
import { ATTR_URL_QUERY, ATTR_URL_PATH, ATTR_URL_FULL, ATTR_HTTP_REQUEST_METHOD_ORIGINAL, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_URL_SCHEME, ATTR_HTTP_REQUEST_METHOD, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_USER_AGENT_ORIGINAL, ATTR_NETWORK_PEER_PORT, ATTR_NETWORK_PEER_ADDRESS } from './semconv.js';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
// No need to instrument files/modules
|
|
15
|
-
init() {
|
|
7
|
+
function safeExecute(fn, onError) {
|
|
8
|
+
try {
|
|
9
|
+
return fn();
|
|
10
|
+
} catch (error) {
|
|
11
|
+
onError(error);
|
|
16
12
|
return void 0;
|
|
17
13
|
}
|
|
14
|
+
}
|
|
15
|
+
class UndiciInstrumentation {
|
|
16
|
+
constructor(config = {}) {
|
|
17
|
+
// Keep ref to avoid https://github.com/nodejs/node/issues/42170 bug and for unsubscribing.
|
|
18
|
+
this._channelSubs = [];
|
|
19
|
+
this._spanFromReq = /* @__PURE__ */ new WeakMap();
|
|
20
|
+
// Caches trace-propagation decisions per URL so we don't recompute the `tracePropagationTargets` regexes per request.
|
|
21
|
+
this._propagationDecisionMap = new LRUMap(100);
|
|
22
|
+
this._config = config;
|
|
23
|
+
}
|
|
18
24
|
disable() {
|
|
19
|
-
super.disable();
|
|
20
25
|
this._channelSubs.forEach((sub) => sub.unsubscribe());
|
|
21
26
|
this._channelSubs.length = 0;
|
|
22
27
|
}
|
|
28
|
+
/** Subscribe to the undici diagnostics channels (idempotent). */
|
|
23
29
|
enable() {
|
|
24
|
-
super.enable();
|
|
25
|
-
this._channelSubs = this._channelSubs || [];
|
|
26
30
|
if (this._channelSubs.length > 0) {
|
|
27
31
|
return;
|
|
28
32
|
}
|
|
@@ -32,16 +36,6 @@ class UndiciInstrumentation extends InstrumentationBase {
|
|
|
32
36
|
this.subscribeToChannel("undici:request:trailers", this.onDone.bind(this));
|
|
33
37
|
this.subscribeToChannel("undici:request:error", this.onError.bind(this));
|
|
34
38
|
}
|
|
35
|
-
_updateMetricInstruments() {
|
|
36
|
-
this._httpClientDurationHistogram = this.meter.createHistogram(METRIC_HTTP_CLIENT_REQUEST_DURATION, {
|
|
37
|
-
description: "Measures the duration of outbound HTTP requests.",
|
|
38
|
-
unit: "s",
|
|
39
|
-
valueType: ValueType.DOUBLE,
|
|
40
|
-
advice: {
|
|
41
|
-
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]
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
39
|
subscribeToChannel(diagnosticChannel, onMessage) {
|
|
46
40
|
const [major = 0, minor = 0] = process.version.replace("v", "").split(".").map((n) => Number(n));
|
|
47
41
|
const useNewSubscribe = major > 18 || major === 18 && minor >= 19;
|
|
@@ -97,22 +91,20 @@ class UndiciInstrumentation extends InstrumentationBase {
|
|
|
97
91
|
// create the span and populate some atttributes, then link the span to the request for further
|
|
98
92
|
// span processing
|
|
99
93
|
onRequestCreated({ request }) {
|
|
100
|
-
const config = this.
|
|
94
|
+
const config = this._config;
|
|
101
95
|
const enabled = config.enabled !== false;
|
|
102
|
-
const shouldIgnoreReq =
|
|
96
|
+
const shouldIgnoreReq = safeExecute(
|
|
103
97
|
() => !enabled || request.method === "CONNECT" || config.ignoreRequestHook?.(request),
|
|
104
|
-
(e) => e &&
|
|
105
|
-
true
|
|
98
|
+
(e) => e && DEBUG_BUILD && debug.error("caught ignoreRequestHook error: ", e)
|
|
106
99
|
);
|
|
107
100
|
if (shouldIgnoreReq) {
|
|
108
101
|
return;
|
|
109
102
|
}
|
|
110
|
-
const startTime = timestampInSeconds();
|
|
111
103
|
let requestUrl;
|
|
112
104
|
try {
|
|
113
105
|
requestUrl = new URL(request.path, request.origin);
|
|
114
106
|
} catch (err) {
|
|
115
|
-
|
|
107
|
+
DEBUG_BUILD && debug.warn("could not determine url.full:", err);
|
|
116
108
|
return;
|
|
117
109
|
}
|
|
118
110
|
const urlScheme = requestUrl.protocol.replace(":", "");
|
|
@@ -138,67 +130,36 @@ class UndiciInstrumentation extends InstrumentationBase {
|
|
|
138
130
|
const userAgent = Array.isArray(userAgentValues) ? userAgentValues[userAgentValues.length - 1] : userAgentValues;
|
|
139
131
|
attributes[ATTR_USER_AGENT_ORIGINAL] = userAgent;
|
|
140
132
|
}
|
|
141
|
-
const hookAttributes =
|
|
133
|
+
const hookAttributes = safeExecute(
|
|
142
134
|
() => config.startSpanHook?.(request),
|
|
143
|
-
(e) => e &&
|
|
144
|
-
true
|
|
135
|
+
(e) => e && DEBUG_BUILD && debug.error("caught startSpanHook error: ", e)
|
|
145
136
|
);
|
|
146
137
|
if (hookAttributes) {
|
|
147
138
|
Object.entries(hookAttributes).forEach(([key, val]) => {
|
|
148
139
|
attributes[key] = val;
|
|
149
140
|
});
|
|
150
141
|
}
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
span = this.tracer.startSpan(
|
|
158
|
-
requestMethod === "_OTHER" ? "HTTP" : requestMethod,
|
|
159
|
-
{
|
|
160
|
-
kind: SpanKind.CLIENT,
|
|
161
|
-
attributes
|
|
162
|
-
},
|
|
163
|
-
activeCtx
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
safeExecuteInTheMiddle(
|
|
142
|
+
const span = startInactiveSpan({
|
|
143
|
+
name: requestMethod === "_OTHER" ? "HTTP" : requestMethod,
|
|
144
|
+
kind: SPAN_KIND.CLIENT,
|
|
145
|
+
attributes
|
|
146
|
+
});
|
|
147
|
+
safeExecute(
|
|
167
148
|
() => config.requestHook?.(span, request),
|
|
168
|
-
(e) => e &&
|
|
169
|
-
true
|
|
149
|
+
(e) => e && DEBUG_BUILD && debug.error("caught requestHook error: ", e)
|
|
170
150
|
);
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
propagation.inject(requestContext, addedHeaders);
|
|
174
|
-
const headerEntries = Object.entries(addedHeaders);
|
|
175
|
-
for (let i = 0; i < headerEntries.length; i++) {
|
|
176
|
-
const pair = headerEntries[i];
|
|
177
|
-
if (!pair) {
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
const [k, v] = pair;
|
|
181
|
-
if (typeof request.addHeader === "function") {
|
|
182
|
-
request.addHeader(k, v);
|
|
183
|
-
} else if (typeof request.headers === "string") {
|
|
184
|
-
request.headers += `${k}: ${v}\r
|
|
185
|
-
`;
|
|
186
|
-
} else if (Array.isArray(request.headers)) {
|
|
187
|
-
request.headers.push(k, v);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
this._recordFromReq.set(request, { span, attributes, startTime });
|
|
151
|
+
this.injectTracePropagationHeaders(span, request, requestUrl.toString());
|
|
152
|
+
this._spanFromReq.set(request, span);
|
|
191
153
|
}
|
|
192
154
|
// This is the 2nd message we receive for each request. It is fired when connection with
|
|
193
155
|
// the remote is established and about to send the first byte. Here we do have info about the
|
|
194
156
|
// remote address and port so we can populate some `network.*` attributes into the span
|
|
195
157
|
onRequestHeaders({ request, socket }) {
|
|
196
|
-
const
|
|
197
|
-
if (!
|
|
158
|
+
const span = this._spanFromReq.get(request);
|
|
159
|
+
if (!span) {
|
|
198
160
|
return;
|
|
199
161
|
}
|
|
200
|
-
const config = this.
|
|
201
|
-
const { span } = record;
|
|
162
|
+
const config = this._config;
|
|
202
163
|
const { remoteAddress, remotePort } = socket;
|
|
203
164
|
const spanAttributes = {
|
|
204
165
|
[ATTR_NETWORK_PEER_ADDRESS]: remoteAddress,
|
|
@@ -220,19 +181,17 @@ class UndiciInstrumentation extends InstrumentationBase {
|
|
|
220
181
|
// headers are received, body may not be accessible yet.
|
|
221
182
|
// From the response headers we can set the status and content length
|
|
222
183
|
onResponseHeaders({ request, response }) {
|
|
223
|
-
const
|
|
224
|
-
if (!
|
|
184
|
+
const span = this._spanFromReq.get(request);
|
|
185
|
+
if (!span) {
|
|
225
186
|
return;
|
|
226
187
|
}
|
|
227
|
-
const { span, attributes } = record;
|
|
228
188
|
const spanAttributes = {
|
|
229
189
|
[ATTR_HTTP_RESPONSE_STATUS_CODE]: response.statusCode
|
|
230
190
|
};
|
|
231
|
-
const config = this.
|
|
232
|
-
|
|
191
|
+
const config = this._config;
|
|
192
|
+
safeExecute(
|
|
233
193
|
() => config.responseHook?.(span, { request, response }),
|
|
234
|
-
(e) => e &&
|
|
235
|
-
true
|
|
194
|
+
(e) => e && DEBUG_BUILD && debug.error("caught responseHook error: ", e)
|
|
236
195
|
);
|
|
237
196
|
if (config.headersToSpanAttributes?.responseHeaders) {
|
|
238
197
|
const headersToAttribs = /* @__PURE__ */ new Set();
|
|
@@ -256,21 +215,18 @@ class UndiciInstrumentation extends InstrumentationBase {
|
|
|
256
215
|
}
|
|
257
216
|
}
|
|
258
217
|
span.setAttributes(spanAttributes);
|
|
259
|
-
|
|
260
|
-
code:
|
|
261
|
-
}
|
|
262
|
-
record.attributes = Object.assign(attributes, spanAttributes);
|
|
218
|
+
if (response.statusCode >= 400) {
|
|
219
|
+
span.setStatus({ code: SPAN_STATUS_ERROR });
|
|
220
|
+
}
|
|
263
221
|
}
|
|
264
222
|
// This is the last event we receive if the request went without any errors
|
|
265
223
|
onDone({ request }) {
|
|
266
|
-
const
|
|
267
|
-
if (!
|
|
224
|
+
const span = this._spanFromReq.get(request);
|
|
225
|
+
if (!span) {
|
|
268
226
|
return;
|
|
269
227
|
}
|
|
270
|
-
const { span, attributes, startTime } = record;
|
|
271
228
|
span.end();
|
|
272
|
-
this.
|
|
273
|
-
this.recordRequestDuration(attributes, startTime);
|
|
229
|
+
this._spanFromReq.delete(request);
|
|
274
230
|
}
|
|
275
231
|
// This is the event we get when something is wrong in the request like
|
|
276
232
|
// - invalid options when calling `fetch` global API or any undici method for request
|
|
@@ -279,38 +235,45 @@ class UndiciInstrumentation extends InstrumentationBase {
|
|
|
279
235
|
// NOTE: server errors are considered valid responses and it's the lib consumer
|
|
280
236
|
// who should deal with that.
|
|
281
237
|
onError({ request, error }) {
|
|
282
|
-
const
|
|
283
|
-
if (!
|
|
238
|
+
const span = this._spanFromReq.get(request);
|
|
239
|
+
if (!span) {
|
|
284
240
|
return;
|
|
285
241
|
}
|
|
286
|
-
const { span, attributes, startTime } = record;
|
|
287
|
-
span.recordException(error);
|
|
288
242
|
span.setStatus({
|
|
289
|
-
code:
|
|
243
|
+
code: SPAN_STATUS_ERROR,
|
|
290
244
|
message: error.message
|
|
291
245
|
});
|
|
292
246
|
span.end();
|
|
293
|
-
this.
|
|
294
|
-
attributes[ATTR_ERROR_TYPE] = error.message;
|
|
295
|
-
this.recordRequestDuration(attributes, startTime);
|
|
247
|
+
this._spanFromReq.delete(request);
|
|
296
248
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
249
|
+
// Propagate the trace data of the given (client) span into the outgoing request headers, gated by
|
|
250
|
+
// `tracePropagationTargets`. Mirrors what `propagation.inject()` did with the SentryPropagator, but
|
|
251
|
+
// via Sentry's `getTraceData()` so we stay off OpenTelemetry's propagation API.
|
|
252
|
+
injectTracePropagationHeaders(span, request, url) {
|
|
253
|
+
const { tracePropagationTargets, propagateTraceparent } = getClient()?.getOptions() ?? {};
|
|
254
|
+
if (!shouldPropagateTraceForUrl(url, tracePropagationTargets, this._propagationDecisionMap)) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const addedHeaders = withActiveSpan(span, () => getTraceData({ propagateTraceparent }));
|
|
258
|
+
const headerEntries = Object.entries(addedHeaders);
|
|
259
|
+
for (let i = 0; i < headerEntries.length; i++) {
|
|
260
|
+
const pair = headerEntries[i];
|
|
261
|
+
if (!pair) {
|
|
262
|
+
continue;
|
|
310
263
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
264
|
+
const [k, v] = pair;
|
|
265
|
+
if (!v) {
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (typeof request.addHeader === "function") {
|
|
269
|
+
request.addHeader(k, v);
|
|
270
|
+
} else if (typeof request.headers === "string") {
|
|
271
|
+
request.headers += `${k}: ${v}\r
|
|
272
|
+
`;
|
|
273
|
+
} else if (Array.isArray(request.headers)) {
|
|
274
|
+
request.headers.push(k, v);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
314
277
|
}
|
|
315
278
|
getRequestMethod(original) {
|
|
316
279
|
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":[],"mappings":";;;;;;;AA4DA,MAAM,YAAA,GAAe,gCAAA;AAId,MAAM,8BAA8B,mBAAA,CAAiD;AAAA,EAQ1F,WAAA,CAAY,MAAA,GAAsC,EAAC,EAAG;AACpD,IAAA,KAAA,CAAM,YAAA,EAAc,aAAa,MAAM,CAAA;AALzC,IAAA,IAAA,CAAQ,cAAA,uBAAqB,OAAA,EAA8C;AAAA,EAM3E;AAAA;AAAA,EAGmB,IAAA,GAAO;AACxB,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAES,OAAA,GAAgB;AACvB,IAAA,KAAA,CAAM,OAAA,EAAQ;AACd,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,EAES,MAAA,GAAe;AAUtB,IAAA,KAAA,CAAM,MAAA,EAAO;AAIb,IAAA,IAAA,CAAK,YAAA,GAAe,IAAA,CAAK,YAAA,IAAgB,EAAC;AAG1C,IAAA,IAAI,IAAA,CAAK,YAAA,CAAa,MAAA,GAAS,CAAA,EAAG;AAChC,MAAA;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,mBAAmB,uBA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xB,MAAA,IAAI,OAAO,UAAA,EAAY;AACrB,QAAA,iBAAA,CAAkB,GAAG,CAAA,GAAI,UAAA,CAAW,GAAG,CAAA;AAAA,MACzC;AAAA,IACF,CAAC,CAAA;AAGD,IAAA,MAAM,eAAA,GAAkB,oBAAmB,GAAI,SAAA;AAC/C,IAAA,IAAA,CAAK,4BAAA,CAA6B,MAAA,CAAO,eAAA,EAAiB,iBAAiB,CAAA;AAAA,EAC7E;AAAA,EAEQ,iBAAiB,QAAA,EAA0B;AACjD,IAAA,MAAM,YAAA,GAAe;AAAA,MACnB,OAAA,EAAS,IAAA;AAAA,MACT,OAAA,EAAS,IAAA;AAAA,MACT,IAAA,EAAM,IAAA;AAAA,MACN,GAAA,EAAK,IAAA;AAAA,MACL,IAAA,EAAM,IAAA;AAAA,MACN,GAAA,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;;;;"}
|
|
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_KIND,\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/** 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":[],"mappings":";;;;;;AAyDA,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,IAAI,MAAA,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,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MACT,IAAA,EAAM,IAAA;AAAA,MACN,GAAA,EAAK,IAAA;AAAA,MACL,IAAA,EAAM,IAAA;AAAA,MACN,GAAA,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;;;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped } from '@opentelemetry/instrumentation';
|
|
2
|
-
import {
|
|
3
|
-
import { SDK_VERSION, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
2
|
+
import { SDK_VERSION, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_KIND } from '@sentry/core';
|
|
4
3
|
|
|
5
4
|
const MODULE_NAME = "dataloader";
|
|
6
5
|
const PACKAGE_NAME = "@sentry/instrumentation-dataloader";
|
|
@@ -102,7 +101,7 @@ class DataloaderInstrumentation extends InstrumentationBase {
|
|
|
102
101
|
return startSpan(
|
|
103
102
|
{
|
|
104
103
|
name: getSpanName(this, "load"),
|
|
105
|
-
kind:
|
|
104
|
+
kind: SPAN_KIND.CLIENT,
|
|
106
105
|
attributes: {
|
|
107
106
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
108
107
|
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("load")
|
|
@@ -133,7 +132,7 @@ class DataloaderInstrumentation extends InstrumentationBase {
|
|
|
133
132
|
return startSpan(
|
|
134
133
|
{
|
|
135
134
|
name: getSpanName(this, "loadMany"),
|
|
136
|
-
kind:
|
|
135
|
+
kind: SPAN_KIND.CLIENT,
|
|
137
136
|
attributes: {
|
|
138
137
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
139
138
|
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("loadMany")
|
|
@@ -155,7 +154,7 @@ class DataloaderInstrumentation extends InstrumentationBase {
|
|
|
155
154
|
return startSpan(
|
|
156
155
|
{
|
|
157
156
|
name: getSpanName(this, "prime"),
|
|
158
|
-
kind:
|
|
157
|
+
kind: SPAN_KIND.CLIENT,
|
|
159
158
|
attributes: {
|
|
160
159
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
161
160
|
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("prime")
|
|
@@ -177,7 +176,7 @@ class DataloaderInstrumentation extends InstrumentationBase {
|
|
|
177
176
|
return startSpan(
|
|
178
177
|
{
|
|
179
178
|
name: getSpanName(this, "clear"),
|
|
180
|
-
kind:
|
|
179
|
+
kind: SPAN_KIND.CLIENT,
|
|
181
180
|
attributes: {
|
|
182
181
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
183
182
|
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("clear")
|
|
@@ -199,7 +198,7 @@ class DataloaderInstrumentation extends InstrumentationBase {
|
|
|
199
198
|
return startSpan(
|
|
200
199
|
{
|
|
201
200
|
name: getSpanName(this, "clearAll"),
|
|
202
|
-
kind:
|
|
201
|
+
kind: SPAN_KIND.CLIENT,
|
|
203
202
|
attributes: {
|
|
204
203
|
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: ORIGIN,
|
|
205
204
|
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: getSpanOp("clearAll")
|