@opentelemetry/instrumentation-http 0.222.0 → 0.300.0-development.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.
Files changed (56) hide show
  1. package/README.md +0 -2
  2. package/dist/_virtual/_rolldown/runtime.mjs +5 -0
  3. package/dist/http.cjs +425 -0
  4. package/dist/http.cjs.map +1 -0
  5. package/dist/http.d.cts +61 -0
  6. package/dist/http.d.cts.map +1 -0
  7. package/dist/http.d.mts +61 -0
  8. package/dist/http.d.mts.map +1 -0
  9. package/dist/http.mjs +425 -0
  10. package/dist/http.mjs.map +1 -0
  11. package/dist/index.cjs +3 -0
  12. package/dist/index.d.cts +3 -0
  13. package/dist/index.d.mts +3 -0
  14. package/dist/index.mjs +2 -0
  15. package/dist/internal-types.cjs +32 -0
  16. package/dist/internal-types.cjs.map +1 -0
  17. package/dist/internal-types.mjs +29 -0
  18. package/dist/internal-types.mjs.map +1 -0
  19. package/dist/semconv.cjs +18 -0
  20. package/dist/semconv.cjs.map +1 -0
  21. package/dist/semconv.mjs +17 -0
  22. package/dist/semconv.mjs.map +1 -0
  23. package/dist/types.d.cts +112 -0
  24. package/dist/types.d.cts.map +1 -0
  25. package/dist/types.d.mts +112 -0
  26. package/dist/types.d.mts.map +1 -0
  27. package/dist/utils.cjs +486 -0
  28. package/dist/utils.cjs.map +1 -0
  29. package/dist/utils.mjs +471 -0
  30. package/dist/utils.mjs.map +1 -0
  31. package/dist/version.cjs +6 -0
  32. package/dist/version.cjs.map +1 -0
  33. package/dist/version.mjs +6 -0
  34. package/dist/version.mjs.map +1 -0
  35. package/package.json +35 -25
  36. package/build/src/http.d.ts +0 -61
  37. package/build/src/http.js +0 -562
  38. package/build/src/http.js.map +0 -1
  39. package/build/src/index.d.ts +0 -3
  40. package/build/src/index.js +0 -10
  41. package/build/src/index.js.map +0 -1
  42. package/build/src/internal-types.d.ts +0 -42
  43. package/build/src/internal-types.js +0 -32
  44. package/build/src/internal-types.js.map +0 -1
  45. package/build/src/semconv.d.ts +0 -17
  46. package/build/src/semconv.js +0 -29
  47. package/build/src/semconv.js.map +0 -1
  48. package/build/src/types.d.ts +0 -115
  49. package/build/src/types.js +0 -3
  50. package/build/src/types.js.map +0 -1
  51. package/build/src/utils.d.ts +0 -105
  52. package/build/src/utils.js +0 -655
  53. package/build/src/utils.js.map +0 -1
  54. package/build/src/version.d.ts +0 -2
  55. package/build/src/version.js +0 -10
  56. package/build/src/version.js.map +0 -1
package/dist/utils.mjs ADDED
@@ -0,0 +1,471 @@
1
+ import { __require } from "./_virtual/_rolldown/runtime.mjs";
2
+ import { ATTR_USER_AGENT_SYNTHETIC_TYPE, USER_AGENT_SYNTHETIC_TYPE_VALUE_TEST } from "./semconv.mjs";
3
+ import { DEFAULT_QUERY_STRINGS_TO_REDACT, STR_REDACTED, SYNTHETIC_BOT_NAMES, SYNTHETIC_TEST_NAMES } from "./internal-types.mjs";
4
+ import { SpanKind, SpanStatusCode, context } from "@opentelemetry/api";
5
+ import { RPCType, getRPCMetadata } from "@opentelemetry/core";
6
+ import { ATTR_CLIENT_ADDRESS, ATTR_ERROR_TYPE, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_REQUEST_METHOD_ORIGINAL, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_HTTP_ROUTE, ATTR_NETWORK_PEER_ADDRESS, ATTR_NETWORK_PEER_PORT, ATTR_NETWORK_PROTOCOL_VERSION, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, ATTR_URL_PATH, ATTR_URL_QUERY, ATTR_URL_SCHEME, ATTR_USER_AGENT_ORIGINAL } from "@opentelemetry/semantic-conventions";
7
+ //#region src/utils.ts
8
+ const forwardedParse = __require("forwarded-parse");
9
+ const defaultQueryStringsToRedact = Array.from(DEFAULT_QUERY_STRINGS_TO_REDACT);
10
+ /**
11
+ * Redacts sensitive query parameters from a query string (without leading '?').
12
+ * Returns the input unchanged if it cannot be parsed.
13
+ */
14
+ const redactQueryString = (searchParams, paramsToRedact) => {
15
+ const params = new URLSearchParams(searchParams);
16
+ for (const param of paramsToRedact) if (params.has(param)) params.set(param, STR_REDACTED);
17
+ return params.toString();
18
+ };
19
+ /**
20
+ * Get an absolute url
21
+ */
22
+ const getAbsoluteUrl = (requestUrl, headers, fallbackProtocol = "http:", redactedQueryParams = Array.from(DEFAULT_QUERY_STRINGS_TO_REDACT)) => {
23
+ const reqUrlObject = requestUrl || {};
24
+ const protocol = reqUrlObject.protocol || fallbackProtocol;
25
+ const port = (reqUrlObject.port || "").toString();
26
+ let path = reqUrlObject.path || "/";
27
+ let host = typeof reqUrlObject.host === "string" && reqUrlObject.host || typeof reqUrlObject.hostname === "string" && reqUrlObject.hostname || typeof headers.host === "string" && headers.host || "localhost";
28
+ if (host.indexOf(":") === -1 && port && port !== "80" && port !== "443") host += `:${port}`;
29
+ if (typeof path === "string" && path.includes("?")) try {
30
+ const parsedUrl = new URL(path, "http://localhost");
31
+ const redacted = redactQueryString(parsedUrl.searchParams, redactedQueryParams);
32
+ path = `${parsedUrl.pathname}?${redacted}`;
33
+ } catch {}
34
+ return `${protocol}//${reqUrlObject.auth ? `${STR_REDACTED}:${STR_REDACTED}@` : ""}${host}${path}`;
35
+ };
36
+ /**
37
+ * Parse status code from HTTP response. [More details](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#status)
38
+ */
39
+ const parseResponseStatus = (kind, statusCode) => {
40
+ const upperBound = kind === SpanKind.CLIENT ? 400 : 500;
41
+ if (statusCode && statusCode >= 100 && statusCode < upperBound) return SpanStatusCode.UNSET;
42
+ return SpanStatusCode.ERROR;
43
+ };
44
+ /**
45
+ * Returns the `error.type` value for a response status code, or undefined when
46
+ * the code is not an error for this span kind. Semconv asks for the status code
47
+ * as a string once a response was received.
48
+ */
49
+ const parseErrorType = (kind, statusCode) => {
50
+ const lowerBound = kind === SpanKind.CLIENT ? 400 : 500;
51
+ if (typeof statusCode === "number" && statusCode >= lowerBound && statusCode < 600) return String(statusCode);
52
+ };
53
+ /**
54
+ * Sets the span with the error passed in params
55
+ * @param {Span} span the span that need to be set
56
+ * @param {Error} error error that will be set to span
57
+ */
58
+ const setSpanWithError = (span, error) => {
59
+ const message = error.message;
60
+ span.setAttribute(ATTR_ERROR_TYPE, error.name);
61
+ span.setStatus({
62
+ code: SpanStatusCode.ERROR,
63
+ message
64
+ });
65
+ span.recordException(error);
66
+ };
67
+ /**
68
+ * Mimics Node.js conversion of URL strings to RequestOptions expected by
69
+ * `http.request` and `https.request` APIs.
70
+ *
71
+ * See https://github.com/nodejs/node/blob/2505e217bba05fc581b572c685c5cf280a16c5a3/lib/internal/url.js#L1415-L1437
72
+ *
73
+ * @param stringUrl
74
+ * @throws TypeError if the URL is not valid.
75
+ */
76
+ function stringUrlToHttpOptions(stringUrl) {
77
+ const { hostname, pathname, port, username, password, search, protocol, hash, href, origin, host } = new URL(stringUrl);
78
+ const options = {
79
+ protocol,
80
+ hostname: hostname && hostname[0] === "[" ? hostname.slice(1, -1) : hostname,
81
+ hash,
82
+ search,
83
+ pathname,
84
+ path: `${pathname || ""}${search || ""}`,
85
+ href,
86
+ origin,
87
+ host
88
+ };
89
+ if (port !== "") options.port = Number(port);
90
+ if (username || password) options.auth = `${decodeURIComponent(username)}:${decodeURIComponent(password)}`;
91
+ return options;
92
+ }
93
+ /**
94
+ * Mirrors how Node.js detects WHATWG `URL` objects passed to `http.request`
95
+ * and `https.request`: by shape rather than by `instanceof`, so that URL
96
+ * objects from other realms (e.g. `vm` contexts) or WHATWG URL polyfills are
97
+ * handled the same way Node.js handles them.
98
+ *
99
+ * This mirrors Node's `isURL()` predicate exactly. The `auth`/`path` guards
100
+ * matter: they keep options objects and legacy `url.parse()` results (both
101
+ * carry `path`) off the URL code path.
102
+ *
103
+ * See https://github.com/nodejs/node/blob/2505e217bba05fc581b572c685c5cf280a16c5a3/lib/internal/url.js#L756-L773
104
+ */
105
+ const isURLLike = (value) => {
106
+ const candidate = value;
107
+ return Boolean(candidate?.href && candidate.protocol && candidate.auth === void 0 && candidate.path === void 0);
108
+ };
109
+ /**
110
+ * Makes sure options is an url object
111
+ * return an object with default value and parsed options
112
+ * @param logger component logger
113
+ * @param options original options for the request
114
+ * @param [extraOptions] additional options for the request
115
+ */
116
+ const getRequestInfo = (logger, options, extraOptions) => {
117
+ let pathname;
118
+ let origin;
119
+ let optionsParsed;
120
+ let invalidUrl = false;
121
+ if (typeof options === "string") {
122
+ try {
123
+ const convertedOptions = stringUrlToHttpOptions(options);
124
+ optionsParsed = convertedOptions;
125
+ pathname = convertedOptions.pathname || "/";
126
+ } catch (e) {
127
+ invalidUrl = true;
128
+ logger.verbose("Unable to parse URL provided to HTTP request, using fallback to determine path. Original error:", e);
129
+ optionsParsed = { path: options };
130
+ pathname = optionsParsed.path || "/";
131
+ }
132
+ origin = `${optionsParsed.protocol || "http:"}//${optionsParsed.host}`;
133
+ if (extraOptions !== void 0) Object.assign(optionsParsed, extraOptions);
134
+ } else if (isURLLike(options)) {
135
+ optionsParsed = {
136
+ protocol: options.protocol,
137
+ hostname: typeof options.hostname === "string" && options.hostname.startsWith("[") ? options.hostname.slice(1, -1) : options.hostname,
138
+ path: `${options.pathname || ""}${options.search || ""}`
139
+ };
140
+ if (options.port !== "") optionsParsed.port = Number(options.port);
141
+ if (options.username || options.password) optionsParsed.auth = `${options.username}:${options.password}`;
142
+ pathname = options.pathname;
143
+ origin = options.origin;
144
+ if (extraOptions !== void 0) Object.assign(optionsParsed, extraOptions);
145
+ } else {
146
+ optionsParsed = Object.assign({ protocol: options.host ? "http:" : void 0 }, options);
147
+ const hostname = optionsParsed.host || (optionsParsed.port != null ? `${optionsParsed.hostname}${optionsParsed.port}` : optionsParsed.hostname);
148
+ origin = `${optionsParsed.protocol || "http:"}//${hostname}`;
149
+ pathname = options.pathname;
150
+ if (!pathname && optionsParsed.path) try {
151
+ pathname = new URL(optionsParsed.path, origin).pathname || "/";
152
+ } catch {
153
+ pathname = "/";
154
+ }
155
+ }
156
+ const method = optionsParsed.method && typeof optionsParsed.method === "string" ? optionsParsed.method.toUpperCase() : "GET";
157
+ return {
158
+ origin,
159
+ pathname,
160
+ method,
161
+ optionsParsed,
162
+ invalidUrl
163
+ };
164
+ };
165
+ /**
166
+ * Makes sure options is of type string or object
167
+ * @param options for the request
168
+ */
169
+ const isValidOptionsType = (options) => {
170
+ if (!options) return false;
171
+ const type = typeof options;
172
+ return type === "string" || type === "object" && !Array.isArray(options);
173
+ };
174
+ const extractHostnameAndPort = (requestOptions) => {
175
+ const optionsHostname = typeof requestOptions.hostname === "string" ? requestOptions.hostname : void 0;
176
+ const optionsHost = typeof requestOptions.host === "string" ? requestOptions.host : void 0;
177
+ const optionsPort = typeof requestOptions.port === "string" || typeof requestOptions.port === "number" ? requestOptions.port : void 0;
178
+ if (optionsHostname && optionsPort) return {
179
+ hostname: optionsHostname,
180
+ port: optionsPort
181
+ };
182
+ const matches = optionsHost?.match(/^([^:/ ]+)(:\d{1,5})?/) || null;
183
+ const hostname = optionsHostname || (matches === null ? "localhost" : matches[1]);
184
+ let port = optionsPort;
185
+ if (!port) {
186
+ if (matches && matches[2]) port = matches[2].substring(1);
187
+ else port = requestOptions.protocol === "https:" ? "443" : "80";
188
+ }
189
+ return {
190
+ hostname,
191
+ port
192
+ };
193
+ };
194
+ /**
195
+ * Returns outgoing request attributes scoped to the options passed to the request
196
+ * @param {ParsedRequestOptions} requestOptions the same options used to make the request
197
+ * @param {{ component: string, hostname: string, hookAttributes?: Attributes }} options used to pass data needed to create attributes
198
+ */
199
+ const getOutgoingRequestAttributes = (requestOptions, options, enableSyntheticSourceDetection) => {
200
+ const hostname = options.hostname;
201
+ const port = options.port;
202
+ const method = requestOptions.method ?? "GET";
203
+ const normalizedMethod = normalizeMethod(method);
204
+ const headers = requestOptions.headers || {};
205
+ const userAgent = headers["user-agent"];
206
+ const urlFull = getAbsoluteUrl(requestOptions, headers, `${options.component}:`, options.redactedQueryParams);
207
+ const attributes = {
208
+ [ATTR_HTTP_REQUEST_METHOD]: normalizedMethod,
209
+ [ATTR_SERVER_ADDRESS]: hostname,
210
+ [ATTR_SERVER_PORT]: Number(port),
211
+ [ATTR_URL_FULL]: urlFull,
212
+ [ATTR_USER_AGENT_ORIGINAL]: userAgent
213
+ };
214
+ if (method !== normalizedMethod) attributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = method;
215
+ if (enableSyntheticSourceDetection && userAgent) attributes[ATTR_USER_AGENT_SYNTHETIC_TYPE] = getSyntheticType(userAgent);
216
+ return Object.assign(attributes, options.hookAttributes);
217
+ };
218
+ /**
219
+ * Returns the type of synthetic source based on the user agent
220
+ * @param {OutgoingHttpHeader} userAgent the user agent string
221
+ */
222
+ const getSyntheticType = (userAgent) => {
223
+ const userAgentString = String(userAgent).toLowerCase();
224
+ for (const name of SYNTHETIC_TEST_NAMES) if (userAgentString.includes(name)) return USER_AGENT_SYNTHETIC_TYPE_VALUE_TEST;
225
+ for (const name of SYNTHETIC_BOT_NAMES) if (userAgentString.includes(name)) return "bot";
226
+ };
227
+ /**
228
+ * Returns outgoing request attributes scoped to the response data
229
+ * @param {IncomingMessage} response the response object
230
+ */
231
+ const getOutgoingRequestAttributesOnResponse = (response) => {
232
+ const { statusCode, socket } = response;
233
+ const attributes = {};
234
+ if (statusCode != null) attributes[ATTR_HTTP_RESPONSE_STATUS_CODE] = statusCode;
235
+ if (socket) {
236
+ const { remoteAddress, remotePort } = socket;
237
+ attributes[ATTR_NETWORK_PEER_ADDRESS] = remoteAddress;
238
+ attributes[ATTR_NETWORK_PEER_PORT] = remotePort;
239
+ attributes[ATTR_NETWORK_PROTOCOL_VERSION] = response.httpVersion;
240
+ }
241
+ return attributes;
242
+ };
243
+ /**
244
+ * Returns outgoing request Metric attributes scoped to the response data
245
+ * @param {Attributes} spanAttributes the span attributes
246
+ */
247
+ const getOutgoingStableRequestMetricAttributesOnResponse = (spanAttributes) => {
248
+ const metricAttributes = {};
249
+ if (spanAttributes[ATTR_NETWORK_PROTOCOL_VERSION]) metricAttributes[ATTR_NETWORK_PROTOCOL_VERSION] = spanAttributes[ATTR_NETWORK_PROTOCOL_VERSION];
250
+ const statusCode = spanAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE];
251
+ if (statusCode) {
252
+ metricAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE] = statusCode;
253
+ const errorType = parseErrorType(SpanKind.CLIENT, statusCode);
254
+ if (errorType !== void 0) metricAttributes[ATTR_ERROR_TYPE] ??= errorType;
255
+ }
256
+ return metricAttributes;
257
+ };
258
+ function parseHostHeader(hostHeader, proto) {
259
+ const parts = hostHeader.split(":");
260
+ if (parts.length === 1) {
261
+ if (proto === "http") return {
262
+ host: parts[0],
263
+ port: "80"
264
+ };
265
+ if (proto === "https") return {
266
+ host: parts[0],
267
+ port: "443"
268
+ };
269
+ return { host: parts[0] };
270
+ }
271
+ if (parts.length === 2) return {
272
+ host: parts[0],
273
+ port: parts[1]
274
+ };
275
+ if (parts[0].startsWith("[")) {
276
+ if (parts[parts.length - 1].endsWith("]")) {
277
+ if (proto === "http") return {
278
+ host: hostHeader,
279
+ port: "80"
280
+ };
281
+ if (proto === "https") return {
282
+ host: hostHeader,
283
+ port: "443"
284
+ };
285
+ } else if (parts[parts.length - 2].endsWith("]")) return {
286
+ host: parts.slice(0, -1).join(":"),
287
+ port: parts[parts.length - 1]
288
+ };
289
+ }
290
+ return { host: hostHeader };
291
+ }
292
+ /**
293
+ * Get server.address and port according to http semconv 1.27
294
+ * https://github.com/open-telemetry/semantic-conventions/blob/bf0a2c1134f206f034408b201dbec37960ed60ec/docs/http/http-spans.md#setting-serveraddress-and-serverport-attributes
295
+ */
296
+ function getServerAddress(request, component) {
297
+ const forwardedHeader = request.headers["forwarded"];
298
+ if (forwardedHeader) {
299
+ for (const entry of parseForwardedHeader(forwardedHeader)) if (entry.host) return parseHostHeader(entry.host, entry.proto);
300
+ }
301
+ const xForwardedHost = request.headers["x-forwarded-host"];
302
+ if (typeof xForwardedHost === "string") {
303
+ if (typeof request.headers["x-forwarded-proto"] === "string") return parseHostHeader(xForwardedHost, request.headers["x-forwarded-proto"]);
304
+ if (Array.isArray(request.headers["x-forwarded-proto"])) return parseHostHeader(xForwardedHost, request.headers["x-forwarded-proto"][0]);
305
+ return parseHostHeader(xForwardedHost);
306
+ } else if (Array.isArray(xForwardedHost) && typeof xForwardedHost[0] === "string" && xForwardedHost[0].length > 0) {
307
+ if (typeof request.headers["x-forwarded-proto"] === "string") return parseHostHeader(xForwardedHost[0], request.headers["x-forwarded-proto"]);
308
+ if (Array.isArray(request.headers["x-forwarded-proto"])) return parseHostHeader(xForwardedHost[0], request.headers["x-forwarded-proto"][0]);
309
+ return parseHostHeader(xForwardedHost[0]);
310
+ }
311
+ const host = request.headers["host"];
312
+ if (typeof host === "string" && host.length > 0) return parseHostHeader(host, component);
313
+ return null;
314
+ }
315
+ /**
316
+ * Get server.address and port according to http semconv 1.27
317
+ * https://github.com/open-telemetry/semantic-conventions/blob/bf0a2c1134f206f034408b201dbec37960ed60ec/docs/http/http-spans.md#setting-serveraddress-and-serverport-attributes
318
+ */
319
+ function getRemoteClientAddress(request) {
320
+ const forwardedHeader = request.headers["forwarded"];
321
+ if (forwardedHeader) {
322
+ for (const entry of parseForwardedHeader(forwardedHeader)) if (entry.for) return removePortFromAddress(entry.for);
323
+ }
324
+ const xForwardedFor = request.headers["x-forwarded-for"];
325
+ if (xForwardedFor) {
326
+ let xForwardedForVal;
327
+ if (typeof xForwardedFor === "string") xForwardedForVal = xForwardedFor;
328
+ else if (Array.isArray(xForwardedFor)) xForwardedForVal = xForwardedFor[0];
329
+ if (typeof xForwardedForVal === "string") {
330
+ xForwardedForVal = xForwardedForVal.split(",")[0].trim();
331
+ return removePortFromAddress(xForwardedForVal);
332
+ }
333
+ }
334
+ const remote = request.socket.remoteAddress;
335
+ if (remote) return remote;
336
+ return null;
337
+ }
338
+ function removePortFromAddress(input) {
339
+ try {
340
+ const { hostname: address } = new URL(`http://${input}`);
341
+ if (address.startsWith("[") && address.endsWith("]")) return address.slice(1, -1);
342
+ return address;
343
+ } catch {
344
+ return input;
345
+ }
346
+ }
347
+ function getInfoFromIncomingMessage(component, request, logger) {
348
+ try {
349
+ if (request.headers.host) return new URL(request.url ?? "/", `${component}://${request.headers.host}`);
350
+ else {
351
+ const unsafeParsedUrl = new URL(request.url ?? "/", `${component}://localhost`);
352
+ return {
353
+ pathname: unsafeParsedUrl.pathname,
354
+ search: unsafeParsedUrl.search,
355
+ toString: function() {
356
+ return unsafeParsedUrl.pathname + unsafeParsedUrl.search;
357
+ }
358
+ };
359
+ }
360
+ } catch (e) {
361
+ logger.verbose("Unable to get URL from request", e);
362
+ return {};
363
+ }
364
+ }
365
+ /**
366
+ * Returns incoming request attributes scoped to the request data
367
+ * @param {IncomingMessage} request the request object
368
+ * @param {{ component: string, hookAttributes?: Attributes, enableSyntheticSourceDetection: boolean }} options used to pass data needed to create attributes
369
+ */
370
+ const getIncomingRequestAttributes = (request, options, logger) => {
371
+ const { component, enableSyntheticSourceDetection, hookAttributes, redactedQueryParams } = options;
372
+ const { headers, method } = request;
373
+ const { "user-agent": userAgent } = headers;
374
+ const parsedUrl = getInfoFromIncomingMessage(component, request, logger);
375
+ const normalizedMethod = normalizeMethod(method);
376
+ const serverAddress = getServerAddress(request, component);
377
+ const remoteClientAddress = getRemoteClientAddress(request);
378
+ const attributes = {
379
+ [ATTR_HTTP_REQUEST_METHOD]: normalizedMethod,
380
+ [ATTR_URL_SCHEME]: component,
381
+ [ATTR_SERVER_ADDRESS]: serverAddress?.host,
382
+ [ATTR_NETWORK_PEER_ADDRESS]: request.socket.remoteAddress,
383
+ [ATTR_NETWORK_PEER_PORT]: request.socket.remotePort,
384
+ [ATTR_NETWORK_PROTOCOL_VERSION]: request.httpVersion,
385
+ [ATTR_USER_AGENT_ORIGINAL]: userAgent
386
+ };
387
+ if (parsedUrl.pathname != null) attributes[ATTR_URL_PATH] = parsedUrl.pathname;
388
+ if (parsedUrl.search) {
389
+ const paramsToRedact = redactedQueryParams ?? defaultQueryStringsToRedact;
390
+ attributes[ATTR_URL_QUERY] = redactQueryString(new URLSearchParams(parsedUrl.search.slice(1)), paramsToRedact);
391
+ }
392
+ if (remoteClientAddress != null) attributes[ATTR_CLIENT_ADDRESS] = remoteClientAddress;
393
+ if (serverAddress?.port != null) attributes[ATTR_SERVER_PORT] = Number(serverAddress.port);
394
+ if (method !== normalizedMethod) attributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = method;
395
+ if (enableSyntheticSourceDetection && userAgent) attributes[ATTR_USER_AGENT_SYNTHETIC_TYPE] = getSyntheticType(userAgent);
396
+ return Object.assign(attributes, hookAttributes);
397
+ };
398
+ /**
399
+ * Returns incoming request attributes scoped to the response data
400
+ * @param {(ServerResponse & { socket: Socket; })} response the response object
401
+ */
402
+ const getIncomingRequestAttributesOnResponse = (response) => {
403
+ const { statusCode } = response;
404
+ const attributes = { [ATTR_HTTP_RESPONSE_STATUS_CODE]: statusCode };
405
+ const rpcMetadata = getRPCMetadata(context.active());
406
+ if (rpcMetadata?.type === RPCType.HTTP && rpcMetadata.route !== void 0) attributes[ATTR_HTTP_ROUTE] = rpcMetadata.route;
407
+ return attributes;
408
+ };
409
+ /**
410
+ * Returns incoming stable request Metric attributes scoped to the request data
411
+ * @param {Attributes} spanAttributes the span attributes
412
+ */
413
+ const getIncomingStableRequestMetricAttributesOnResponse = (spanAttributes) => {
414
+ const metricAttributes = {};
415
+ if (spanAttributes[ATTR_HTTP_ROUTE] !== void 0) metricAttributes[ATTR_HTTP_ROUTE] = spanAttributes[ATTR_HTTP_ROUTE];
416
+ const statusCode = spanAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE];
417
+ if (statusCode) {
418
+ metricAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE] = statusCode;
419
+ const errorType = parseErrorType(SpanKind.SERVER, statusCode);
420
+ if (errorType !== void 0) metricAttributes[ATTR_ERROR_TYPE] ??= errorType;
421
+ }
422
+ return metricAttributes;
423
+ };
424
+ function headerCapture(type, headers) {
425
+ const normalizedHeaders = /* @__PURE__ */ new Map();
426
+ for (let i = 0, len = headers.length; i < len; i++) {
427
+ const capturedHeader = headers[i].toLowerCase();
428
+ normalizedHeaders.set(capturedHeader, capturedHeader);
429
+ }
430
+ return (getHeader) => {
431
+ const attributes = {};
432
+ for (const capturedHeader of normalizedHeaders.keys()) {
433
+ const value = getHeader(capturedHeader);
434
+ if (value === void 0) continue;
435
+ const key = `http.${type}.header.${normalizedHeaders.get(capturedHeader)}`;
436
+ if (typeof value === "string") attributes[key] = [value];
437
+ else if (Array.isArray(value)) attributes[key] = value;
438
+ else attributes[key] = [value];
439
+ }
440
+ return attributes;
441
+ };
442
+ }
443
+ const KNOWN_METHODS = /* @__PURE__ */ new Set([
444
+ "GET",
445
+ "HEAD",
446
+ "POST",
447
+ "PUT",
448
+ "DELETE",
449
+ "CONNECT",
450
+ "OPTIONS",
451
+ "TRACE",
452
+ "PATCH",
453
+ "QUERY"
454
+ ]);
455
+ function normalizeMethod(method) {
456
+ if (method == null) return "GET";
457
+ const upper = method.toUpperCase();
458
+ if (KNOWN_METHODS.has(upper)) return upper;
459
+ return "_OTHER";
460
+ }
461
+ function parseForwardedHeader(header) {
462
+ try {
463
+ return forwardedParse(header);
464
+ } catch {
465
+ return [];
466
+ }
467
+ }
468
+ //#endregion
469
+ export { extractHostnameAndPort, getAbsoluteUrl, getIncomingRequestAttributes, getIncomingRequestAttributesOnResponse, getIncomingStableRequestMetricAttributesOnResponse, getOutgoingRequestAttributes, getOutgoingRequestAttributesOnResponse, getOutgoingStableRequestMetricAttributesOnResponse, getRemoteClientAddress, getRequestInfo, headerCapture, isURLLike, isValidOptionsType, parseErrorType, parseResponseStatus, redactQueryString, setSpanWithError };
470
+
471
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../src/utils.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type {\n Attributes,\n Span,\n DiagLogger,\n AttributeValue,\n} from '@opentelemetry/api';\nimport { SpanStatusCode, context, SpanKind } from '@opentelemetry/api';\nimport {\n ATTR_CLIENT_ADDRESS,\n ATTR_ERROR_TYPE,\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_REQUEST_METHOD_ORIGINAL,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_HTTP_ROUTE,\n ATTR_NETWORK_PEER_ADDRESS,\n ATTR_NETWORK_PEER_PORT,\n ATTR_NETWORK_PROTOCOL_VERSION,\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 '@opentelemetry/semantic-conventions';\nimport {\n ATTR_USER_AGENT_SYNTHETIC_TYPE,\n USER_AGENT_SYNTHETIC_TYPE_VALUE_BOT,\n USER_AGENT_SYNTHETIC_TYPE_VALUE_TEST,\n} from './semconv';\nimport type {\n IncomingHttpHeaders,\n IncomingMessage,\n OutgoingHttpHeader,\n OutgoingHttpHeaders,\n RequestOptions,\n ServerResponse,\n} from 'http';\nimport { getRPCMetadata, RPCType } from '@opentelemetry/core';\nimport type * as url from 'url';\nimport type {\n Err,\n IgnoreMatcher,\n ParsedRequestOptions,\n} from './internal-types';\nimport { SYNTHETIC_BOT_NAMES, SYNTHETIC_TEST_NAMES } from './internal-types';\nimport {\n DEFAULT_QUERY_STRINGS_TO_REDACT,\n STR_REDACTED,\n} from './internal-types';\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nimport forwardedParse = require('forwarded-parse');\n\nconst defaultQueryStringsToRedact = Array.from(DEFAULT_QUERY_STRINGS_TO_REDACT);\n\n/**\n * Redacts sensitive query parameters from a query string (without leading '?').\n * Returns the input unchanged if it cannot be parsed.\n */\nexport const redactQueryString = (\n searchParams: URLSearchParams,\n paramsToRedact: string[]\n): string => {\n const params = new URLSearchParams(searchParams);\n for (const param of paramsToRedact) {\n if (params.has(param)) {\n params.set(param, STR_REDACTED);\n }\n }\n return params.toString();\n};\n\n/**\n * Get an absolute url\n */\nexport const getAbsoluteUrl = (\n requestUrl: ParsedRequestOptions | null,\n headers: IncomingHttpHeaders | OutgoingHttpHeaders,\n fallbackProtocol = 'http:',\n redactedQueryParams: string[] = Array.from(DEFAULT_QUERY_STRINGS_TO_REDACT)\n): string => {\n const reqUrlObject = requestUrl || {};\n const protocol = reqUrlObject.protocol || fallbackProtocol;\n const port = (reqUrlObject.port || '').toString();\n let path = reqUrlObject.path || '/';\n // `host`, `hostname` and the `host` header may hold values of unexpected\n // types at runtime. Node.js itself ignores non-string values when it can\n // derive the target from another option (e.g. it uses `hostname` when\n // `host` is not a valid string), so skip non-string candidates instead of\n // crashing on them.\n let host: string =\n (typeof reqUrlObject.host === 'string' && reqUrlObject.host) ||\n (typeof reqUrlObject.hostname === 'string' && reqUrlObject.hostname) ||\n (typeof headers.host === 'string' && headers.host) ||\n 'localhost';\n // if there is no port in host and there is a port\n // it should be displayed if it's not 80 and 443 (default ports)\n if (host.indexOf(':') === -1 && port && port !== '80' && port !== '443') {\n host += `:${port}`;\n }\n // Redact sensitive query parameters\n if (typeof path === 'string' && path.includes('?')) {\n try {\n const parsedUrl = new URL(path, 'http://localhost');\n const redacted = redactQueryString(\n parsedUrl.searchParams,\n redactedQueryParams\n );\n path = `${parsedUrl.pathname}?${redacted}`;\n } catch {\n // Ignore error, as the path was not a valid URL.\n }\n }\n const authPart = reqUrlObject.auth ? `${STR_REDACTED}:${STR_REDACTED}@` : '';\n return `${protocol}//${authPart}${host}${path}`;\n};\n\n/**\n * Parse status code from HTTP response. [More details](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#status)\n */\nexport const parseResponseStatus = (\n kind: SpanKind,\n statusCode?: number\n): SpanStatusCode => {\n const upperBound = kind === SpanKind.CLIENT ? 400 : 500;\n // 1xx, 2xx, 3xx are OK on client and server\n // 4xx is OK on server\n if (statusCode && statusCode >= 100 && statusCode < upperBound) {\n return SpanStatusCode.UNSET;\n }\n\n // All other codes are error\n return SpanStatusCode.ERROR;\n};\n\n/**\n * Returns the `error.type` value for a response status code, or undefined when\n * the code is not an error for this span kind. Semconv asks for the status code\n * as a string once a response was received.\n */\nexport const parseErrorType = (\n kind: SpanKind,\n statusCode?: unknown\n): string | undefined => {\n const lowerBound = kind === SpanKind.CLIENT ? 400 : 500;\n if (\n typeof statusCode === 'number' &&\n statusCode >= lowerBound &&\n statusCode < 600\n ) {\n return String(statusCode);\n }\n\n return undefined;\n};\n\n/**\n * Check whether the given obj match pattern\n * @param constant e.g URL of request\n * @param pattern Match pattern\n */\nexport const satisfiesPattern = (\n constant: string,\n pattern: IgnoreMatcher\n): boolean => {\n if (typeof pattern === 'string') {\n return pattern === constant;\n } else if (pattern instanceof RegExp) {\n return pattern.test(constant);\n } else if (typeof pattern === 'function') {\n return pattern(constant);\n } else {\n throw new TypeError('Pattern is in unsupported datatype');\n }\n};\n\n/**\n * Sets the span with the error passed in params\n * @param {Span} span the span that need to be set\n * @param {Error} error error that will be set to span\n */\nexport const setSpanWithError = (span: Span, error: Err): void => {\n const message = error.message;\n span.setAttribute(ATTR_ERROR_TYPE, error.name);\n span.setStatus({ code: SpanStatusCode.ERROR, message });\n span.recordException(error);\n};\n\nexport const isCompressed = (\n headers: OutgoingHttpHeaders | IncomingHttpHeaders\n): boolean => {\n const encoding = headers['content-encoding'];\n\n return !!encoding && encoding !== 'identity';\n};\n\n/**\n * Mimics Node.js conversion of URL strings to RequestOptions expected by\n * `http.request` and `https.request` APIs.\n *\n * See https://github.com/nodejs/node/blob/2505e217bba05fc581b572c685c5cf280a16c5a3/lib/internal/url.js#L1415-L1437\n *\n * @param stringUrl\n * @throws TypeError if the URL is not valid.\n */\nfunction stringUrlToHttpOptions(\n stringUrl: string\n): RequestOptions & { pathname: string } {\n // This is heavily inspired by Node.js handling of the same situation, trying\n // to follow it as closely as possible while keeping in mind that we only\n // deal with string URLs, not URL objects.\n const {\n hostname,\n pathname,\n port,\n username,\n password,\n search,\n protocol,\n hash,\n href,\n origin,\n host,\n } = new URL(stringUrl);\n\n const options: RequestOptions & {\n pathname: string;\n hash: string;\n search: string;\n href: string;\n origin: string;\n } = {\n protocol: protocol,\n hostname:\n hostname && hostname[0] === '[' ? hostname.slice(1, -1) : hostname,\n hash: hash,\n search: search,\n pathname: pathname,\n path: `${pathname || ''}${search || ''}`,\n href: href,\n origin: origin,\n host: host,\n };\n if (port !== '') {\n options.port = Number(port);\n }\n if (username || password) {\n options.auth = `${decodeURIComponent(username)}:${decodeURIComponent(\n password\n )}`;\n }\n return options;\n}\n\n/**\n * Mirrors how Node.js detects WHATWG `URL` objects passed to `http.request`\n * and `https.request`: by shape rather than by `instanceof`, so that URL\n * objects from other realms (e.g. `vm` contexts) or WHATWG URL polyfills are\n * handled the same way Node.js handles them.\n *\n * This mirrors Node's `isURL()` predicate exactly. The `auth`/`path` guards\n * matter: they keep options objects and legacy `url.parse()` results (both\n * carry `path`) off the URL code path.\n *\n * See https://github.com/nodejs/node/blob/2505e217bba05fc581b572c685c5cf280a16c5a3/lib/internal/url.js#L756-L773\n */\nexport const isURLLike = (value: unknown): value is url.URL => {\n const candidate = value as\n | (url.URL & { auth?: unknown; path?: unknown })\n | undefined;\n return Boolean(\n candidate?.href &&\n candidate.protocol &&\n candidate.auth === undefined &&\n candidate.path === undefined\n );\n};\n\n/**\n * Makes sure options is an url object\n * return an object with default value and parsed options\n * @param logger component logger\n * @param options original options for the request\n * @param [extraOptions] additional options for the request\n */\nexport const getRequestInfo = (\n logger: DiagLogger,\n options: url.URL | RequestOptions | string,\n extraOptions?: RequestOptions\n): {\n origin: string;\n pathname: string;\n method: string;\n invalidUrl: boolean;\n optionsParsed: RequestOptions;\n} => {\n let pathname: string;\n let origin: string;\n let optionsParsed: RequestOptions;\n let invalidUrl = false;\n if (typeof options === 'string') {\n try {\n const convertedOptions = stringUrlToHttpOptions(options);\n optionsParsed = convertedOptions;\n pathname = convertedOptions.pathname || '/';\n } catch (e) {\n invalidUrl = true;\n logger.verbose(\n 'Unable to parse URL provided to HTTP request, using fallback to determine path. Original error:',\n e\n );\n // for backward compatibility with how url.parse() behaved.\n optionsParsed = {\n path: options,\n };\n pathname = optionsParsed.path || '/';\n }\n\n origin = `${optionsParsed.protocol || 'http:'}//${optionsParsed.host}`;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else if (isURLLike(options)) {\n optionsParsed = {\n protocol: options.protocol,\n hostname:\n typeof options.hostname === 'string' && options.hostname.startsWith('[')\n ? options.hostname.slice(1, -1)\n : options.hostname,\n path: `${options.pathname || ''}${options.search || ''}`,\n };\n if (options.port !== '') {\n optionsParsed.port = Number(options.port);\n }\n if (options.username || options.password) {\n optionsParsed.auth = `${options.username}:${options.password}`;\n }\n pathname = options.pathname;\n origin = options.origin;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else {\n optionsParsed = Object.assign(\n { protocol: options.host ? 'http:' : undefined },\n options\n );\n\n const hostname =\n optionsParsed.host ||\n (optionsParsed.port != null\n ? `${optionsParsed.hostname}${optionsParsed.port}`\n : optionsParsed.hostname);\n origin = `${optionsParsed.protocol || 'http:'}//${hostname}`;\n\n pathname = (options as url.URL).pathname;\n if (!pathname && optionsParsed.path) {\n try {\n const parsedUrl = new URL(optionsParsed.path, origin);\n pathname = parsedUrl.pathname || '/';\n } catch {\n pathname = '/';\n }\n }\n }\n\n // some packages return method in lowercase..\n // ensure upperCase for consistency\n // Note: a non-string `method` is rejected by Node.js itself; skip it here\n // so the resulting error comes from Node.js and not the instrumentation.\n const method =\n optionsParsed.method && typeof optionsParsed.method === 'string'\n ? optionsParsed.method.toUpperCase()\n : 'GET';\n\n return { origin, pathname, method, optionsParsed, invalidUrl };\n};\n\n/**\n * Makes sure options is of type string or object\n * @param options for the request\n */\nexport const isValidOptionsType = (options: unknown): boolean => {\n if (!options) {\n return false;\n }\n\n const type = typeof options;\n return type === 'string' || (type === 'object' && !Array.isArray(options));\n};\n\nexport const extractHostnameAndPort = (\n requestOptions: Pick<\n ParsedRequestOptions,\n 'hostname' | 'host' | 'port' | 'protocol'\n >\n): { hostname: string; port: number | string } => {\n // `hostname`, `host` and `port` may hold values of unexpected types at\n // runtime. Node.js itself ignores non-string values when it can derive the\n // target from another option (e.g. it uses `hostname` when `host` is not a\n // valid string), so skip non-string candidates instead of crashing on them.\n const optionsHostname =\n typeof requestOptions.hostname === 'string'\n ? requestOptions.hostname\n : undefined;\n const optionsHost =\n typeof requestOptions.host === 'string' ? requestOptions.host : undefined;\n const optionsPort =\n typeof requestOptions.port === 'string' ||\n typeof requestOptions.port === 'number'\n ? requestOptions.port\n : undefined;\n\n if (optionsHostname && optionsPort) {\n return { hostname: optionsHostname, port: optionsPort };\n }\n const matches = optionsHost?.match(/^([^:/ ]+)(:\\d{1,5})?/) || null;\n const hostname =\n optionsHostname || (matches === null ? 'localhost' : matches[1]);\n let port = optionsPort;\n if (!port) {\n if (matches && matches[2]) {\n // remove the leading \":\". The extracted port would be something like \":8080\"\n port = matches[2].substring(1);\n } else {\n port = requestOptions.protocol === 'https:' ? '443' : '80';\n }\n }\n return { hostname, port };\n};\n\n/**\n * Returns outgoing request attributes scoped to the options passed to the request\n * @param {ParsedRequestOptions} requestOptions the same options used to make the request\n * @param {{ component: string, hostname: string, hookAttributes?: Attributes }} options used to pass data needed to create attributes\n */\nexport const getOutgoingRequestAttributes = (\n requestOptions: ParsedRequestOptions,\n options: {\n component: string;\n hostname: string;\n port: string | number;\n hookAttributes?: Attributes;\n redactedQueryParams?: string[];\n },\n enableSyntheticSourceDetection: boolean\n): Attributes => {\n const hostname = options.hostname;\n const port = options.port;\n const method = requestOptions.method ?? 'GET';\n const normalizedMethod = normalizeMethod(method);\n const headers = (requestOptions.headers || {}) as OutgoingHttpHeaders;\n const userAgent = headers['user-agent'];\n const urlFull = getAbsoluteUrl(\n requestOptions,\n headers,\n `${options.component}:`,\n options.redactedQueryParams\n );\n\n const attributes: Attributes = {\n // Required attributes\n [ATTR_HTTP_REQUEST_METHOD]: normalizedMethod,\n [ATTR_SERVER_ADDRESS]: hostname,\n [ATTR_SERVER_PORT]: Number(port),\n [ATTR_URL_FULL]: urlFull,\n [ATTR_USER_AGENT_ORIGINAL]: userAgent,\n // leaving out protocol version, it is not yet negotiated\n // leaving out protocol name, it is only required when protocol version is set\n // retries and redirects not supported\n\n // Opt-in attributes left off for now\n };\n\n // conditionally required if request method required case normalization\n if (method !== normalizedMethod) {\n attributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = method;\n }\n\n if (enableSyntheticSourceDetection && userAgent) {\n attributes[ATTR_USER_AGENT_SYNTHETIC_TYPE] = getSyntheticType(userAgent);\n }\n return Object.assign(attributes, options.hookAttributes);\n};\n\n/**\n * Returns the type of synthetic source based on the user agent\n * @param {OutgoingHttpHeader} userAgent the user agent string\n */\nconst getSyntheticType = (\n userAgent: OutgoingHttpHeader\n): AttributeValue | undefined => {\n const userAgentString: string = String(userAgent).toLowerCase();\n for (const name of SYNTHETIC_TEST_NAMES) {\n if (userAgentString.includes(name)) {\n return USER_AGENT_SYNTHETIC_TYPE_VALUE_TEST;\n }\n }\n for (const name of SYNTHETIC_BOT_NAMES) {\n if (userAgentString.includes(name)) {\n return USER_AGENT_SYNTHETIC_TYPE_VALUE_BOT;\n }\n }\n return;\n};\n\n/**\n * Returns outgoing request attributes scoped to the response data\n * @param {IncomingMessage} response the response object\n */\nexport const getOutgoingRequestAttributesOnResponse = (\n response: IncomingMessage\n): Attributes => {\n const { statusCode, socket } = response;\n const attributes: Attributes = {};\n\n if (statusCode != null) {\n attributes[ATTR_HTTP_RESPONSE_STATUS_CODE] = statusCode;\n }\n\n if (socket) {\n const { remoteAddress, remotePort } = socket;\n\n // Recommended\n attributes[ATTR_NETWORK_PEER_ADDRESS] = remoteAddress;\n attributes[ATTR_NETWORK_PEER_PORT] = remotePort;\n attributes[ATTR_NETWORK_PROTOCOL_VERSION] = response.httpVersion;\n }\n return attributes;\n};\n\n/**\n * Returns outgoing request Metric attributes scoped to the response data\n * @param {Attributes} spanAttributes the span attributes\n */\nexport const getOutgoingStableRequestMetricAttributesOnResponse = (\n spanAttributes: Attributes\n): Attributes => {\n const metricAttributes: Attributes = {};\n\n if (spanAttributes[ATTR_NETWORK_PROTOCOL_VERSION]) {\n metricAttributes[ATTR_NETWORK_PROTOCOL_VERSION] =\n spanAttributes[ATTR_NETWORK_PROTOCOL_VERSION];\n }\n\n const statusCode = spanAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE];\n if (statusCode) {\n metricAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE] = statusCode;\n const errorType = parseErrorType(SpanKind.CLIENT, statusCode);\n if (errorType !== undefined) {\n metricAttributes[ATTR_ERROR_TYPE] ??= errorType;\n }\n }\n return metricAttributes;\n};\n\nfunction parseHostHeader(\n hostHeader: string,\n proto?: string\n): { host: string; port?: string } {\n const parts = hostHeader.split(':');\n\n // no semicolon implies ipv4 dotted syntax or host name without port\n // x.x.x.x\n // example.com\n if (parts.length === 1) {\n if (proto === 'http') {\n return { host: parts[0], port: '80' };\n }\n\n if (proto === 'https') {\n return { host: parts[0], port: '443' };\n }\n\n return { host: parts[0] };\n }\n\n // single semicolon implies ipv4 dotted syntax or host name with port\n // x.x.x.x:yyyy\n // example.com:yyyy\n if (parts.length === 2) {\n return {\n host: parts[0],\n port: parts[1],\n };\n }\n\n // more than 2 parts implies ipv6 syntax with multiple colons\n // [x:x:x:x:x:x:x:x]\n // [x:x:x:x:x:x:x:x]:yyyy\n if (parts[0].startsWith('[')) {\n if (parts[parts.length - 1].endsWith(']')) {\n if (proto === 'http') {\n return { host: hostHeader, port: '80' };\n }\n\n if (proto === 'https') {\n return { host: hostHeader, port: '443' };\n }\n } else if (parts[parts.length - 2].endsWith(']')) {\n return {\n host: parts.slice(0, -1).join(':'),\n port: parts[parts.length - 1],\n };\n }\n }\n\n // if nothing above matches just return the host header\n return { host: hostHeader };\n}\n\n/**\n * Get server.address and port according to http semconv 1.27\n * https://github.com/open-telemetry/semantic-conventions/blob/bf0a2c1134f206f034408b201dbec37960ed60ec/docs/http/http-spans.md#setting-serveraddress-and-serverport-attributes\n */\nfunction getServerAddress(\n request: IncomingMessage,\n component: 'http' | 'https'\n): { host: string; port?: string } | null {\n const forwardedHeader = request.headers['forwarded'];\n if (forwardedHeader) {\n for (const entry of parseForwardedHeader(forwardedHeader)) {\n if (entry.host) {\n return parseHostHeader(entry.host, entry.proto);\n }\n }\n }\n\n const xForwardedHost = request.headers['x-forwarded-host'];\n if (typeof xForwardedHost === 'string') {\n if (typeof request.headers['x-forwarded-proto'] === 'string') {\n return parseHostHeader(\n xForwardedHost,\n request.headers['x-forwarded-proto']\n );\n }\n\n if (Array.isArray(request.headers['x-forwarded-proto'])) {\n return parseHostHeader(\n xForwardedHost,\n request.headers['x-forwarded-proto'][0]\n );\n }\n\n return parseHostHeader(xForwardedHost);\n } else if (\n Array.isArray(xForwardedHost) &&\n typeof xForwardedHost[0] === 'string' &&\n xForwardedHost[0].length > 0\n ) {\n if (typeof request.headers['x-forwarded-proto'] === 'string') {\n return parseHostHeader(\n xForwardedHost[0],\n request.headers['x-forwarded-proto']\n );\n }\n\n if (Array.isArray(request.headers['x-forwarded-proto'])) {\n return parseHostHeader(\n xForwardedHost[0],\n request.headers['x-forwarded-proto'][0]\n );\n }\n\n return parseHostHeader(xForwardedHost[0]);\n }\n\n const host = request.headers['host'];\n if (typeof host === 'string' && host.length > 0) {\n return parseHostHeader(host, component);\n }\n\n return null;\n}\n\n/**\n * Get server.address and port according to http semconv 1.27\n * https://github.com/open-telemetry/semantic-conventions/blob/bf0a2c1134f206f034408b201dbec37960ed60ec/docs/http/http-spans.md#setting-serveraddress-and-serverport-attributes\n */\nexport function getRemoteClientAddress(\n request: IncomingMessage\n): string | null {\n const forwardedHeader = request.headers['forwarded'];\n if (forwardedHeader) {\n for (const entry of parseForwardedHeader(forwardedHeader)) {\n if (entry.for) {\n return removePortFromAddress(entry.for);\n }\n }\n }\n\n const xForwardedFor = request.headers['x-forwarded-for'];\n if (xForwardedFor) {\n let xForwardedForVal;\n if (typeof xForwardedFor === 'string') {\n xForwardedForVal = xForwardedFor;\n } else if (Array.isArray(xForwardedFor)) {\n xForwardedForVal = xForwardedFor[0];\n }\n\n if (typeof xForwardedForVal === 'string') {\n xForwardedForVal = xForwardedForVal.split(',')[0].trim();\n return removePortFromAddress(xForwardedForVal);\n }\n }\n\n const remote = request.socket.remoteAddress;\n if (remote) {\n return remote;\n }\n\n return null;\n}\n\nfunction removePortFromAddress(input: string): string {\n // This function can be replaced with SocketAddress.parse() once the minimum\n // supported Node.js version allows it.\n try {\n const { hostname: address } = new URL(`http://${input}`);\n\n if (address.startsWith('[') && address.endsWith(']')) {\n return address.slice(1, -1);\n }\n\n return address;\n } catch {\n return input;\n }\n}\n\nfunction getInfoFromIncomingMessage(\n component: 'http' | 'https',\n request: IncomingMessage,\n logger: DiagLogger\n): { pathname?: string; search?: string; toString: () => string } {\n try {\n if (request.headers.host) {\n return new URL(\n request.url ?? '/',\n `${component}://${request.headers.host}`\n );\n } else {\n const unsafeParsedUrl = new URL(\n request.url ?? '/',\n // using localhost as a workaround to still use the URL constructor for parsing\n `${component}://localhost`\n );\n // since we use localhost as a workaround, ensure we hide the rest of the properties to avoid\n // our workaround leaking though.\n return {\n pathname: unsafeParsedUrl.pathname,\n search: unsafeParsedUrl.search,\n toString: function () {\n // we cannot use the result of unsafeParsedUrl.toString as it's potentially wrong.\n return unsafeParsedUrl.pathname + unsafeParsedUrl.search;\n },\n };\n }\n } catch (e) {\n // something is wrong, use undefined - this *should* never happen, logging\n // for troubleshooting in case it does happen.\n logger.verbose('Unable to get URL from request', e);\n return {};\n }\n}\n\n/**\n * Returns incoming request attributes scoped to the request data\n * @param {IncomingMessage} request the request object\n * @param {{ component: string, hookAttributes?: Attributes, enableSyntheticSourceDetection: boolean }} options used to pass data needed to create attributes\n */\nexport const getIncomingRequestAttributes = (\n request: IncomingMessage,\n options: {\n component: 'http' | 'https';\n hookAttributes?: Attributes;\n enableSyntheticSourceDetection: boolean;\n redactedQueryParams?: string[];\n },\n logger: DiagLogger\n): Attributes => {\n const {\n component,\n enableSyntheticSourceDetection,\n hookAttributes,\n redactedQueryParams,\n } = options;\n const { headers, method } = request;\n const { 'user-agent': userAgent } = headers;\n const parsedUrl = getInfoFromIncomingMessage(component, request, logger);\n\n // Stable attributes are used.\n const normalizedMethod = normalizeMethod(method);\n const serverAddress = getServerAddress(request, component);\n const remoteClientAddress = getRemoteClientAddress(request);\n\n const attributes: Attributes = {\n [ATTR_HTTP_REQUEST_METHOD]: normalizedMethod,\n [ATTR_URL_SCHEME]: component,\n [ATTR_SERVER_ADDRESS]: serverAddress?.host,\n [ATTR_NETWORK_PEER_ADDRESS]: request.socket.remoteAddress,\n [ATTR_NETWORK_PEER_PORT]: request.socket.remotePort,\n [ATTR_NETWORK_PROTOCOL_VERSION]: request.httpVersion,\n [ATTR_USER_AGENT_ORIGINAL]: userAgent,\n };\n\n if (parsedUrl.pathname != null) {\n attributes[ATTR_URL_PATH] = parsedUrl.pathname;\n }\n\n if (parsedUrl.search) {\n // Remove leading '?' from URL search (https://developer.mozilla.org/en-US/docs/Web/API/URL/search).\n const paramsToRedact = redactedQueryParams ?? defaultQueryStringsToRedact;\n attributes[ATTR_URL_QUERY] = redactQueryString(\n new URLSearchParams(parsedUrl.search.slice(1)),\n paramsToRedact\n );\n }\n\n if (remoteClientAddress != null) {\n attributes[ATTR_CLIENT_ADDRESS] = remoteClientAddress;\n }\n\n if (serverAddress?.port != null) {\n attributes[ATTR_SERVER_PORT] = Number(serverAddress.port);\n }\n\n // Conditionally required if request method required case normalization.\n if (method !== normalizedMethod) {\n attributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = method;\n }\n\n if (enableSyntheticSourceDetection && userAgent) {\n attributes[ATTR_USER_AGENT_SYNTHETIC_TYPE] = getSyntheticType(userAgent);\n }\n\n return Object.assign(attributes, hookAttributes);\n};\n\n/**\n * Returns incoming request attributes scoped to the response data\n * @param {(ServerResponse & { socket: Socket; })} response the response object\n */\nexport const getIncomingRequestAttributesOnResponse = (\n response: ServerResponse\n): Attributes => {\n const { statusCode } = response;\n\n const attributes: Attributes = {\n [ATTR_HTTP_RESPONSE_STATUS_CODE]: statusCode,\n };\n\n const rpcMetadata = getRPCMetadata(context.active());\n if (rpcMetadata?.type === RPCType.HTTP && rpcMetadata.route !== undefined) {\n attributes[ATTR_HTTP_ROUTE] = rpcMetadata.route;\n }\n\n return attributes;\n};\n\n/**\n * Returns incoming stable request Metric attributes scoped to the request data\n * @param {Attributes} spanAttributes the span attributes\n */\nexport const getIncomingStableRequestMetricAttributesOnResponse = (\n spanAttributes: Attributes\n): Attributes => {\n const metricAttributes: Attributes = {};\n if (spanAttributes[ATTR_HTTP_ROUTE] !== undefined) {\n metricAttributes[ATTR_HTTP_ROUTE] = spanAttributes[ATTR_HTTP_ROUTE];\n }\n\n // required if and only if one was sent, same as span requirement\n const statusCode = spanAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE];\n if (statusCode) {\n metricAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE] = statusCode;\n const errorType = parseErrorType(SpanKind.SERVER, statusCode);\n if (errorType !== undefined) {\n metricAttributes[ATTR_ERROR_TYPE] ??= errorType;\n }\n }\n\n return metricAttributes;\n};\n\nexport function headerCapture(type: 'request' | 'response', headers: string[]) {\n const normalizedHeaders = new Map<string, string>();\n for (let i = 0, len = headers.length; i < len; i++) {\n const capturedHeader = headers[i].toLowerCase();\n normalizedHeaders.set(capturedHeader, capturedHeader);\n }\n\n return (\n getHeader: (key: string) => undefined | string | string[] | number\n ): Attributes => {\n const attributes: Attributes = {};\n for (const capturedHeader of normalizedHeaders.keys()) {\n const value = getHeader(capturedHeader);\n\n if (value === undefined) {\n continue;\n }\n\n const normalizedHeader = normalizedHeaders.get(capturedHeader);\n const key = `http.${type}.header.${normalizedHeader}`;\n\n if (typeof value === 'string') {\n attributes[key] = [value];\n } else if (Array.isArray(value)) {\n attributes[key] = value;\n } else {\n attributes[key] = [value];\n }\n }\n return attributes;\n };\n}\n\nconst KNOWN_METHODS = new Set([\n // methods from https://www.rfc-editor.org/rfc/rfc9110.html#name-methods\n 'GET',\n 'HEAD',\n 'POST',\n 'PUT',\n 'DELETE',\n 'CONNECT',\n 'OPTIONS',\n 'TRACE',\n\n // PATCH from https://www.rfc-editor.org/rfc/rfc5789.html\n 'PATCH',\n\n // QUERY from https://datatracker.ietf.org/doc/draft-ietf-httpbis-safe-method-w-body/\n 'QUERY',\n]);\n\nfunction normalizeMethod(method?: string | null) {\n if (method == null) {\n return 'GET';\n }\n\n const upper = method.toUpperCase();\n if (KNOWN_METHODS.has(upper)) {\n return upper;\n }\n\n return '_OTHER';\n}\n\nfunction parseForwardedHeader(header: string): Record<string, string>[] {\n try {\n return forwardedParse(header);\n } catch {\n return [];\n }\n}\n"],"mappings":";;;;;;;AAuDO,MAAA,iBAAA,UAAyB,iBAAA;AAEhC,MAAM,8BAA8B,MAAM,KAAK,+BAA+B;;;;;AAM9E,MAAa,qBACX,cACA,mBACW;CACX,MAAM,SAAS,IAAI,gBAAgB,YAAY;CAC/C,KAAK,MAAM,SAAS,gBAClB,IAAI,OAAO,IAAI,KAAK,GAClB,OAAO,IAAI,OAAO,YAAY;CAGlC,OAAO,OAAO,SAAS;AACzB;;;;AAKA,MAAa,kBACX,YACA,SACA,mBAAmB,SACnB,sBAAgC,MAAM,KAAK,+BAA+B,MAC/D;CACX,MAAM,eAAe,cAAc,CAAC;CACpC,MAAM,WAAW,aAAa,YAAY;CAC1C,MAAM,QAAQ,aAAa,QAAQ,GAAA,CAAI,SAAS;CAChD,IAAI,OAAO,aAAa,QAAQ;CAMhC,IAAI,OACD,OAAO,aAAa,SAAS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,KAAK,UADA,kBAAkB,IAAI,cACG;GAElD,IAAI,OAAO,UAAU,UACnB,WAAW,OAAO,CAAC,KAAK;QACnB,IAAI,MAAM,QAAQ,KAAK,GAC5B,WAAW,OAAO;QAElB,WAAW,OAAO,CAAC,KAAK;EAE5B;EACA,OAAO;CACT;AACF;AAEA,MAAM,gCAAgB,IAAI,IAAI;CAE5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CAGA;AACF,CAAC;AAED,SAAS,gBAAgB,QAAwB;CAC/C,IAAI,UAAU,MACZ,OAAO;CAGT,MAAM,QAAQ,OAAO,YAAY;CACjC,IAAI,cAAc,IAAI,KAAK,GACzB,OAAO;CAGT,OAAO;AACT;AAEA,SAAS,qBAAqB,QAA0C;CACtE,IAAI;EACF,OAAO,eAAe,MAAM;CAC9B,QAAQ;EACN,OAAO,CAAC;CACV;AACF"}
@@ -0,0 +1,6 @@
1
+ //#region src/version.ts
2
+ const VERSION = "0.300.0-development.1";
3
+ //#endregion
4
+ exports.VERSION = VERSION;
5
+
6
+ //# sourceMappingURL=version.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.cjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.300.0-development.1';\n"],"mappings":";AAMA,MAAa,UAAU"}
@@ -0,0 +1,6 @@
1
+ //#region src/version.ts
2
+ const VERSION = "0.300.0-development.1";
3
+ //#endregion
4
+ export { VERSION };
5
+
6
+ //# sourceMappingURL=version.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.300.0-development.1';\n"],"mappings":";AAMA,MAAa,UAAU"}