@opentelemetry/instrumentation-http 0.52.1 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -6
- package/build/src/http.d.ts +10 -4
- package/build/src/http.js +189 -76
- package/build/src/http.js.map +1 -1
- package/build/src/index.d.ts +3 -3
- package/build/src/index.js +24 -13
- package/build/src/index.js.map +1 -1
- package/build/src/types.d.ts +21 -13
- package/build/src/types.js.map +1 -1
- package/build/src/utils.d.ts +39 -35
- package/build/src/utils.js +287 -79
- package/build/src/utils.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +18 -18
package/build/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAO4B;AAC5B,8EAyB6C;AAQ7C,8CAA8D;AAC9D,2BAA2B;AAC3B,2DAAwD;AAGxD;;GAEG;AACI,MAAM,cAAc,GAAG,CAC5B,UAAuC,EACvC,OAAkD,EAClD,gBAAgB,GAAG,OAAO,EAClB,EAAE;IACV,MAAM,YAAY,GAAG,UAAU,IAAI,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,IAAI,gBAAgB,CAAC;IAC3D,MAAM,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,IAAI,GAAG,CAAC;IACtC,IAAI,IAAI,GACN,YAAY,CAAC,IAAI,IAAI,YAAY,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC;IAE5E,kDAAkD;IAClD,gEAAgE;IAChE,IACG,IAAe,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK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AC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;aACjC;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC/B,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aAC/B;iBAAM;gBACL,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;aACjC;SACF;IACH,CAAC,CAAC;AACJ,CAAC;AA9BD,sCA8BC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n MetricAttributes,\n SpanAttributes,\n SpanStatusCode,\n Span,\n context,\n SpanKind,\n} from '@opentelemetry/api';\nimport {\n NETTRANSPORTVALUES_IP_TCP,\n NETTRANSPORTVALUES_IP_UDP,\n SEMATTRS_HTTP_CLIENT_IP,\n SEMATTRS_HTTP_FLAVOR,\n SEMATTRS_HTTP_HOST,\n SEMATTRS_HTTP_METHOD,\n SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH,\n SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED,\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH,\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,\n SEMATTRS_HTTP_ROUTE,\n SEMATTRS_HTTP_SCHEME,\n SEMATTRS_HTTP_SERVER_NAME,\n SEMATTRS_HTTP_STATUS_CODE,\n SEMATTRS_HTTP_TARGET,\n SEMATTRS_HTTP_URL,\n SEMATTRS_HTTP_USER_AGENT,\n SEMATTRS_NET_HOST_IP,\n SEMATTRS_NET_HOST_NAME,\n SEMATTRS_NET_HOST_PORT,\n SEMATTRS_NET_PEER_IP,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_PEER_PORT,\n SEMATTRS_NET_TRANSPORT,\n} from '@opentelemetry/semantic-conventions';\nimport {\n IncomingHttpHeaders,\n IncomingMessage,\n OutgoingHttpHeaders,\n RequestOptions,\n ServerResponse,\n} from 'http';\nimport { getRPCMetadata, RPCType } from '@opentelemetry/core';\nimport * as url from 'url';\nimport { AttributeNames } from './enums/AttributeNames';\nimport { Err, IgnoreMatcher, ParsedRequestOptions } from './types';\n\n/**\n * Get an absolute url\n */\nexport const getAbsoluteUrl = (\n requestUrl: ParsedRequestOptions | null,\n headers: IncomingHttpHeaders | OutgoingHttpHeaders,\n fallbackProtocol = 'http:'\n): string => {\n const reqUrlObject = requestUrl || {};\n const protocol = reqUrlObject.protocol || fallbackProtocol;\n const port = (reqUrlObject.port || '').toString();\n const path = reqUrlObject.path || '/';\n let host =\n reqUrlObject.host || reqUrlObject.hostname || headers.host || 'localhost';\n\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 (\n (host as string).indexOf(':') === -1 &&\n port &&\n port !== '80' &&\n port !== '443'\n ) {\n host += `:${port}`;\n }\n\n return `${protocol}//${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 * 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 * Check whether the given request is ignored by configuration\n * It will not re-throw exceptions from `list` provided by the client\n * @param constant e.g URL of request\n * @param [list] List of ignore patterns\n * @param [onException] callback for doing something when an exception has\n * occurred\n */\nexport const isIgnored = (\n constant: string,\n list?: IgnoreMatcher[],\n onException?: (error: unknown) => void\n): boolean => {\n if (!list) {\n // No ignored urls - trace everything\n return false;\n }\n // Try/catch outside the loop for failing fast\n try {\n for (const pattern of list) {\n if (satisfiesPattern(constant, pattern)) {\n return true;\n }\n }\n } catch (e) {\n if (onException) {\n onException(e);\n }\n }\n\n return false;\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\n span.setAttribute(AttributeNames.HTTP_ERROR_NAME, error.name);\n span.setAttribute(AttributeNames.HTTP_ERROR_MESSAGE, message);\n span.setStatus({ code: SpanStatusCode.ERROR, message });\n span.recordException(error);\n};\n\n/**\n * Adds attributes for request content-length and content-encoding HTTP headers\n * @param { IncomingMessage } Request object whose headers will be analyzed\n * @param { SpanAttributes } SpanAttributes object to be modified\n */\nexport const setRequestContentLengthAttribute = (\n request: IncomingMessage,\n attributes: SpanAttributes\n): void => {\n const length = getContentLength(request.headers);\n if (length === null) return;\n\n if (isCompressed(request.headers)) {\n attributes[SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH] = length;\n } else {\n attributes[SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED] = length;\n }\n};\n\n/**\n * Adds attributes for response content-length and content-encoding HTTP headers\n * @param { IncomingMessage } Response object whose headers will be analyzed\n * @param { SpanAttributes } SpanAttributes object to be modified\n */\nexport const setResponseContentLengthAttribute = (\n response: IncomingMessage,\n attributes: SpanAttributes\n): void => {\n const length = getContentLength(response.headers);\n if (length === null) return;\n\n if (isCompressed(response.headers)) {\n attributes[SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH] = length;\n } else {\n attributes[SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED] = length;\n }\n};\n\nfunction getContentLength(\n headers: OutgoingHttpHeaders | IncomingHttpHeaders\n): number | null {\n const contentLengthHeader = headers['content-length'];\n if (contentLengthHeader === undefined) return null;\n\n const contentLength = parseInt(contentLengthHeader as string, 10);\n if (isNaN(contentLength)) return null;\n\n return contentLength;\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 * Makes sure options is an url object\n * return an object with default value and parsed options\n * @param options original options for the request\n * @param [extraOptions] additional options for the request\n */\nexport const getRequestInfo = (\n options: url.URL | RequestOptions | string,\n extraOptions?: RequestOptions\n): {\n origin: string;\n pathname: string;\n method: string;\n optionsParsed: RequestOptions;\n} => {\n let pathname = '/';\n let origin = '';\n let optionsParsed: RequestOptions;\n if (typeof options === 'string') {\n optionsParsed = url.parse(options);\n pathname = (optionsParsed as url.UrlWithStringQuery).pathname || '/';\n origin = `${optionsParsed.protocol || 'http:'}//${optionsParsed.host}`;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else if (options instanceof url.URL) {\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 pathname = (options as url.URL).pathname;\n if (!pathname && optionsParsed.path) {\n pathname = url.parse(optionsParsed.path).pathname || '/';\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\n // some packages return method in lowercase..\n // ensure upperCase for consistency\n const method = optionsParsed.method\n ? optionsParsed.method.toUpperCase()\n : 'GET';\n\n return { origin, pathname, method, optionsParsed };\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 if (requestOptions.hostname && requestOptions.port) {\n return { hostname: requestOptions.hostname, port: requestOptions.port };\n }\n const matches = requestOptions.host?.match(/^([^:/ ]+)(:\\d{1,5})?/) || null;\n const hostname =\n requestOptions.hostname || (matches === null ? 'localhost' : matches[1]);\n let port = requestOptions.port;\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?: SpanAttributes }} 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?: SpanAttributes;\n }\n): SpanAttributes => {\n const hostname = options.hostname;\n const port = options.port;\n const requestMethod = requestOptions.method;\n const method = requestMethod ? requestMethod.toUpperCase() : 'GET';\n const headers = requestOptions.headers || {};\n const userAgent = headers['user-agent'];\n const attributes: SpanAttributes = {\n [SEMATTRS_HTTP_URL]: getAbsoluteUrl(\n requestOptions,\n headers,\n `${options.component}:`\n ),\n [SEMATTRS_HTTP_METHOD]: method,\n [SEMATTRS_HTTP_TARGET]: requestOptions.path || '/',\n [SEMATTRS_NET_PEER_NAME]: hostname,\n [SEMATTRS_HTTP_HOST]: headers.host ?? `${hostname}:${port}`,\n };\n\n if (userAgent !== undefined) {\n attributes[SEMATTRS_HTTP_USER_AGENT] = userAgent;\n }\n return Object.assign(attributes, options.hookAttributes);\n};\n\n/**\n * Returns outgoing request Metric attributes scoped to the request data\n * @param {SpanAttributes} spanAttributes the span attributes\n */\nexport const getOutgoingRequestMetricAttributes = (\n spanAttributes: SpanAttributes\n): MetricAttributes => {\n const metricAttributes: MetricAttributes = {};\n metricAttributes[SEMATTRS_HTTP_METHOD] = spanAttributes[SEMATTRS_HTTP_METHOD];\n metricAttributes[SEMATTRS_NET_PEER_NAME] =\n spanAttributes[SEMATTRS_NET_PEER_NAME];\n //TODO: http.url attribute, it should substitute any parameters to avoid high cardinality.\n return metricAttributes;\n};\n\n/**\n * Returns attributes related to the kind of HTTP protocol used\n * @param {string} [kind] Kind of HTTP protocol used: \"1.0\", \"1.1\", \"2\", \"SPDY\" or \"QUIC\".\n */\nexport const setAttributesFromHttpKind = (\n kind: string | undefined,\n attributes: SpanAttributes\n): void => {\n if (kind) {\n attributes[SEMATTRS_HTTP_FLAVOR] = kind;\n if (kind.toUpperCase() !== 'QUIC') {\n attributes[SEMATTRS_NET_TRANSPORT] = NETTRANSPORTVALUES_IP_TCP;\n } else {\n attributes[SEMATTRS_NET_TRANSPORT] = NETTRANSPORTVALUES_IP_UDP;\n }\n }\n};\n\n/**\n * Returns outgoing request attributes scoped to the response data\n * @param {IncomingMessage} response the response object\n * @param {{ hostname: string }} options used to pass data needed to create attributes\n */\nexport const getOutgoingRequestAttributesOnResponse = (\n response: IncomingMessage\n): SpanAttributes => {\n const { statusCode, statusMessage, httpVersion, socket } = response;\n const attributes: SpanAttributes = {};\n if (socket) {\n const { remoteAddress, remotePort } = socket;\n attributes[SEMATTRS_NET_PEER_IP] = remoteAddress;\n attributes[SEMATTRS_NET_PEER_PORT] = remotePort;\n }\n setResponseContentLengthAttribute(response, attributes);\n\n if (statusCode) {\n attributes[SEMATTRS_HTTP_STATUS_CODE] = statusCode;\n attributes[AttributeNames.HTTP_STATUS_TEXT] = (\n statusMessage || ''\n ).toUpperCase();\n }\n\n setAttributesFromHttpKind(httpVersion, attributes);\n return attributes;\n};\n\n/**\n * Returns outgoing request Metric attributes scoped to the response data\n * @param {SpanAttributes} spanAttributes the span attributes\n */\nexport const getOutgoingRequestMetricAttributesOnResponse = (\n spanAttributes: SpanAttributes\n): MetricAttributes => {\n const metricAttributes: MetricAttributes = {};\n metricAttributes[SEMATTRS_NET_PEER_PORT] =\n spanAttributes[SEMATTRS_NET_PEER_PORT];\n metricAttributes[SEMATTRS_HTTP_STATUS_CODE] =\n spanAttributes[SEMATTRS_HTTP_STATUS_CODE];\n metricAttributes[SEMATTRS_HTTP_FLAVOR] = spanAttributes[SEMATTRS_HTTP_FLAVOR];\n return metricAttributes;\n};\n\n/**\n * Returns incoming request attributes scoped to the request data\n * @param {IncomingMessage} request the request object\n * @param {{ component: string, serverName?: string, hookAttributes?: SpanAttributes }} options used to pass data needed to create attributes\n */\nexport const getIncomingRequestAttributes = (\n request: IncomingMessage,\n options: {\n component: string;\n serverName?: string;\n hookAttributes?: SpanAttributes;\n }\n): SpanAttributes => {\n const headers = request.headers;\n const userAgent = headers['user-agent'];\n const ips = headers['x-forwarded-for'];\n const method = request.method || 'GET';\n const httpVersion = request.httpVersion;\n const requestUrl = request.url ? url.parse(request.url) : null;\n const host = requestUrl?.host || headers.host;\n const hostname =\n requestUrl?.hostname ||\n host?.replace(/^(.*)(:[0-9]{1,5})/, '$1') ||\n 'localhost';\n const serverName = options.serverName;\n const attributes: SpanAttributes = {\n [SEMATTRS_HTTP_URL]: getAbsoluteUrl(\n requestUrl,\n headers,\n `${options.component}:`\n ),\n [SEMATTRS_HTTP_HOST]: host,\n [SEMATTRS_NET_HOST_NAME]: hostname,\n [SEMATTRS_HTTP_METHOD]: method,\n [SEMATTRS_HTTP_SCHEME]: options.component,\n };\n\n if (typeof ips === 'string') {\n attributes[SEMATTRS_HTTP_CLIENT_IP] = ips.split(',')[0];\n }\n\n if (typeof serverName === 'string') {\n attributes[SEMATTRS_HTTP_SERVER_NAME] = serverName;\n }\n\n if (requestUrl) {\n attributes[SEMATTRS_HTTP_TARGET] = requestUrl.path || '/';\n }\n\n if (userAgent !== undefined) {\n attributes[SEMATTRS_HTTP_USER_AGENT] = userAgent;\n }\n setRequestContentLengthAttribute(request, attributes);\n setAttributesFromHttpKind(httpVersion, attributes);\n return Object.assign(attributes, options.hookAttributes);\n};\n\n/**\n * Returns incoming request Metric attributes scoped to the request data\n * @param {SpanAttributes} spanAttributes the span attributes\n * @param {{ component: string }} options used to pass data needed to create attributes\n */\nexport const getIncomingRequestMetricAttributes = (\n spanAttributes: SpanAttributes\n): MetricAttributes => {\n const metricAttributes: MetricAttributes = {};\n metricAttributes[SEMATTRS_HTTP_SCHEME] = spanAttributes[SEMATTRS_HTTP_SCHEME];\n metricAttributes[SEMATTRS_HTTP_METHOD] = spanAttributes[SEMATTRS_HTTP_METHOD];\n metricAttributes[SEMATTRS_NET_HOST_NAME] =\n spanAttributes[SEMATTRS_NET_HOST_NAME];\n metricAttributes[SEMATTRS_HTTP_FLAVOR] = spanAttributes[SEMATTRS_HTTP_FLAVOR];\n //TODO: http.target attribute, it should substitute any parameters to avoid high cardinality.\n return metricAttributes;\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 request: IncomingMessage,\n response: ServerResponse\n): SpanAttributes => {\n // take socket from the request,\n // since it may be detached from the response object in keep-alive mode\n const { socket } = request;\n const { statusCode, statusMessage } = response;\n\n const rpcMetadata = getRPCMetadata(context.active());\n const attributes: SpanAttributes = {};\n if (socket) {\n const { localAddress, localPort, remoteAddress, remotePort } = socket;\n attributes[SEMATTRS_NET_HOST_IP] = localAddress;\n attributes[SEMATTRS_NET_HOST_PORT] = localPort;\n attributes[SEMATTRS_NET_PEER_IP] = remoteAddress;\n attributes[SEMATTRS_NET_PEER_PORT] = remotePort;\n }\n attributes[SEMATTRS_HTTP_STATUS_CODE] = statusCode;\n attributes[AttributeNames.HTTP_STATUS_TEXT] = (\n statusMessage || ''\n ).toUpperCase();\n\n if (rpcMetadata?.type === RPCType.HTTP && rpcMetadata.route !== undefined) {\n attributes[SEMATTRS_HTTP_ROUTE] = rpcMetadata.route;\n }\n return attributes;\n};\n\n/**\n * Returns incoming request Metric attributes scoped to the request data\n * @param {SpanAttributes} spanAttributes the span attributes\n */\nexport const getIncomingRequestMetricAttributesOnResponse = (\n spanAttributes: SpanAttributes\n): MetricAttributes => {\n const metricAttributes: MetricAttributes = {};\n metricAttributes[SEMATTRS_HTTP_STATUS_CODE] =\n spanAttributes[SEMATTRS_HTTP_STATUS_CODE];\n metricAttributes[SEMATTRS_NET_HOST_PORT] =\n spanAttributes[SEMATTRS_NET_HOST_PORT];\n if (spanAttributes[SEMATTRS_HTTP_ROUTE] !== undefined) {\n metricAttributes[SEMATTRS_HTTP_ROUTE] = spanAttributes[SEMATTRS_HTTP_ROUTE];\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.replace(/-/g, '_'));\n }\n\n return (\n span: Span,\n getHeader: (key: string) => undefined | string | string[] | number\n ) => {\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 span.setAttribute(key, [value]);\n } else if (Array.isArray(value)) {\n span.setAttribute(key, value);\n } else {\n span.setAttribute(key, [value]);\n }\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAM4B;AAC5B,8EAwC6C;AAQ7C,8CAA8D;AAC9D,2BAA2B;AAC3B,2DAAwD;AAOxD,kDAAmD;AAEnD;;GAEG;AACI,MAAM,cAAc,GAAG,CAC5B,UAAuC,EACvC,OAAkD,EAClD,gBAAgB,GAAG,OAAO,EAClB,EAAE;IACV,MAAM,YAAY,GAAG,UAAU,IAAI,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,IAAI,gBAAgB,CAAC;IAC3D,MAAM,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IAClD,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,IAAI,GAAG,CAAC;IACtC,IAAI,IAAI,GACN,YAAY,CAAC,IAAI,IAAI,YAAY,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC;IAE5E,kDAAkD;IAClD,gEAAgE;IAChE,IACG,IAAe,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI;QACJ,IAAI,KAAK,IAAI;QACb,IAAI,KAAK,KAAK,EACd;QACA,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;KACpB;IAED,OAAO,GAAG,QAAQ,KAAK,IAAI,GAAG,IAAI,EAAE,CAAC;AACvC,CAAC,CAAC;AAxBW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,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n Attributes,\n SpanStatusCode,\n Span,\n context,\n SpanKind,\n} 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_SCHEME,\n ATTR_USER_AGENT_ORIGINAL,\n NETTRANSPORTVALUES_IP_TCP,\n NETTRANSPORTVALUES_IP_UDP,\n SEMATTRS_HTTP_CLIENT_IP,\n SEMATTRS_HTTP_FLAVOR,\n SEMATTRS_HTTP_HOST,\n SEMATTRS_HTTP_METHOD,\n SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH,\n SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED,\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH,\n SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,\n SEMATTRS_HTTP_ROUTE,\n SEMATTRS_HTTP_SCHEME,\n SEMATTRS_HTTP_SERVER_NAME,\n SEMATTRS_HTTP_STATUS_CODE,\n SEMATTRS_HTTP_TARGET,\n SEMATTRS_HTTP_URL,\n SEMATTRS_HTTP_USER_AGENT,\n SEMATTRS_NET_HOST_IP,\n SEMATTRS_NET_HOST_NAME,\n SEMATTRS_NET_HOST_PORT,\n SEMATTRS_NET_PEER_IP,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_PEER_PORT,\n SEMATTRS_NET_TRANSPORT,\n} from '@opentelemetry/semantic-conventions';\nimport {\n IncomingHttpHeaders,\n IncomingMessage,\n OutgoingHttpHeaders,\n RequestOptions,\n ServerResponse,\n} from 'http';\nimport { getRPCMetadata, RPCType } from '@opentelemetry/core';\nimport * as url from 'url';\nimport { AttributeNames } from './enums/AttributeNames';\nimport {\n Err,\n IgnoreMatcher,\n ParsedRequestOptions,\n SemconvStability,\n} from './types';\nimport forwardedParse = require('forwarded-parse');\n\n/**\n * Get an absolute url\n */\nexport const getAbsoluteUrl = (\n requestUrl: ParsedRequestOptions | null,\n headers: IncomingHttpHeaders | OutgoingHttpHeaders,\n fallbackProtocol = 'http:'\n): string => {\n const reqUrlObject = requestUrl || {};\n const protocol = reqUrlObject.protocol || fallbackProtocol;\n const port = (reqUrlObject.port || '').toString();\n const path = reqUrlObject.path || '/';\n let host =\n reqUrlObject.host || reqUrlObject.hostname || headers.host || 'localhost';\n\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 (\n (host as string).indexOf(':') === -1 &&\n port &&\n port !== '80' &&\n port !== '443'\n ) {\n host += `:${port}`;\n }\n\n return `${protocol}//${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 * 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 * @param {SemconvStability} semconvStability determines which semconv version to use\n */\nexport const setSpanWithError = (\n span: Span,\n error: Err,\n semconvStability: SemconvStability\n): void => {\n const message = error.message;\n\n if ((semconvStability & SemconvStability.OLD) === SemconvStability.OLD) {\n span.setAttribute(AttributeNames.HTTP_ERROR_NAME, error.name);\n span.setAttribute(AttributeNames.HTTP_ERROR_MESSAGE, message);\n }\n\n if (\n (semconvStability & SemconvStability.STABLE) ===\n SemconvStability.STABLE\n ) {\n span.setAttribute(ATTR_ERROR_TYPE, error.name);\n }\n\n span.setStatus({ code: SpanStatusCode.ERROR, message });\n span.recordException(error);\n};\n\n/**\n * Adds attributes for request content-length and content-encoding HTTP headers\n * @param { IncomingMessage } Request object whose headers will be analyzed\n * @param { Attributes } Attributes object to be modified\n */\nexport const setRequestContentLengthAttribute = (\n request: IncomingMessage,\n attributes: Attributes\n): void => {\n const length = getContentLength(request.headers);\n if (length === null) return;\n\n if (isCompressed(request.headers)) {\n attributes[SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH] = length;\n } else {\n attributes[SEMATTRS_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED] = length;\n }\n};\n\n/**\n * Adds attributes for response content-length and content-encoding HTTP headers\n * @param { IncomingMessage } Response object whose headers will be analyzed\n * @param { Attributes } Attributes object to be modified\n *\n * @deprecated this is for an older version of semconv. It is retained for compatibility using OTEL_SEMCONV_STABILITY_OPT_IN\n */\nexport const setResponseContentLengthAttribute = (\n response: IncomingMessage,\n attributes: Attributes\n): void => {\n const length = getContentLength(response.headers);\n if (length === null) return;\n\n if (isCompressed(response.headers)) {\n attributes[SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH] = length;\n } else {\n attributes[SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED] = length;\n }\n};\n\nfunction getContentLength(\n headers: OutgoingHttpHeaders | IncomingHttpHeaders\n): number | null {\n const contentLengthHeader = headers['content-length'];\n if (contentLengthHeader === undefined) return null;\n\n const contentLength = parseInt(contentLengthHeader as string, 10);\n if (isNaN(contentLength)) return null;\n\n return contentLength;\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 * Makes sure options is an url object\n * return an object with default value and parsed options\n * @param options original options for the request\n * @param [extraOptions] additional options for the request\n */\nexport const getRequestInfo = (\n options: url.URL | RequestOptions | string,\n extraOptions?: RequestOptions\n): {\n origin: string;\n pathname: string;\n method: string;\n optionsParsed: RequestOptions;\n} => {\n let pathname = '/';\n let origin = '';\n let optionsParsed: RequestOptions;\n if (typeof options === 'string') {\n optionsParsed = url.parse(options);\n pathname = (optionsParsed as url.UrlWithStringQuery).pathname || '/';\n origin = `${optionsParsed.protocol || 'http:'}//${optionsParsed.host}`;\n if (extraOptions !== undefined) {\n Object.assign(optionsParsed, extraOptions);\n }\n } else if (options instanceof url.URL) {\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 pathname = (options as url.URL).pathname;\n if (!pathname && optionsParsed.path) {\n pathname = url.parse(optionsParsed.path).pathname || '/';\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\n // some packages return method in lowercase..\n // ensure upperCase for consistency\n const method = optionsParsed.method\n ? optionsParsed.method.toUpperCase()\n : 'GET';\n\n return { origin, pathname, method, optionsParsed };\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 if (requestOptions.hostname && requestOptions.port) {\n return { hostname: requestOptions.hostname, port: requestOptions.port };\n }\n const matches = requestOptions.host?.match(/^([^:/ ]+)(:\\d{1,5})?/) || null;\n const hostname =\n requestOptions.hostname || (matches === null ? 'localhost' : matches[1]);\n let port = requestOptions.port;\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 * @param {SemconvStability} semconvStability determines which semconv version to use\n */\nexport const getOutgoingRequestAttributes = (\n requestOptions: ParsedRequestOptions,\n options: {\n component: string;\n hostname: string;\n port: string | number;\n hookAttributes?: Attributes;\n },\n semconvStability: SemconvStability\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 || {};\n const userAgent = headers['user-agent'];\n const urlFull = getAbsoluteUrl(\n requestOptions,\n headers,\n `${options.component}:`\n );\n const oldAttributes: Attributes = {\n [SEMATTRS_HTTP_URL]: urlFull,\n [SEMATTRS_HTTP_METHOD]: method,\n [SEMATTRS_HTTP_TARGET]: requestOptions.path || '/',\n [SEMATTRS_NET_PEER_NAME]: hostname,\n [SEMATTRS_HTTP_HOST]: headers.host ?? `${hostname}:${port}`,\n };\n\n const newAttributes: 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 // 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 newAttributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = method;\n }\n\n if (userAgent !== undefined) {\n oldAttributes[SEMATTRS_HTTP_USER_AGENT] = userAgent;\n }\n\n switch (semconvStability) {\n case SemconvStability.STABLE:\n return Object.assign(newAttributes, options.hookAttributes);\n case SemconvStability.OLD:\n return Object.assign(oldAttributes, options.hookAttributes);\n }\n\n return Object.assign(oldAttributes, newAttributes, options.hookAttributes);\n};\n\n/**\n * Returns outgoing request Metric attributes scoped to the request data\n * @param {Attributes} spanAttributes the span attributes\n */\nexport const getOutgoingRequestMetricAttributes = (\n spanAttributes: Attributes\n): Attributes => {\n const metricAttributes: Attributes = {};\n metricAttributes[SEMATTRS_HTTP_METHOD] = spanAttributes[SEMATTRS_HTTP_METHOD];\n metricAttributes[SEMATTRS_NET_PEER_NAME] =\n spanAttributes[SEMATTRS_NET_PEER_NAME];\n //TODO: http.url attribute, it should substitute any parameters to avoid high cardinality.\n return metricAttributes;\n};\n\n/**\n * Returns attributes related to the kind of HTTP protocol used\n * @param {string} [kind] Kind of HTTP protocol used: \"1.0\", \"1.1\", \"2\", \"SPDY\" or \"QUIC\".\n */\nexport const setAttributesFromHttpKind = (\n kind: string | undefined,\n attributes: Attributes\n): void => {\n if (kind) {\n attributes[SEMATTRS_HTTP_FLAVOR] = kind;\n if (kind.toUpperCase() !== 'QUIC') {\n attributes[SEMATTRS_NET_TRANSPORT] = NETTRANSPORTVALUES_IP_TCP;\n } else {\n attributes[SEMATTRS_NET_TRANSPORT] = NETTRANSPORTVALUES_IP_UDP;\n }\n }\n};\n\n/**\n * Returns outgoing request attributes scoped to the response data\n * @param {IncomingMessage} response the response object\n * @param {SemconvStability} semconvStability determines which semconv version to use\n */\nexport const getOutgoingRequestAttributesOnResponse = (\n response: IncomingMessage,\n semconvStability: SemconvStability\n): Attributes => {\n const { statusCode, statusMessage, httpVersion, socket } = response;\n const oldAttributes: Attributes = {};\n const stableAttributes: Attributes = {};\n\n if (statusCode != null) {\n stableAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE] = statusCode;\n }\n\n if (socket) {\n const { remoteAddress, remotePort } = socket;\n oldAttributes[SEMATTRS_NET_PEER_IP] = remoteAddress;\n oldAttributes[SEMATTRS_NET_PEER_PORT] = remotePort;\n\n // Recommended\n stableAttributes[ATTR_NETWORK_PEER_ADDRESS] = remoteAddress;\n stableAttributes[ATTR_NETWORK_PEER_PORT] = remotePort;\n stableAttributes[ATTR_NETWORK_PROTOCOL_VERSION] = response.httpVersion;\n }\n setResponseContentLengthAttribute(response, oldAttributes);\n\n if (statusCode) {\n oldAttributes[SEMATTRS_HTTP_STATUS_CODE] = statusCode;\n oldAttributes[AttributeNames.HTTP_STATUS_TEXT] = (\n statusMessage || ''\n ).toUpperCase();\n }\n\n setAttributesFromHttpKind(httpVersion, oldAttributes);\n\n switch (semconvStability) {\n case SemconvStability.STABLE:\n return stableAttributes;\n case SemconvStability.OLD:\n return oldAttributes;\n }\n\n return Object.assign(oldAttributes, stableAttributes);\n};\n\n/**\n * Returns outgoing request Metric attributes scoped to the response data\n * @param {Attributes} spanAttributes the span attributes\n */\nexport const getOutgoingRequestMetricAttributesOnResponse = (\n spanAttributes: Attributes\n): Attributes => {\n const metricAttributes: Attributes = {};\n metricAttributes[SEMATTRS_NET_PEER_PORT] =\n spanAttributes[SEMATTRS_NET_PEER_PORT];\n metricAttributes[SEMATTRS_HTTP_STATUS_CODE] =\n spanAttributes[SEMATTRS_HTTP_STATUS_CODE];\n metricAttributes[SEMATTRS_HTTP_FLAVOR] = spanAttributes[SEMATTRS_HTTP_FLAVOR];\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 forwardedParse(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 forwardedParse(forwardedHeader)) {\n if (entry.for) {\n return entry.for;\n }\n }\n }\n\n const xForwardedFor = request.headers['x-forwarded-for'];\n if (typeof xForwardedFor === 'string') {\n return xForwardedFor;\n } else if (Array.isArray(xForwardedFor)) {\n return xForwardedFor[0];\n }\n\n const remote = request.socket.remoteAddress;\n if (remote) {\n return remote;\n }\n\n return null;\n}\n\n/**\n * Returns incoming request attributes scoped to the request data\n * @param {IncomingMessage} request the request object\n * @param {{ component: string, serverName?: string, hookAttributes?: Attributes }} options used to pass data needed to create attributes\n * @param {SemconvStability} semconvStability determines which semconv version to use\n */\nexport const getIncomingRequestAttributes = (\n request: IncomingMessage,\n options: {\n component: 'http' | 'https';\n serverName?: string;\n hookAttributes?: Attributes;\n semconvStability: SemconvStability;\n }\n): Attributes => {\n const headers = request.headers;\n const userAgent = headers['user-agent'];\n const ips = headers['x-forwarded-for'];\n const httpVersion = request.httpVersion;\n const requestUrl = request.url ? url.parse(request.url) : null;\n const host = requestUrl?.host || headers.host;\n const hostname =\n requestUrl?.hostname ||\n host?.replace(/^(.*)(:[0-9]{1,5})/, '$1') ||\n 'localhost';\n\n const method = request.method;\n const normalizedMethod = normalizeMethod(method);\n\n const serverAddress = getServerAddress(request, options.component);\n const serverName = options.serverName;\n\n const remoteClientAddress = getRemoteClientAddress(request);\n\n const newAttributes: Attributes = {\n [ATTR_HTTP_REQUEST_METHOD]: normalizedMethod,\n [ATTR_URL_SCHEME]: options.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 (requestUrl?.pathname != null) {\n newAttributes[ATTR_URL_PATH] = requestUrl.pathname;\n }\n\n if (remoteClientAddress != null) {\n newAttributes[ATTR_CLIENT_ADDRESS] = remoteClientAddress;\n }\n\n if (serverAddress?.port != null) {\n newAttributes[ATTR_SERVER_PORT] = Number(serverAddress.port);\n }\n\n // conditionally required if request method required case normalization\n if (method !== normalizedMethod) {\n newAttributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = method;\n }\n\n const oldAttributes: Attributes = {\n [SEMATTRS_HTTP_URL]: getAbsoluteUrl(\n requestUrl,\n headers,\n `${options.component}:`\n ),\n [SEMATTRS_HTTP_HOST]: host,\n [SEMATTRS_NET_HOST_NAME]: hostname,\n [SEMATTRS_HTTP_METHOD]: method,\n [SEMATTRS_HTTP_SCHEME]: options.component,\n };\n\n if (typeof ips === 'string') {\n oldAttributes[SEMATTRS_HTTP_CLIENT_IP] = ips.split(',')[0];\n }\n\n if (typeof serverName === 'string') {\n oldAttributes[SEMATTRS_HTTP_SERVER_NAME] = serverName;\n }\n\n if (requestUrl) {\n oldAttributes[SEMATTRS_HTTP_TARGET] = requestUrl.path || '/';\n }\n\n if (userAgent !== undefined) {\n oldAttributes[SEMATTRS_HTTP_USER_AGENT] = userAgent;\n }\n setRequestContentLengthAttribute(request, oldAttributes);\n setAttributesFromHttpKind(httpVersion, oldAttributes);\n\n switch (options.semconvStability) {\n case SemconvStability.STABLE:\n return Object.assign(newAttributes, options.hookAttributes);\n case SemconvStability.OLD:\n return Object.assign(oldAttributes, options.hookAttributes);\n }\n\n return Object.assign(oldAttributes, newAttributes, options.hookAttributes);\n};\n\n/**\n * Returns incoming request Metric attributes scoped to the request data\n * @param {Attributes} spanAttributes the span attributes\n * @param {{ component: string }} options used to pass data needed to create attributes\n */\nexport const getIncomingRequestMetricAttributes = (\n spanAttributes: Attributes\n): Attributes => {\n const metricAttributes: Attributes = {};\n metricAttributes[SEMATTRS_HTTP_SCHEME] = spanAttributes[SEMATTRS_HTTP_SCHEME];\n metricAttributes[SEMATTRS_HTTP_METHOD] = spanAttributes[SEMATTRS_HTTP_METHOD];\n metricAttributes[SEMATTRS_NET_HOST_NAME] =\n spanAttributes[SEMATTRS_NET_HOST_NAME];\n metricAttributes[SEMATTRS_HTTP_FLAVOR] = spanAttributes[SEMATTRS_HTTP_FLAVOR];\n //TODO: http.target attribute, it should substitute any parameters to avoid high cardinality.\n return metricAttributes;\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 request: IncomingMessage,\n response: ServerResponse,\n semconvStability: SemconvStability\n): Attributes => {\n // take socket from the request,\n // since it may be detached from the response object in keep-alive mode\n const { socket } = request;\n const { statusCode, statusMessage } = response;\n\n const newAttributes: Attributes = {\n [ATTR_HTTP_RESPONSE_STATUS_CODE]: statusCode,\n };\n\n const rpcMetadata = getRPCMetadata(context.active());\n const oldAttributes: Attributes = {};\n if (socket) {\n const { localAddress, localPort, remoteAddress, remotePort } = socket;\n oldAttributes[SEMATTRS_NET_HOST_IP] = localAddress;\n oldAttributes[SEMATTRS_NET_HOST_PORT] = localPort;\n oldAttributes[SEMATTRS_NET_PEER_IP] = remoteAddress;\n oldAttributes[SEMATTRS_NET_PEER_PORT] = remotePort;\n }\n oldAttributes[SEMATTRS_HTTP_STATUS_CODE] = statusCode;\n oldAttributes[AttributeNames.HTTP_STATUS_TEXT] = (\n statusMessage || ''\n ).toUpperCase();\n\n if (rpcMetadata?.type === RPCType.HTTP && rpcMetadata.route !== undefined) {\n oldAttributes[SEMATTRS_HTTP_ROUTE] = rpcMetadata.route;\n newAttributes[ATTR_HTTP_ROUTE] = rpcMetadata.route;\n }\n\n switch (semconvStability) {\n case SemconvStability.STABLE:\n return newAttributes;\n case SemconvStability.OLD:\n return oldAttributes;\n }\n\n return Object.assign(oldAttributes, newAttributes);\n};\n\n/**\n * Returns incoming request Metric attributes scoped to the request data\n * @param {Attributes} spanAttributes the span attributes\n */\nexport const getIncomingRequestMetricAttributesOnResponse = (\n spanAttributes: Attributes\n): Attributes => {\n const metricAttributes: Attributes = {};\n metricAttributes[SEMATTRS_HTTP_STATUS_CODE] =\n spanAttributes[SEMATTRS_HTTP_STATUS_CODE];\n metricAttributes[SEMATTRS_NET_HOST_PORT] =\n spanAttributes[SEMATTRS_NET_HOST_PORT];\n if (spanAttributes[SEMATTRS_HTTP_ROUTE] !== undefined) {\n metricAttributes[SEMATTRS_HTTP_ROUTE] = spanAttributes[SEMATTRS_HTTP_ROUTE];\n }\n return metricAttributes;\n};\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[SEMATTRS_HTTP_ROUTE];\n }\n\n // required if and only if one was sent, same as span requirement\n if (spanAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE]) {\n metricAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE] =\n spanAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE];\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.replace(/-/g, '_'));\n }\n\n return (\n span: Span,\n getHeader: (key: string) => undefined | string | string[] | number\n ) => {\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 span.setAttribute(key, [value]);\n } else if (Array.isArray(value)) {\n span.setAttribute(key, value);\n } else {\n span.setAttribute(key, [value]);\n }\n }\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\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"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.54.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.54.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/instrumentation-http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for `node:http` and `node:https` http client and server modules",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
"prepublishOnly": "npm run compile",
|
|
10
10
|
"compile": "tsc --build",
|
|
11
11
|
"clean": "tsc --build --clean",
|
|
12
|
-
"test": "nyc
|
|
12
|
+
"test:cjs": "nyc mocha test/**/*.test.ts",
|
|
13
|
+
"test:esm": "nyc node --experimental-loader=@opentelemetry/instrumentation/hook.mjs ../../../node_modules/mocha/bin/mocha 'test/**/*.test.mjs'",
|
|
14
|
+
"test": "npm run test:cjs && npm run test:esm",
|
|
13
15
|
"tdd": "npm run test -- --watch-extensions ts --watch",
|
|
14
16
|
"lint": "eslint . --ext .ts",
|
|
15
17
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
16
|
-
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
|
|
17
18
|
"version": "node ../../../scripts/version-update.js",
|
|
18
19
|
"watch": "tsc --build --watch",
|
|
19
20
|
"precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies",
|
|
@@ -48,40 +49,39 @@
|
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@opentelemetry/api": "1.9.0",
|
|
51
|
-
"@opentelemetry/context-async-hooks": "1.
|
|
52
|
-
"@opentelemetry/sdk-metrics": "1.
|
|
53
|
-
"@opentelemetry/sdk-trace-base": "1.
|
|
54
|
-
"@opentelemetry/sdk-trace-node": "1.
|
|
55
|
-
"@types/mocha": "10.0.
|
|
52
|
+
"@opentelemetry/context-async-hooks": "1.27.0",
|
|
53
|
+
"@opentelemetry/sdk-metrics": "1.27.0",
|
|
54
|
+
"@opentelemetry/sdk-trace-base": "1.27.0",
|
|
55
|
+
"@opentelemetry/sdk-trace-node": "1.27.0",
|
|
56
|
+
"@types/mocha": "10.0.8",
|
|
56
57
|
"@types/node": "18.6.5",
|
|
57
58
|
"@types/request-promise-native": "1.0.21",
|
|
58
59
|
"@types/semver": "7.5.8",
|
|
59
60
|
"@types/sinon": "17.0.3",
|
|
60
|
-
"@types/superagent": "8.1.
|
|
61
|
-
"axios": "1.
|
|
62
|
-
"codecov": "3.8.3",
|
|
61
|
+
"@types/superagent": "8.1.9",
|
|
62
|
+
"axios": "1.7.4",
|
|
63
63
|
"cross-var": "1.1.0",
|
|
64
64
|
"lerna": "6.6.2",
|
|
65
|
-
"mocha": "10.
|
|
65
|
+
"mocha": "10.7.3",
|
|
66
66
|
"nock": "13.3.8",
|
|
67
67
|
"nyc": "15.1.0",
|
|
68
68
|
"request": "2.88.2",
|
|
69
69
|
"request-promise-native": "1.0.9",
|
|
70
70
|
"sinon": "15.1.2",
|
|
71
|
-
"superagent": "
|
|
72
|
-
"ts-mocha": "10.0.0",
|
|
71
|
+
"superagent": "10.0.2",
|
|
73
72
|
"typescript": "4.4.4"
|
|
74
73
|
},
|
|
75
74
|
"peerDependencies": {
|
|
76
75
|
"@opentelemetry/api": "^1.3.0"
|
|
77
76
|
},
|
|
78
77
|
"dependencies": {
|
|
79
|
-
"@opentelemetry/core": "1.
|
|
80
|
-
"@opentelemetry/instrumentation": "0.
|
|
81
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
78
|
+
"@opentelemetry/core": "1.27.0",
|
|
79
|
+
"@opentelemetry/instrumentation": "0.54.0",
|
|
80
|
+
"@opentelemetry/semantic-conventions": "1.27.0",
|
|
81
|
+
"forwarded-parse": "2.1.2",
|
|
82
82
|
"semver": "^7.5.2"
|
|
83
83
|
},
|
|
84
84
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-http",
|
|
85
85
|
"sideEffects": false,
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "eb3ca4fb07ee31c62093f5fcec56575573c902ce"
|
|
87
87
|
}
|