@reqray/instrumentation-undici 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ruslan Kryklyvyi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,54 @@
1
- # Temporary Holding Version
1
+ # @reqray/instrumentation-undici
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Records outgoing HTTP calls — undici and the built-in `fetch` — into the request that made them, through Node's own `diagnostics_channel`. Nothing is patched.
4
+
5
+ Part of [Reqray](https://github.com/reqray/reqray) — a dev panel and request inspector for Node.js. It
6
+ instruments HTTP, SQL, outgoing calls and cache on its own, shows every
7
+ request as a waterfall, and finds N+1 down to the file and the line.
8
+
9
+ ## You probably do not need to install this
10
+
11
+ [`@reqray/register`](https://www.npmjs.com/package/@reqray/register) depends on
12
+ it and applies it automatically:
13
+
14
+ ```bash
15
+ node --import @reqray/register app.js
16
+ ```
17
+
18
+ ```
19
+ reqray instrumentation active
20
+ ✔ undici (built-in) outgoing HTTP
21
+ ```
22
+
23
+ ## What is recorded
24
+
25
+ For each call: method, URL, status and duration. That is what lets Reqray flag calls made one after another that could have run in parallel, and the same URL fetched twice.
26
+
27
+ **Secrets in the URL are masked** before anything is stored: `?token=abc` becomes `?token=[redacted]`. Request and response bodies of outgoing calls are not recorded.
28
+
29
+ Supported: any undici, and the `fetch` built into Node 20 or newer. Outside that range nothing is patched, and the startup
30
+ report says so.
31
+
32
+ ## Applying it by hand
33
+
34
+ In a bundled application (esbuild, webpack, tsup) imports are resolved at build
35
+ time and loader hooks never fire. Apply the instrumentation yourself, before
36
+ the first call:
37
+
38
+ ```js
39
+ import { instrumentUndici } from '@reqray/instrumentation-undici';
40
+
41
+ instrumentUndici().apply();
42
+ ```
43
+
44
+ No version range is checked on this path — the choice was yours.
45
+
46
+ ## More
47
+
48
+ Everything else — the detectors, security defaults, measured overhead and a
49
+ demo that runs with one command — is in the
50
+ [main README](https://github.com/reqray/reqray#readme).
51
+
52
+ ## License
53
+
54
+ [MIT](https://github.com/reqray/reqray/blob/main/LICENSE)
package/dist/index.cjs ADDED
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ instrumentUndici: () => instrumentUndici
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+ var import_node_diagnostics_channel = __toESM(require("diagnostics_channel"), 1);
37
+ var import_core = require("@reqray/core");
38
+ var inFlight = /* @__PURE__ */ new WeakMap();
39
+ function urlOf(request) {
40
+ const origin = typeof request.origin === "string" ? request.origin : String(request.origin ?? "");
41
+ return `${origin}${request.path ?? ""}`;
42
+ }
43
+ function write(state, error) {
44
+ state.recorded = true;
45
+ state.span = (0, import_core.record)(state.scope, {
46
+ kind: "http",
47
+ method: state.method,
48
+ url: state.url,
49
+ duration: performance.now() - state.startTime,
50
+ startTime: state.startTime,
51
+ statusCode: state.statusCode,
52
+ callsite: state.callsite,
53
+ error: (0, import_core.toSpanError)(error)
54
+ });
55
+ }
56
+ function finish(request, error) {
57
+ const state = inFlight.get(request);
58
+ if (!state) return;
59
+ inFlight.delete(request);
60
+ try {
61
+ if (!state.recorded) {
62
+ write(state, error);
63
+ return;
64
+ }
65
+ if (state.span) {
66
+ Object.assign(state.span, {
67
+ duration: performance.now() - state.startTime,
68
+ error: (0, import_core.toSpanError)(error)
69
+ });
70
+ }
71
+ } catch {
72
+ }
73
+ }
74
+ function onCreate(message) {
75
+ try {
76
+ const request = message?.request;
77
+ if (!request) return;
78
+ const scope = (0, import_core.current)();
79
+ if (!scope) return;
80
+ const details = request;
81
+ const method = details.method ?? "GET";
82
+ const url = (0, import_core.redactQuery)(urlOf(details), scope.options.redact);
83
+ inFlight.set(request, {
84
+ scope,
85
+ startTime: performance.now(),
86
+ method,
87
+ url,
88
+ callsite: (0, import_core.handedCallsite)()?.callsite ?? null,
89
+ statusCode: null,
90
+ recorded: false,
91
+ span: null
92
+ });
93
+ } catch {
94
+ }
95
+ }
96
+ function onHeaders(message) {
97
+ try {
98
+ const payload = message;
99
+ if (!payload?.request) return;
100
+ const state = inFlight.get(payload.request);
101
+ if (!state) return;
102
+ const status = payload.response?.statusCode;
103
+ if (typeof status === "number") state.statusCode = status;
104
+ if (!state.recorded) write(state, void 0);
105
+ } catch {
106
+ }
107
+ }
108
+ function onTrailers(message) {
109
+ const request = message?.request;
110
+ if (request) finish(request, void 0);
111
+ }
112
+ function onError(message) {
113
+ const payload = message;
114
+ if (payload?.request) finish(payload.request, payload.error);
115
+ }
116
+ var subscriptions = [
117
+ ["undici:request:create", onCreate],
118
+ ["undici:request:headers", onHeaders],
119
+ ["undici:request:trailers", onTrailers],
120
+ ["undici:request:error", onError]
121
+ ];
122
+ var subscribed = false;
123
+ function targetOf(input, init) {
124
+ const options = init;
125
+ if (input && typeof input === "object" && "url" in input && "method" in input) {
126
+ const request = input;
127
+ const method = typeof options?.method === "string" ? options.method : typeof request.method === "string" ? request.method : "GET";
128
+ return [method, typeof request.url === "string" ? request.url : String(input)];
129
+ }
130
+ return [typeof options?.method === "string" ? options.method : "GET", String(input)];
131
+ }
132
+ function patchFetch() {
133
+ (0, import_core.patchMethod)(
134
+ globalThis,
135
+ "fetch",
136
+ (original) => function reqrayFetch(input, init) {
137
+ let handed = null;
138
+ try {
139
+ const scope = (0, import_core.current)();
140
+ if (scope) {
141
+ const [method, url] = targetOf(input, init);
142
+ handed = {
143
+ callsite: (0, import_core.resolveCallsite)(scope, (0, import_core.fingerprintHttp)(method, url), reqrayFetch)
144
+ };
145
+ }
146
+ } catch {
147
+ }
148
+ if (!handed) return original.call(this, input, init);
149
+ return (0, import_core.withHandedCallsite)(handed, () => original.call(this, input, init));
150
+ }
151
+ );
152
+ }
153
+ function instrumentUndici() {
154
+ return {
155
+ name: "undici",
156
+ // The channels have been stable since undici 5; there is no range to check,
157
+ // the subscription does not depend on the installed package version.
158
+ supportedVersions: "*",
159
+ captures: "outgoing HTTP",
160
+ apply() {
161
+ if (subscribed) return;
162
+ (0, import_core.guarded)("undici", () => {
163
+ for (const [channel, handler] of subscriptions) {
164
+ import_node_diagnostics_channel.default.subscribe(channel, handler);
165
+ }
166
+ patchFetch();
167
+ subscribed = true;
168
+ });
169
+ },
170
+ unapply() {
171
+ if (!subscribed) return;
172
+ (0, import_core.guarded)("undici", () => {
173
+ for (const [channel, handler] of subscriptions) {
174
+ import_node_diagnostics_channel.default.unsubscribe(channel, handler);
175
+ }
176
+ (0, import_core.unpatchMethod)(globalThis, "fetch");
177
+ });
178
+ subscribed = false;
179
+ }
180
+ };
181
+ }
182
+ // Annotate the CommonJS export names for ESM import in node:
183
+ 0 && (module.exports = {
184
+ instrumentUndici
185
+ });
186
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@reqray/instrumentation-undici` — interception of outgoing HTTP.\n *\n * **Interception method: `diagnostics_channel`.** This is the most preferred\n * option available: undici publishes the channels natively, so nothing is\n * patched and nothing breaks when it is upgraded. Built-in `fetch` is covered\n * along the way — it is undici.\n *\n * Loader hooks are not needed here at all: the subscription works regardless of\n * when and how the application imported undici.\n */\n\nimport diagnosticsChannel from 'node:diagnostics_channel';\nimport {\n type Callsite,\n current,\n fingerprintHttp,\n guarded,\n handedCallsite,\n type Instrumentation,\n patchMethod,\n type RequestScope,\n record,\n redactQuery,\n resolveCallsite,\n type Span,\n toSpanError,\n unpatchMethod,\n withHandedCallsite,\n} from '@reqray/core';\n\n/** What undici puts into the `undici:request:create` channel. */\ninterface UndiciRequest {\n readonly origin?: unknown;\n readonly path?: string;\n readonly method?: string;\n}\n\n/** Call state from start to completion. */\ninterface CallState {\n readonly scope: RequestScope;\n readonly startTime: number;\n readonly method: string;\n readonly url: string;\n readonly callsite: Callsite | null;\n statusCode: number | null;\n /** Whether the span was written when the headers arrived. */\n recorded: boolean;\n /** That span, unless the scope was already full. */\n span: Span | null;\n}\n\n// Keyed by the undici request object itself: nothing is left behind once it is\n// garbage collected.\nconst inFlight = new WeakMap<object, CallState>();\n\nfunction urlOf(request: UndiciRequest): string {\n const origin = typeof request.origin === 'string' ? request.origin : String(request.origin ?? '');\n return `${origin}${request.path ?? ''}`;\n}\n\n/** Writes the call's span as things stand: the time so far, the status known. */\nfunction write(state: CallState, error: unknown): void {\n state.recorded = true;\n state.span = record(state.scope, {\n kind: 'http',\n method: state.method,\n url: state.url,\n duration: performance.now() - state.startTime,\n startTime: state.startTime,\n statusCode: state.statusCode,\n callsite: state.callsite,\n error: toSpanError(error),\n });\n}\n\nfunction finish(request: object, error: unknown): void {\n const state = inFlight.get(request);\n if (!state) return;\n inFlight.delete(request);\n\n try {\n if (!state.recorded) {\n write(state, error);\n return;\n }\n // Written at the headers; the body has now been read to its end, or\n // failed on the way. The record copies spans when the request is\n // finalized, so correcting this one in place is all it takes — and after\n // that point the correction lands on an object nobody reads.\n if (state.span) {\n Object.assign(state.span, {\n duration: performance.now() - state.startTime,\n error: toSpanError(error),\n });\n }\n } catch {\n // Instrumentation must never break the host request.\n }\n}\n\nfunction onCreate(message: unknown): void {\n try {\n const request = (message as { request?: object })?.request;\n if (!request) return;\n\n // Channel handlers run synchronously in the caller's context, so the scope is\n // still visible here. By the time the request completes the context is a\n // different one — hence the WeakMap.\n const scope = current();\n if (!scope) return;\n\n const details = request as UndiciRequest;\n const method = details.method ?? 'GET';\n // `?api_key=…` and presigned URLs are secrets in a place masking by\n // header and body field never looked.\n const url = redactQuery(urlOf(details), scope.options.redact);\n\n // No stack is captured here: the channel is published from the dispatcher,\n // so the user's frame is already off the synchronous stack. The `fetch`\n // wrapper below captures the callsite while the frame is still there and\n // hands it down through the same context the pg pool wrapper uses.\n inFlight.set(request, {\n scope,\n startTime: performance.now(),\n method,\n url,\n callsite: handedCallsite()?.callsite ?? null,\n statusCode: null,\n recorded: false,\n span: null,\n });\n } catch {\n // Instrumentation must never break the host request.\n }\n}\n\nfunction onHeaders(message: unknown): void {\n try {\n const payload = message as { request?: object; response?: { statusCode?: unknown } };\n if (!payload?.request) return;\n const state = inFlight.get(payload.request);\n if (!state) return;\n const status = payload.response?.statusCode;\n if (typeof status === 'number') state.statusCode = status;\n // Recorded now rather than at the trailers: those only come once the\n // body has been read to its end, and `if (!res.ok) throw` never reads it.\n // Such a call used to leave no span at all, and its time showed up as a\n // stretch of the application's own code.\n if (!state.recorded) write(state, undefined);\n } catch {\n // Instrumentation must never break the host request.\n }\n}\n\nfunction onTrailers(message: unknown): void {\n const request = (message as { request?: object })?.request;\n if (request) finish(request, undefined);\n}\n\nfunction onError(message: unknown): void {\n const payload = message as { request?: object; error?: unknown };\n if (payload?.request) finish(payload.request, payload.error);\n}\n\nconst subscriptions: ReadonlyArray<readonly [string, (message: unknown) => void]> = [\n ['undici:request:create', onCreate],\n ['undici:request:headers', onHeaders],\n ['undici:request:trailers', onTrailers],\n ['undici:request:error', onError],\n];\n\nlet subscribed = false;\n\n/** Method and URL of a `fetch` call, best effort for every call shape. */\nfunction targetOf(input: unknown, init: unknown): [method: string, url: string] {\n const options = init as { method?: unknown } | undefined;\n if (input && typeof input === 'object' && 'url' in input && 'method' in input) {\n const request = input as { url: unknown; method: unknown };\n const method =\n typeof options?.method === 'string'\n ? options.method\n : typeof request.method === 'string'\n ? request.method\n : 'GET';\n return [method, typeof request.url === 'string' ? request.url : String(input)];\n }\n return [typeof options?.method === 'string' ? options.method : 'GET', String(input)];\n}\n\n/**\n * Wraps `globalThis.fetch` to capture the caller's line of code.\n *\n * The channels record the span, but they fire from the dispatcher where the\n * user's frame is gone. This wrapper is the only place the frame still exists;\n * the callsite is handed down the same way the pg pool wrapper does it. The\n * wrapper changes nothing else — arguments, return value and errors pass\n * through untouched.\n */\nfunction patchFetch(): void {\n patchMethod(\n globalThis,\n 'fetch',\n (original: any) =>\n function reqrayFetch(\n this: unknown,\n input: Parameters<typeof globalThis.fetch>[0],\n init?: Parameters<typeof globalThis.fetch>[1],\n ) {\n let handed: { callsite: Callsite | null } | null = null;\n try {\n const scope = current();\n if (scope) {\n const [method, url] = targetOf(input, init);\n handed = {\n callsite: resolveCallsite(scope, fingerprintHttp(method, url), reqrayFetch),\n };\n }\n } catch {\n // Instrumentation must never break the host call.\n }\n if (!handed) return original.call(this, input, init);\n return withHandedCallsite(handed, () => original.call(this, input, init));\n },\n );\n}\n\n/** Instrumentation for outgoing HTTP: undici and built-in `fetch`. */\nexport function instrumentUndici(): Instrumentation {\n return {\n name: 'undici',\n // The channels have been stable since undici 5; there is no range to check,\n // the subscription does not depend on the installed package version.\n supportedVersions: '*',\n captures: 'outgoing HTTP',\n\n apply() {\n if (subscribed) return;\n guarded('undici', () => {\n for (const [channel, handler] of subscriptions) {\n diagnosticsChannel.subscribe(channel, handler);\n }\n patchFetch();\n subscribed = true;\n });\n },\n\n unapply() {\n if (!subscribed) return;\n guarded('undici', () => {\n for (const [channel, handler] of subscriptions) {\n diagnosticsChannel.unsubscribe(channel, handler);\n }\n unpatchMethod(globalThis, 'fetch');\n });\n subscribed = false;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sCAA+B;AAC/B,kBAgBO;AAyBP,IAAM,WAAW,oBAAI,QAA2B;AAEhD,SAAS,MAAM,SAAgC;AAC7C,QAAM,SAAS,OAAO,QAAQ,WAAW,WAAW,QAAQ,SAAS,OAAO,QAAQ,U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;AACnD,UAAI;AACF,cAAM,YAAQ,qBAAQ;AACtB,YAAI,OAAO;AACT,gBAAM,CAAC,QAAQ,GAAG,IAAI,SAAS,OAAO,IAAI;AAC1C,mBAAS;AAAA,YACP,cAAU,6BAAgB,WAAO,6BAAgB,QAAQ,GAAG,GAAG,WAAW;AAAA,UAC5E;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AACA,UAAI,CAAC,OAAQ,QAAO,SAAS,KAAK,MAAM,OAAO,IAAI;AACnD,iBAAO,gCAAmB,QAAQ,MAAM,SAAS,KAAK,MAAM,OAAO,IAAI,CAAC;AAAA,IAC1E;AAAA,EACJ;AACF;AAGO,SAAS,mBAAoC;AAClD,SAAO;AAAA,IACL,MAAM;AAAA;AAAA;AAAA,IAGN,mBAAmB;AAAA,IACnB,UAAU;AAAA,IAEV,QAAQ;AACN,UAAI,WAAY;AAChB,+BAAQ,UAAU,MAAM;AACtB,mBAAW,CAAC,SAAS,OAAO,KAAK,eAAe;AAC9C,0CAAAA,QAAmB,UAAU,SAAS,OAAO;AAAA,QAC/C;AACA,mBAAW;AACX,qBAAa;AAAA,MACf,CAAC;AAAA,IACH;AAAA,IAEA,UAAU;AACR,UAAI,CAAC,WAAY;AACjB,+BAAQ,UAAU,MAAM;AACtB,mBAAW,CAAC,SAAS,OAAO,KAAK,eAAe;AAC9C,0CAAAA,QAAmB,YAAY,SAAS,OAAO;AAAA,QACjD;AACA,uCAAc,YAAY,OAAO;AAAA,MACnC,CAAC;AACD,mBAAa;AAAA,IACf;AAAA,EACF;AACF;","names":["diagnosticsChannel"]}
@@ -0,0 +1,18 @@
1
+ import { Instrumentation } from '@reqray/core';
2
+
3
+ /**
4
+ * `@reqray/instrumentation-undici` — interception of outgoing HTTP.
5
+ *
6
+ * **Interception method: `diagnostics_channel`.** This is the most preferred
7
+ * option available: undici publishes the channels natively, so nothing is
8
+ * patched and nothing breaks when it is upgraded. Built-in `fetch` is covered
9
+ * along the way — it is undici.
10
+ *
11
+ * Loader hooks are not needed here at all: the subscription works regardless of
12
+ * when and how the application imported undici.
13
+ */
14
+
15
+ /** Instrumentation for outgoing HTTP: undici and built-in `fetch`. */
16
+ declare function instrumentUndici(): Instrumentation;
17
+
18
+ export { instrumentUndici };
@@ -0,0 +1,18 @@
1
+ import { Instrumentation } from '@reqray/core';
2
+
3
+ /**
4
+ * `@reqray/instrumentation-undici` — interception of outgoing HTTP.
5
+ *
6
+ * **Interception method: `diagnostics_channel`.** This is the most preferred
7
+ * option available: undici publishes the channels natively, so nothing is
8
+ * patched and nothing breaks when it is upgraded. Built-in `fetch` is covered
9
+ * along the way — it is undici.
10
+ *
11
+ * Loader hooks are not needed here at all: the subscription works regardless of
12
+ * when and how the application imported undici.
13
+ */
14
+
15
+ /** Instrumentation for outgoing HTTP: undici and built-in `fetch`. */
16
+ declare function instrumentUndici(): Instrumentation;
17
+
18
+ export { instrumentUndici };
package/dist/index.js ADDED
@@ -0,0 +1,163 @@
1
+ // src/index.ts
2
+ import diagnosticsChannel from "diagnostics_channel";
3
+ import {
4
+ current,
5
+ fingerprintHttp,
6
+ guarded,
7
+ handedCallsite,
8
+ patchMethod,
9
+ record,
10
+ redactQuery,
11
+ resolveCallsite,
12
+ toSpanError,
13
+ unpatchMethod,
14
+ withHandedCallsite
15
+ } from "@reqray/core";
16
+ var inFlight = /* @__PURE__ */ new WeakMap();
17
+ function urlOf(request) {
18
+ const origin = typeof request.origin === "string" ? request.origin : String(request.origin ?? "");
19
+ return `${origin}${request.path ?? ""}`;
20
+ }
21
+ function write(state, error) {
22
+ state.recorded = true;
23
+ state.span = record(state.scope, {
24
+ kind: "http",
25
+ method: state.method,
26
+ url: state.url,
27
+ duration: performance.now() - state.startTime,
28
+ startTime: state.startTime,
29
+ statusCode: state.statusCode,
30
+ callsite: state.callsite,
31
+ error: toSpanError(error)
32
+ });
33
+ }
34
+ function finish(request, error) {
35
+ const state = inFlight.get(request);
36
+ if (!state) return;
37
+ inFlight.delete(request);
38
+ try {
39
+ if (!state.recorded) {
40
+ write(state, error);
41
+ return;
42
+ }
43
+ if (state.span) {
44
+ Object.assign(state.span, {
45
+ duration: performance.now() - state.startTime,
46
+ error: toSpanError(error)
47
+ });
48
+ }
49
+ } catch {
50
+ }
51
+ }
52
+ function onCreate(message) {
53
+ try {
54
+ const request = message?.request;
55
+ if (!request) return;
56
+ const scope = current();
57
+ if (!scope) return;
58
+ const details = request;
59
+ const method = details.method ?? "GET";
60
+ const url = redactQuery(urlOf(details), scope.options.redact);
61
+ inFlight.set(request, {
62
+ scope,
63
+ startTime: performance.now(),
64
+ method,
65
+ url,
66
+ callsite: handedCallsite()?.callsite ?? null,
67
+ statusCode: null,
68
+ recorded: false,
69
+ span: null
70
+ });
71
+ } catch {
72
+ }
73
+ }
74
+ function onHeaders(message) {
75
+ try {
76
+ const payload = message;
77
+ if (!payload?.request) return;
78
+ const state = inFlight.get(payload.request);
79
+ if (!state) return;
80
+ const status = payload.response?.statusCode;
81
+ if (typeof status === "number") state.statusCode = status;
82
+ if (!state.recorded) write(state, void 0);
83
+ } catch {
84
+ }
85
+ }
86
+ function onTrailers(message) {
87
+ const request = message?.request;
88
+ if (request) finish(request, void 0);
89
+ }
90
+ function onError(message) {
91
+ const payload = message;
92
+ if (payload?.request) finish(payload.request, payload.error);
93
+ }
94
+ var subscriptions = [
95
+ ["undici:request:create", onCreate],
96
+ ["undici:request:headers", onHeaders],
97
+ ["undici:request:trailers", onTrailers],
98
+ ["undici:request:error", onError]
99
+ ];
100
+ var subscribed = false;
101
+ function targetOf(input, init) {
102
+ const options = init;
103
+ if (input && typeof input === "object" && "url" in input && "method" in input) {
104
+ const request = input;
105
+ const method = typeof options?.method === "string" ? options.method : typeof request.method === "string" ? request.method : "GET";
106
+ return [method, typeof request.url === "string" ? request.url : String(input)];
107
+ }
108
+ return [typeof options?.method === "string" ? options.method : "GET", String(input)];
109
+ }
110
+ function patchFetch() {
111
+ patchMethod(
112
+ globalThis,
113
+ "fetch",
114
+ (original) => function reqrayFetch(input, init) {
115
+ let handed = null;
116
+ try {
117
+ const scope = current();
118
+ if (scope) {
119
+ const [method, url] = targetOf(input, init);
120
+ handed = {
121
+ callsite: resolveCallsite(scope, fingerprintHttp(method, url), reqrayFetch)
122
+ };
123
+ }
124
+ } catch {
125
+ }
126
+ if (!handed) return original.call(this, input, init);
127
+ return withHandedCallsite(handed, () => original.call(this, input, init));
128
+ }
129
+ );
130
+ }
131
+ function instrumentUndici() {
132
+ return {
133
+ name: "undici",
134
+ // The channels have been stable since undici 5; there is no range to check,
135
+ // the subscription does not depend on the installed package version.
136
+ supportedVersions: "*",
137
+ captures: "outgoing HTTP",
138
+ apply() {
139
+ if (subscribed) return;
140
+ guarded("undici", () => {
141
+ for (const [channel, handler] of subscriptions) {
142
+ diagnosticsChannel.subscribe(channel, handler);
143
+ }
144
+ patchFetch();
145
+ subscribed = true;
146
+ });
147
+ },
148
+ unapply() {
149
+ if (!subscribed) return;
150
+ guarded("undici", () => {
151
+ for (const [channel, handler] of subscriptions) {
152
+ diagnosticsChannel.unsubscribe(channel, handler);
153
+ }
154
+ unpatchMethod(globalThis, "fetch");
155
+ });
156
+ subscribed = false;
157
+ }
158
+ };
159
+ }
160
+ export {
161
+ instrumentUndici
162
+ };
163
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@reqray/instrumentation-undici` — interception of outgoing HTTP.\n *\n * **Interception method: `diagnostics_channel`.** This is the most preferred\n * option available: undici publishes the channels natively, so nothing is\n * patched and nothing breaks when it is upgraded. Built-in `fetch` is covered\n * along the way — it is undici.\n *\n * Loader hooks are not needed here at all: the subscription works regardless of\n * when and how the application imported undici.\n */\n\nimport diagnosticsChannel from 'node:diagnostics_channel';\nimport {\n type Callsite,\n current,\n fingerprintHttp,\n guarded,\n handedCallsite,\n type Instrumentation,\n patchMethod,\n type RequestScope,\n record,\n redactQuery,\n resolveCallsite,\n type Span,\n toSpanError,\n unpatchMethod,\n withHandedCallsite,\n} from '@reqray/core';\n\n/** What undici puts into the `undici:request:create` channel. */\ninterface UndiciRequest {\n readonly origin?: unknown;\n readonly path?: string;\n readonly method?: string;\n}\n\n/** Call state from start to completion. */\ninterface CallState {\n readonly scope: RequestScope;\n readonly startTime: number;\n readonly method: string;\n readonly url: string;\n readonly callsite: Callsite | null;\n statusCode: number | null;\n /** Whether the span was written when the headers arrived. */\n recorded: boolean;\n /** That span, unless the scope was already full. */\n span: Span | null;\n}\n\n// Keyed by the undici request object itself: nothing is left behind once it is\n// garbage collected.\nconst inFlight = new WeakMap<object, CallState>();\n\nfunction urlOf(request: UndiciRequest): string {\n const origin = typeof request.origin === 'string' ? request.origin : String(request.origin ?? '');\n return `${origin}${request.path ?? ''}`;\n}\n\n/** Writes the call's span as things stand: the time so far, the status known. */\nfunction write(state: CallState, error: unknown): void {\n state.recorded = true;\n state.span = record(state.scope, {\n kind: 'http',\n method: state.method,\n url: state.url,\n duration: performance.now() - state.startTime,\n startTime: state.startTime,\n statusCode: state.statusCode,\n callsite: state.callsite,\n error: toSpanError(error),\n });\n}\n\nfunction finish(request: object, error: unknown): void {\n const state = inFlight.get(request);\n if (!state) return;\n inFlight.delete(request);\n\n try {\n if (!state.recorded) {\n write(state, error);\n return;\n }\n // Written at the headers; the body has now been read to its end, or\n // failed on the way. The record copies spans when the request is\n // finalized, so correcting this one in place is all it takes — and after\n // that point the correction lands on an object nobody reads.\n if (state.span) {\n Object.assign(state.span, {\n duration: performance.now() - state.startTime,\n error: toSpanError(error),\n });\n }\n } catch {\n // Instrumentation must never break the host request.\n }\n}\n\nfunction onCreate(message: unknown): void {\n try {\n const request = (message as { request?: object })?.request;\n if (!request) return;\n\n // Channel handlers run synchronously in the caller's context, so the scope is\n // still visible here. By the time the request completes the context is a\n // different one — hence the WeakMap.\n const scope = current();\n if (!scope) return;\n\n const details = request as UndiciRequest;\n const method = details.method ?? 'GET';\n // `?api_key=…` and presigned URLs are secrets in a place masking by\n // header and body field never looked.\n const url = redactQuery(urlOf(details), scope.options.redact);\n\n // No stack is captured here: the channel is published from the dispatcher,\n // so the user's frame is already off the synchronous stack. The `fetch`\n // wrapper below captures the callsite while the frame is still there and\n // hands it down through the same context the pg pool wrapper uses.\n inFlight.set(request, {\n scope,\n startTime: performance.now(),\n method,\n url,\n callsite: handedCallsite()?.callsite ?? null,\n statusCode: null,\n recorded: false,\n span: null,\n });\n } catch {\n // Instrumentation must never break the host request.\n }\n}\n\nfunction onHeaders(message: unknown): void {\n try {\n const payload = message as { request?: object; response?: { statusCode?: unknown } };\n if (!payload?.request) return;\n const state = inFlight.get(payload.request);\n if (!state) return;\n const status = payload.response?.statusCode;\n if (typeof status === 'number') state.statusCode = status;\n // Recorded now rather than at the trailers: those only come once the\n // body has been read to its end, and `if (!res.ok) throw` never reads it.\n // Such a call used to leave no span at all, and its time showed up as a\n // stretch of the application's own code.\n if (!state.recorded) write(state, undefined);\n } catch {\n // Instrumentation must never break the host request.\n }\n}\n\nfunction onTrailers(message: unknown): void {\n const request = (message as { request?: object })?.request;\n if (request) finish(request, undefined);\n}\n\nfunction onError(message: unknown): void {\n const payload = message as { request?: object; error?: unknown };\n if (payload?.request) finish(payload.request, payload.error);\n}\n\nconst subscriptions: ReadonlyArray<readonly [string, (message: unknown) => void]> = [\n ['undici:request:create', onCreate],\n ['undici:request:headers', onHeaders],\n ['undici:request:trailers', onTrailers],\n ['undici:request:error', onError],\n];\n\nlet subscribed = false;\n\n/** Method and URL of a `fetch` call, best effort for every call shape. */\nfunction targetOf(input: unknown, init: unknown): [method: string, url: string] {\n const options = init as { method?: unknown } | undefined;\n if (input && typeof input === 'object' && 'url' in input && 'method' in input) {\n const request = input as { url: unknown; method: unknown };\n const method =\n typeof options?.method === 'string'\n ? options.method\n : typeof request.method === 'string'\n ? request.method\n : 'GET';\n return [method, typeof request.url === 'string' ? request.url : String(input)];\n }\n return [typeof options?.method === 'string' ? options.method : 'GET', String(input)];\n}\n\n/**\n * Wraps `globalThis.fetch` to capture the caller's line of code.\n *\n * The channels record the span, but they fire from the dispatcher where the\n * user's frame is gone. This wrapper is the only place the frame still exists;\n * the callsite is handed down the same way the pg pool wrapper does it. The\n * wrapper changes nothing else — arguments, return value and errors pass\n * through untouched.\n */\nfunction patchFetch(): void {\n patchMethod(\n globalThis,\n 'fetch',\n (original: any) =>\n function reqrayFetch(\n this: unknown,\n input: Parameters<typeof globalThis.fetch>[0],\n init?: Parameters<typeof globalThis.fetch>[1],\n ) {\n let handed: { callsite: Callsite | null } | null = null;\n try {\n const scope = current();\n if (scope) {\n const [method, url] = targetOf(input, init);\n handed = {\n callsite: resolveCallsite(scope, fingerprintHttp(method, url), reqrayFetch),\n };\n }\n } catch {\n // Instrumentation must never break the host call.\n }\n if (!handed) return original.call(this, input, init);\n return withHandedCallsite(handed, () => original.call(this, input, init));\n },\n );\n}\n\n/** Instrumentation for outgoing HTTP: undici and built-in `fetch`. */\nexport function instrumentUndici(): Instrumentation {\n return {\n name: 'undici',\n // The channels have been stable since undici 5; there is no range to check,\n // the subscription does not depend on the installed package version.\n supportedVersions: '*',\n captures: 'outgoing HTTP',\n\n apply() {\n if (subscribed) return;\n guarded('undici', () => {\n for (const [channel, handler] of subscriptions) {\n diagnosticsChannel.subscribe(channel, handler);\n }\n patchFetch();\n subscribed = true;\n });\n },\n\n unapply() {\n if (!subscribed) return;\n guarded('undici', () => {\n for (const [channel, handler] of subscriptions) {\n diagnosticsChannel.unsubscribe(channel, handler);\n }\n unpatchMethod(globalThis, 'fetch');\n });\n subscribed = false;\n },\n };\n}\n"],"mappings":";AAYA,OAAO,wBAAwB;AAC/B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAyBP,IAAM,WAAW,oBAAI,QAA2B;AAEhD,SAAS,MAAM,SAAgC;AAC7C,QAAM,SAAS,OAAO,QAAQ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S,YAEP,OACA,MACA;AACA,UAAI,SAA+C;AACnD,UAAI;AACF,cAAM,QAAQ,QAAQ;AACtB,YAAI,OAAO;AACT,gBAAM,CAAC,QAAQ,GAAG,IAAI,SAAS,OAAO,IAAI;AAC1C,mBAAS;AAAA,YACP,UAAU,gBAAgB,OAAO,gBAAgB,QAAQ,GAAG,GAAG,WAAW;AAAA,UAC5E;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AACA,UAAI,CAAC,OAAQ,QAAO,SAAS,KAAK,MAAM,OAAO,IAAI;AACnD,aAAO,mBAAmB,QAAQ,MAAM,SAAS,KAAK,MAAM,OAAO,IAAI,CAAC;AAAA,IAC1E;AAAA,EACJ;AACF;AAGO,SAAS,mBAAoC;AAClD,SAAO;AAAA,IACL,MAAM;AAAA;AAAA;AAAA,IAGN,mBAAmB;AAAA,IACnB,UAAU;AAAA,IAEV,QAAQ;AACN,UAAI,WAAY;AAChB,cAAQ,UAAU,MAAM;AACtB,mBAAW,CAAC,SAAS,OAAO,KAAK,eAAe;AAC9C,6BAAmB,UAAU,SAAS,OAAO;AAAA,QAC/C;AACA,mBAAW;AACX,qBAAa;AAAA,MACf,CAAC;AAAA,IACH;AAAA,IAEA,UAAU;AACR,UAAI,CAAC,WAAY;AACjB,cAAQ,UAAU,MAAM;AACtB,mBAAW,CAAC,SAAS,OAAO,KAAK,eAAe;AAC9C,6BAAmB,YAAY,SAAS,OAAO;AAAA,QACjD;AACA,sBAAc,YAAY,OAAO;AAAA,MACnC,CAAC;AACD,mBAAa;AAAA,IACf;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "@reqray/instrumentation-undici",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Outgoing HTTP instrumentation (undici / built-in fetch) for Reqray.",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "nodejs",
8
+ "debugging",
9
+ "profiling",
10
+ "n+1",
11
+ "sql",
12
+ "observability",
13
+ "devtools",
14
+ "fastify",
15
+ "express",
16
+ "nestjs"
17
+ ],
18
+ "homepage": "https://github.com/reqray/reqray#readme",
19
+ "bugs": "https://github.com/reqray/reqray/issues",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/reqray/reqray.git",
23
+ "directory": "packages/instrumentation-undici"
24
+ },
25
+ "type": "module",
26
+ "engines": {
27
+ "node": ">=20"
28
+ },
29
+ "exports": {
30
+ ".": {
31
+ "import": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/index.d.cts",
37
+ "default": "./dist/index.cjs"
38
+ }
39
+ }
40
+ },
41
+ "main": "./dist/index.cjs",
42
+ "module": "./dist/index.js",
43
+ "types": "./dist/index.d.ts",
44
+ "files": [
45
+ "dist"
46
+ ],
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "dependencies": {
51
+ "@reqray/core": "^0.1.1"
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^26.2.0",
55
+ "tsup": "^8.5.1",
56
+ "typescript": "^6.0.3"
57
+ },
58
+ "scripts": {
59
+ "build": "tsup",
60
+ "typecheck": "tsc --noEmit"
61
+ }
6
62
  }