@opentelemetry/instrumentation-http 0.53.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAe4B;AAC5B,8CAK6B;AAI7B,iCAAiC;AACjC,2BAA2B;AAS3B,iCAAiC;AACjC,uCAAoC;AACpC,oEAIwC;AACxC,8CAA2E;AAC3E,mCAAsC;AACtC,8EAA0E;AAE1E;;GAEG;AACH,MAAa,mBAAoB,SAAQ,qCAA8C;IAOrF,YAAY,SAAoC,EAAE;QAChD,KAAK,CAAC,qCAAqC,EAAE,iBAAO,EAAE,MAAM,CAAC,CAAC;QAPhE,oCAAoC;QACnB,kBAAa,GAAkB,IAAI,OAAO,EAAQ,CAAC;QAOlE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACpD,CAAC;IAEkB,wBAAwB;QACzC,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAC5D,sBAAsB,EACtB;YACE,WAAW,EAAE,iDAAiD;YAC9D,IAAI,EAAE,IAAI;YACV,SAAS,EAAE,eAAS,CAAC,MAAM;SAC5B,CACF,CAAC;QACF,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAC5D,sBAAsB,EACtB;YACE,WAAW,EAAE,kDAAkD;YAC/D,IAAI,EAAE,IAAI;YACV,SAAS,EAAE,eAAS,CAAC,MAAM;SAC5B,CACF,CAAC;IACJ,CAAC;IAEQ,SAAS,CAAC,SAAoC,EAAE;QACvD,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;IACpD,CAAC;IAED,IAAI;QAIF,OAAO,CA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gBACD,sBAAsB,EAAE,KAAK,CAAC,aAAa,CACzC,UAAU,EACV,MAAA,MAAA,MAAA,MAAM,CAAC,uBAAuB,0CAAE,MAAM,0CAAE,eAAe,mCAAI,EAAE,CAC9D;aACF;SACF,CAAC;IACJ,CAAC;CACF;AA7yBD,kDA6yBC","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 context,\n HrTime,\n INVALID_SPAN_CONTEXT,\n propagation,\n ROOT_CONTEXT,\n Span,\n SpanKind,\n SpanOptions,\n SpanStatus,\n SpanStatusCode,\n trace,\n Histogram,\n MetricAttributes,\n ValueType,\n} from '@opentelemetry/api';\nimport {\n hrTime,\n hrTimeDuration,\n hrTimeToMilliseconds,\n suppressTracing,\n} from '@opentelemetry/core';\nimport type * as http from 'http';\nimport type * as https from 'https';\nimport { Socket } from 'net';\nimport * as semver from 'semver';\nimport * as url from 'url';\nimport {\n Err,\n Func,\n Http,\n HttpInstrumentationConfig,\n HttpRequestArgs,\n Https,\n} from './types';\nimport * as utils from './utils';\nimport { VERSION } from './version';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { RPCMetadata, RPCType, setRPCMetadata } from '@opentelemetry/core';\nimport { errorMonitor } from 'events';\nimport { SEMATTRS_HTTP_ROUTE } from '@opentelemetry/semantic-conventions';\n\n/**\n * Http instrumentation instrumentation for Opentelemetry\n */\nexport class HttpInstrumentation extends InstrumentationBase<HttpInstrumentationConfig> {\n /** keep track on spans not ended */\n private readonly _spanNotEnded: WeakSet<Span> = new WeakSet<Span>();\n private _headerCapture;\n private _httpServerDurationHistogram!: Histogram;\n private _httpClientDurationHistogram!: Histogram;\n\n constructor(config: HttpInstrumentationConfig = {}) {\n super('@opentelemetry/instrumentation-http', VERSION, config);\n this._headerCapture = this._createHeaderCapture();\n }\n\n protected override _updateMetricInstruments() {\n this._httpServerDurationHistogram = this.meter.createHistogram(\n 'http.server.duration',\n {\n description: 'Measures the duration of inbound HTTP requests.',\n unit: 'ms',\n valueType: ValueType.DOUBLE,\n }\n );\n this._httpClientDurationHistogram = this.meter.createHistogram(\n 'http.client.duration',\n {\n description: 'Measures the duration of outbound HTTP requests.',\n unit: 'ms',\n valueType: ValueType.DOUBLE,\n }\n );\n }\n\n override setConfig(config: HttpInstrumentationConfig = {}): void {\n super.setConfig(config);\n this._headerCapture = this._createHeaderCapture();\n }\n\n init(): [\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleDefinition,\n ] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n private _getHttpInstrumentation() {\n return new InstrumentationNodeModuleDefinition(\n 'http',\n ['*'],\n (moduleExports: Http): Http => {\n if (!this.getConfig().disableOutgoingRequestInstrumentation) {\n const patchedRequest = this._wrap(\n moduleExports,\n 'request',\n this._getPatchOutgoingRequestFunction('http')\n ) as unknown as Func<http.ClientRequest>;\n this._wrap(\n moduleExports,\n 'get',\n this._getPatchOutgoingGetFunction(patchedRequest)\n );\n }\n if (!this.getConfig().disableIncomingRequestInstrumentation) {\n this._wrap(\n moduleExports.Server.prototype,\n 'emit',\n this._getPatchIncomingRequestFunction('http')\n );\n }\n return moduleExports;\n },\n (moduleExports: Http) => {\n if (moduleExports === undefined) return;\n\n if (!this.getConfig().disableOutgoingRequestInstrumentation) {\n this._unwrap(moduleExports, 'request');\n this._unwrap(moduleExports, 'get');\n }\n if (!this.getConfig().disableIncomingRequestInstrumentation) {\n this._unwrap(moduleExports.Server.prototype, 'emit');\n }\n }\n );\n }\n\n private _getHttpsInstrumentation() {\n return new InstrumentationNodeModuleDefinition(\n 'https',\n ['*'],\n (moduleExports: Https): Https => {\n if (!this.getConfig().disableOutgoingRequestInstrumentation) {\n const patchedRequest = this._wrap(\n moduleExports,\n 'request',\n this._getPatchHttpsOutgoingRequestFunction('https')\n ) as unknown as Func<http.ClientRequest>;\n this._wrap(\n moduleExports,\n 'get',\n this._getPatchHttpsOutgoingGetFunction(patchedRequest)\n );\n }\n if (!this.getConfig().disableIncomingRequestInstrumentation) {\n this._wrap(\n moduleExports.Server.prototype,\n 'emit',\n this._getPatchIncomingRequestFunction('https')\n );\n }\n return moduleExports;\n },\n (moduleExports: Https) => {\n if (moduleExports === undefined) return;\n\n if (!this.getConfig().disableOutgoingRequestInstrumentation) {\n this._unwrap(moduleExports, 'request');\n this._unwrap(moduleExports, 'get');\n }\n if (!this.getConfig().disableIncomingRequestInstrumentation) {\n this._unwrap(moduleExports.Server.prototype, 'emit');\n }\n }\n );\n }\n\n /**\n * Creates spans for incoming requests, restoring spans' context if applied.\n */\n protected _getPatchIncomingRequestFunction(component: 'http' | 'https') {\n return (\n original: (event: string, ...args: unknown[]) => boolean\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return this._incomingRequestFunction(component, original);\n };\n }\n\n /**\n * Creates spans for outgoing requests, sending spans' context for distributed\n * tracing.\n */\n protected _getPatchOutgoingRequestFunction(component: 'http' | 'https') {\n return (original: Func<http.ClientRequest>): Func<http.ClientRequest> => {\n return this._outgoingRequestFunction(component, original);\n };\n }\n\n protected _getPatchOutgoingGetFunction(\n clientRequest: (\n options: http.RequestOptions | string | url.URL,\n ...args: HttpRequestArgs\n ) => http.ClientRequest\n ) {\n return (_original: Func<http.ClientRequest>): Func<http.ClientRequest> => {\n // Re-implement http.get. This needs to be done (instead of using\n // getPatchOutgoingRequestFunction to patch it) because we need to\n // set the trace context header before the returned http.ClientRequest is\n // ended. The Node.js docs state that the only differences between\n // request and get are that (1) get defaults to the HTTP GET method and\n // (2) the returned request object is ended immediately. The former is\n // already true (at least in supported Node versions up to v10), so we\n // simply follow the latter. Ref:\n // https://nodejs.org/dist/latest/docs/api/http.html#http_http_get_options_callback\n // https://github.com/googleapis/cloud-trace-nodejs/blob/master/src/instrumentations/instrumentation-http.ts#L198\n return function outgoingGetRequest<\n T extends http.RequestOptions | string | url.URL,\n >(options: T, ...args: HttpRequestArgs): http.ClientRequest {\n const req = clientRequest(options, ...args);\n req.end();\n return req;\n };\n };\n }\n\n /** Patches HTTPS outgoing requests */\n private _getPatchHttpsOutgoingRequestFunction(component: 'http' | 'https') {\n return (original: Func<http.ClientRequest>): Func<http.ClientRequest> => {\n const instrumentation = this;\n return function httpsOutgoingRequest(\n // eslint-disable-next-line node/no-unsupported-features/node-builtins\n options: https.RequestOptions | string | URL,\n ...args: HttpRequestArgs\n ): http.ClientRequest {\n // Makes sure options will have default HTTPS parameters\n if (\n component === 'https' &&\n typeof options === 'object' &&\n options?.constructor?.name !== 'URL'\n ) {\n options = Object.assign({}, options);\n instrumentation._setDefaultOptions(options);\n }\n return instrumentation._getPatchOutgoingRequestFunction(component)(\n original\n )(options, ...args);\n };\n };\n }\n\n private _setDefaultOptions(options: https.RequestOptions) {\n options.protocol = options.protocol || 'https:';\n options.port = options.port || 443;\n }\n\n /** Patches HTTPS outgoing get requests */\n private _getPatchHttpsOutgoingGetFunction(\n clientRequest: (\n // eslint-disable-next-line node/no-unsupported-features/node-builtins\n options: http.RequestOptions | string | URL,\n ...args: HttpRequestArgs\n ) => http.ClientRequest\n ) {\n return (original: Func<http.ClientRequest>): Func<http.ClientRequest> => {\n const instrumentation = this;\n return function httpsOutgoingRequest(\n // eslint-disable-next-line node/no-unsupported-features/node-builtins\n options: https.RequestOptions | string | URL,\n ...args: HttpRequestArgs\n ): http.ClientRequest {\n return instrumentation._getPatchOutgoingGetFunction(clientRequest)(\n original\n )(options, ...args);\n };\n };\n }\n\n /**\n * Attach event listeners to a client request to end span and add span attributes.\n *\n * @param request The original request object.\n * @param span representing the current operation\n * @param startTime representing the start time of the request to calculate duration in Metric\n * @param metricAttributes metric attributes\n */\n private _traceClientRequest(\n request: http.ClientRequest,\n span: Span,\n startTime: HrTime,\n metricAttributes: MetricAttributes\n ): http.ClientRequest {\n if (this.getConfig().requestHook) {\n this._callRequestHook(span, request);\n }\n\n /**\n * Determines if the request has errored or the response has ended/errored.\n */\n let responseFinished = false;\n\n /*\n * User 'response' event listeners can be added before our listener,\n * force our listener to be the first, so response emitter is bound\n * before any user listeners are added to it.\n */\n request.prependListener(\n 'response',\n (response: http.IncomingMessage & { aborted?: boolean }) => {\n this._diag.debug('outgoingRequest on response()');\n if (request.listenerCount('response') <= 1) {\n response.resume();\n }\n const responseAttributes =\n utils.getOutgoingRequestAttributesOnResponse(response);\n span.setAttributes(responseAttributes);\n metricAttributes = Object.assign(\n metricAttributes,\n utils.getOutgoingRequestMetricAttributesOnResponse(responseAttributes)\n );\n\n if (this.getConfig().responseHook) {\n this._callResponseHook(span, response);\n }\n\n this._headerCapture.client.captureRequestHeaders(span, header =>\n request.getHeader(header)\n );\n this._headerCapture.client.captureResponseHeaders(\n span,\n header => response.headers[header]\n );\n\n context.bind(context.active(), response);\n\n const endHandler = () => {\n this._diag.debug('outgoingRequest on end()');\n if (responseFinished) {\n return;\n }\n responseFinished = true;\n let status: SpanStatus;\n\n if (response.aborted && !response.complete) {\n status = { code: SpanStatusCode.ERROR };\n } else {\n status = {\n code: utils.parseResponseStatus(\n SpanKind.CLIENT,\n response.statusCode\n ),\n };\n }\n\n span.setStatus(status);\n\n if (this.getConfig().applyCustomAttributesOnSpan) {\n safeExecuteInTheMiddle(\n () =>\n this.getConfig().applyCustomAttributesOnSpan!(\n span,\n request,\n response\n ),\n () => {},\n true\n );\n }\n\n this._closeHttpSpan(\n span,\n SpanKind.CLIENT,\n startTime,\n metricAttributes\n );\n };\n\n response.on('end', endHandler);\n // See https://github.com/open-telemetry/opentelemetry-js/pull/3625#issuecomment-1475673533\n if (semver.lt(process.version, '16.0.0')) {\n response.on('close', endHandler);\n }\n response.on(errorMonitor, (error: Err) => {\n this._diag.debug('outgoingRequest on error()', error);\n if (responseFinished) {\n return;\n }\n responseFinished = true;\n utils.setSpanWithError(span, error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n this._closeHttpSpan(\n span,\n SpanKind.CLIENT,\n startTime,\n metricAttributes\n );\n });\n }\n );\n request.on('close', () => {\n this._diag.debug('outgoingRequest on request close()');\n if (request.aborted || responseFinished) {\n return;\n }\n responseFinished = true;\n this._closeHttpSpan(span, SpanKind.CLIENT, startTime, metricAttributes);\n });\n request.on(errorMonitor, (error: Err) => {\n this._diag.debug('outgoingRequest on request error()', error);\n if (responseFinished) {\n return;\n }\n responseFinished = true;\n utils.setSpanWithError(span, error);\n this._closeHttpSpan(span, SpanKind.CLIENT, startTime, metricAttributes);\n });\n\n this._diag.debug('http.ClientRequest return request');\n return request;\n }\n\n private _incomingRequestFunction(\n component: 'http' | 'https',\n original: (event: string, ...args: unknown[]) => boolean\n ) {\n const instrumentation = this;\n return function incomingRequest(\n this: unknown,\n event: string,\n ...args: unknown[]\n ): boolean {\n // Only traces request events\n if (event !== 'request') {\n return original.apply(this, [event, ...args]);\n }\n\n const request = args[0] as http.IncomingMessage;\n const response = args[1] as http.ServerResponse & { socket: Socket };\n const pathname = request.url\n ? url.parse(request.url).pathname || '/'\n : '/';\n const method = request.method || 'GET';\n\n instrumentation._diag.debug(\n `${component} instrumentation incomingRequest`\n );\n\n if (\n utils.isIgnored(\n pathname,\n instrumentation.getConfig().ignoreIncomingPaths,\n (e: unknown) =>\n instrumentation._diag.error('caught ignoreIncomingPaths error: ', e)\n ) ||\n safeExecuteInTheMiddle(\n () =>\n instrumentation.getConfig().ignoreIncomingRequestHook?.(request),\n (e: unknown) => {\n if (e != null) {\n instrumentation._diag.error(\n 'caught ignoreIncomingRequestHook error: ',\n e\n );\n }\n },\n true\n )\n ) {\n return context.with(suppressTracing(context.active()), () => {\n context.bind(context.active(), request);\n context.bind(context.active(), response);\n return original.apply(this, [event, ...args]);\n });\n }\n\n const headers = request.headers;\n\n const spanAttributes = utils.getIncomingRequestAttributes(request, {\n component: component,\n serverName: instrumentation.getConfig().serverName,\n hookAttributes: instrumentation._callStartSpanHook(\n request,\n instrumentation.getConfig().startIncomingSpanHook\n ),\n });\n\n const spanOptions: SpanOptions = {\n kind: SpanKind.SERVER,\n attributes: spanAttributes,\n };\n\n const startTime = hrTime();\n const metricAttributes =\n utils.getIncomingRequestMetricAttributes(spanAttributes);\n\n const ctx = propagation.extract(ROOT_CONTEXT, headers);\n const span = instrumentation._startHttpSpan(method, spanOptions, ctx);\n const rpcMetadata: RPCMetadata = {\n type: RPCType.HTTP,\n span,\n };\n\n return context.with(\n setRPCMetadata(trace.setSpan(ctx, span), rpcMetadata),\n () => {\n context.bind(context.active(), request);\n context.bind(context.active(), response);\n\n if (instrumentation.getConfig().requestHook) {\n instrumentation._callRequestHook(span, request);\n }\n if (instrumentation.getConfig().responseHook) {\n instrumentation._callResponseHook(span, response);\n }\n\n instrumentation._headerCapture.server.captureRequestHeaders(\n span,\n header => request.headers[header]\n );\n\n // After 'error', no further events other than 'close' should be emitted.\n let hasError = false;\n response.on('close', () => {\n if (hasError) {\n return;\n }\n instrumentation._onServerResponseFinish(\n request,\n response,\n span,\n metricAttributes,\n startTime\n );\n });\n response.on(errorMonitor, (err: Err) => {\n hasError = true;\n instrumentation._onServerResponseError(\n span,\n metricAttributes,\n startTime,\n err\n );\n });\n\n return safeExecuteInTheMiddle(\n () => original.apply(this, [event, ...args]),\n error => {\n if (error) {\n utils.setSpanWithError(span, error);\n instrumentation._closeHttpSpan(\n span,\n SpanKind.SERVER,\n startTime,\n metricAttributes\n );\n throw error;\n }\n }\n );\n }\n );\n };\n }\n\n private _outgoingRequestFunction(\n component: 'http' | 'https',\n original: Func<http.ClientRequest>\n ): Func<http.ClientRequest> {\n const instrumentation = this;\n return function outgoingRequest(\n this: unknown,\n options: url.URL | http.RequestOptions | string,\n ...args: unknown[]\n ): http.ClientRequest {\n if (!utils.isValidOptionsType(options)) {\n return original.apply(this, [options, ...args]);\n }\n const extraOptions =\n typeof args[0] === 'object' &&\n (typeof options === 'string' || options instanceof url.URL)\n ? (args.shift() as http.RequestOptions)\n : undefined;\n const { origin, pathname, method, optionsParsed } = utils.getRequestInfo(\n options,\n extraOptions\n );\n /**\n * Node 8's https module directly call the http one so to avoid creating\n * 2 span for the same request we need to check that the protocol is correct\n * See: https://github.com/nodejs/node/blob/v8.17.0/lib/https.js#L245\n */\n if (\n component === 'http' &&\n semver.lt(process.version, '9.0.0') &&\n optionsParsed.protocol === 'https:'\n ) {\n return original.apply(this, [optionsParsed, ...args]);\n }\n\n if (\n utils.isIgnored(\n origin + pathname,\n instrumentation.getConfig().ignoreOutgoingUrls,\n (e: unknown) =>\n instrumentation._diag.error('caught ignoreOutgoingUrls error: ', e)\n ) ||\n safeExecuteInTheMiddle(\n () =>\n instrumentation\n .getConfig()\n .ignoreOutgoingRequestHook?.(optionsParsed),\n (e: unknown) => {\n if (e != null) {\n instrumentation._diag.error(\n 'caught ignoreOutgoingRequestHook error: ',\n e\n );\n }\n },\n true\n )\n ) {\n return original.apply(this, [optionsParsed, ...args]);\n }\n\n const { hostname, port } = utils.extractHostnameAndPort(optionsParsed);\n\n const attributes = utils.getOutgoingRequestAttributes(optionsParsed, {\n component,\n port,\n hostname,\n hookAttributes: instrumentation._callStartSpanHook(\n optionsParsed,\n instrumentation.getConfig().startOutgoingSpanHook\n ),\n });\n\n const startTime = hrTime();\n const metricAttributes: MetricAttributes =\n utils.getOutgoingRequestMetricAttributes(attributes);\n\n const spanOptions: SpanOptions = {\n kind: SpanKind.CLIENT,\n attributes,\n };\n const span = instrumentation._startHttpSpan(method, spanOptions);\n\n const parentContext = context.active();\n const requestContext = trace.setSpan(parentContext, span);\n\n if (!optionsParsed.headers) {\n optionsParsed.headers = {};\n } else {\n // Make a copy of the headers object to avoid mutating an object the\n // caller might have a reference to.\n optionsParsed.headers = Object.assign({}, optionsParsed.headers);\n }\n propagation.inject(requestContext, optionsParsed.headers);\n\n return context.with(requestContext, () => {\n /*\n * The response callback is registered before ClientRequest is bound,\n * thus it is needed to bind it before the function call.\n */\n const cb = args[args.length - 1];\n if (typeof cb === 'function') {\n args[args.length - 1] = context.bind(parentContext, cb);\n }\n\n const request: http.ClientRequest = safeExecuteInTheMiddle(\n () => original.apply(this, [optionsParsed, ...args]),\n error => {\n if (error) {\n utils.setSpanWithError(span, error);\n instrumentation._closeHttpSpan(\n span,\n SpanKind.CLIENT,\n startTime,\n metricAttributes\n );\n throw error;\n }\n }\n );\n\n instrumentation._diag.debug(\n `${component} instrumentation outgoingRequest`\n );\n context.bind(parentContext, request);\n return instrumentation._traceClientRequest(\n request,\n span,\n startTime,\n metricAttributes\n );\n });\n };\n }\n\n private _onServerResponseFinish(\n request: http.IncomingMessage,\n response: http.ServerResponse,\n span: Span,\n metricAttributes: MetricAttributes,\n startTime: HrTime\n ) {\n const attributes = utils.getIncomingRequestAttributesOnResponse(\n request,\n response\n );\n metricAttributes = Object.assign(\n metricAttributes,\n utils.getIncomingRequestMetricAttributesOnResponse(attributes)\n );\n\n this._headerCapture.server.captureResponseHeaders(span, header =>\n response.getHeader(header)\n );\n\n span.setAttributes(attributes).setStatus({\n code: utils.parseResponseStatus(SpanKind.SERVER, response.statusCode),\n });\n\n const route = attributes[SEMATTRS_HTTP_ROUTE];\n if (route) {\n span.updateName(`${request.method || 'GET'} ${route}`);\n }\n\n if (this.getConfig().applyCustomAttributesOnSpan) {\n safeExecuteInTheMiddle(\n () =>\n this.getConfig().applyCustomAttributesOnSpan!(\n span,\n request,\n response\n ),\n () => {},\n true\n );\n }\n\n this._closeHttpSpan(span, SpanKind.SERVER, startTime, metricAttributes);\n }\n\n private _onServerResponseError(\n span: Span,\n metricAttributes: MetricAttributes,\n startTime: HrTime,\n error: Err\n ) {\n utils.setSpanWithError(span, error);\n this._closeHttpSpan(span, SpanKind.SERVER, startTime, metricAttributes);\n }\n\n private _startHttpSpan(\n name: string,\n options: SpanOptions,\n ctx = context.active()\n ) {\n /*\n * If a parent is required but not present, we use a `NoopSpan` to still\n * propagate context without recording it.\n */\n const requireParent =\n options.kind === SpanKind.CLIENT\n ? this.getConfig().requireParentforOutgoingSpans\n : this.getConfig().requireParentforIncomingSpans;\n\n let span: Span;\n const currentSpan = trace.getSpan(ctx);\n\n if (requireParent === true && currentSpan === undefined) {\n span = trace.wrapSpanContext(INVALID_SPAN_CONTEXT);\n } else if (requireParent === true && currentSpan?.spanContext().isRemote) {\n span = currentSpan;\n } else {\n span = this.tracer.startSpan(name, options, ctx);\n }\n this._spanNotEnded.add(span);\n return span;\n }\n\n private _closeHttpSpan(\n span: Span,\n spanKind: SpanKind,\n startTime: HrTime,\n metricAttributes: MetricAttributes\n ) {\n if (!this._spanNotEnded.has(span)) {\n return;\n }\n\n span.end();\n this._spanNotEnded.delete(span);\n\n // Record metrics\n const duration = hrTimeToMilliseconds(hrTimeDuration(startTime, hrTime()));\n if (spanKind === SpanKind.SERVER) {\n this._httpServerDurationHistogram.record(duration, metricAttributes);\n } else if (spanKind === SpanKind.CLIENT) {\n this._httpClientDurationHistogram.record(duration, metricAttributes);\n }\n }\n\n private _callResponseHook(\n span: Span,\n response: http.IncomingMessage | http.ServerResponse\n ) {\n safeExecuteInTheMiddle(\n () => this.getConfig().responseHook!(span, response),\n () => {},\n true\n );\n }\n\n private _callRequestHook(\n span: Span,\n request: http.ClientRequest | http.IncomingMessage\n ) {\n safeExecuteInTheMiddle(\n () => this.getConfig().requestHook!(span, request),\n () => {},\n true\n );\n }\n\n private _callStartSpanHook(\n request: http.IncomingMessage | http.RequestOptions,\n hookFunc: Function | undefined\n ) {\n if (typeof hookFunc === 'function') {\n return safeExecuteInTheMiddle(\n () => hookFunc(request),\n () => {},\n true\n );\n }\n }\n\n private _createHeaderCapture() {\n const config = this.getConfig();\n\n return {\n client: {\n captureRequestHeaders: utils.headerCapture(\n 'request',\n config.headersToSpanAttributes?.client?.requestHeaders ?? []\n ),\n captureResponseHeaders: utils.headerCapture(\n 'response',\n config.headersToSpanAttributes?.client?.responseHeaders ?? []\n ),\n },\n server: {\n captureRequestHeaders: utils.headerCapture(\n 'request',\n config.headersToSpanAttributes?.server?.requestHeaders ?? []\n ),\n captureResponseHeaders: utils.headerCapture(\n 'response',\n config.headersToSpanAttributes?.server?.responseHeaders ?? []\n ),\n },\n };\n }\n}\n"]}
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAe4B;AAC5B,8CAK6B;AAI7B,iCAAiC;AACjC,2BAA2B;AAU3B,uCAAoC;AACpC,oEAIwC;AACxC,8CAK6B;AAC7B,mCAAsC;AACtC,8EAU6C;AAC7C,mCAgBiB;AAEjB;;GAEG;AACH,MAAa,mBAAoB,SAAQ,qCAA8C;IAWrF,YAAY,SAAoC,EAAE;QAChD,KAAK,CAAC,qCAAqC,EAAE,iBAAO,EAAE,MAAM,CAAC,CAAC;QAXhE,oCAAoC;QACnB,kBAAa,GAAkB,IAAI,OAAO,EAAQ,CAAC;QAO5D,sBAAiB,eAAwB;QAI/C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAElD,KAAK,MAAM,KAAK,IAAI,IAAA,aAAM,GAAE,CAAC,6BAA6B,EAAE;YAC1D,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,UAAU,EAAE;gBACtC,mGAAmG;gBACnG,IAAI,CAAC,iBAAiB,oBAA6B,CAAC;gBACpD,MAAM;aACP;iBAAM,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE;gBACzC,IAAI,CAAC,iBAAiB,iBAA0B,CAAC;aAClD;SACF;IACH,CAAC;IAEkB,wBAAwB;QACzC,IAAI,CAAC,+BAA+B,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAC/D,s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,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,WAAY,CAAC,IAAI,EAAE,OAAO,CAAC,EAClD,GAAG,EAAE,GAAE,CAAC,EACR,IAAI,CACL,CAAC;IACJ,CAAC;IAEO,kBAAkB,CACxB,OAAmD,EACnD,QAA8B;QAE9B,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YAClC,OAAO,IAAA,wCAAsB,EAC3B,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EACvB,GAAG,EAAE,GAAE,CAAC,EACR,IAAI,CACL,CAAC;SACH;IACH,CAAC;IAEO,oBAAoB;;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAEhC,OAAO;YACL,MAAM,EAAE;gBACN,qBAAqB,EAAE,IAAA,qBAAa,EAClC,SAAS,EACT,MAAA,MAAA,MAAA,MAAM,CAAC,uBAAuB,0CAAE,MAAM,0CAAE,cAAc,mCAAI,EAAE,CAC7D;gBACD,sBAAsB,EAAE,IAAA,qBAAa,EACnC,UAAU,EACV,MAAA,MAAA,MAAA,MAAM,CAAC,uBAAuB,0CAAE,MAAM,0CAAE,eAAe,mCAAI,EAAE,CAC9D;aACF;YACD,MAAM,EAAE;gBACN,qBAAqB,EAAE,IAAA,qBAAa,EAClC,SAAS,EACT,MAAA,MAAA,MAAA,MAAM,CAAC,uBAAuB,0CAAE,MAAM,0CAAE,cAAc,mCAAI,EAAE,CAC7D;gBACD,sBAAsB,EAAE,IAAA,qBAAa,EACnC,UAAU,EACV,MAAA,MAAA,MAAA,MAAM,CAAC,uBAAuB,0CAAE,MAAM,0CAAE,eAAe,mCAAI,EAAE,CAC9D;aACF;SACF,CAAC;IACJ,CAAC;CACF;AA/9BD,kDA+9BC","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 context,\n HrTime,\n INVALID_SPAN_CONTEXT,\n propagation,\n ROOT_CONTEXT,\n Span,\n SpanKind,\n SpanOptions,\n SpanStatus,\n SpanStatusCode,\n trace,\n Histogram,\n Attributes,\n ValueType,\n} from '@opentelemetry/api';\nimport {\n hrTime,\n hrTimeDuration,\n hrTimeToMilliseconds,\n suppressTracing,\n} from '@opentelemetry/core';\nimport type * as http from 'http';\nimport type * as https from 'https';\nimport { Socket } from 'net';\nimport * as semver from 'semver';\nimport * as url from 'url';\nimport {\n Err,\n Func,\n Http,\n HttpInstrumentationConfig,\n HttpRequestArgs,\n Https,\n SemconvStability,\n} from './types';\nimport { VERSION } from './version';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport {\n RPCMetadata,\n RPCType,\n setRPCMetadata,\n getEnv,\n} from '@opentelemetry/core';\nimport { errorMonitor } from 'events';\nimport {\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_NETWORK_PROTOCOL_VERSION,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n ATTR_URL_SCHEME,\n METRIC_HTTP_CLIENT_REQUEST_DURATION,\n METRIC_HTTP_SERVER_REQUEST_DURATION,\n SEMATTRS_HTTP_ROUTE,\n} from '@opentelemetry/semantic-conventions';\nimport {\n extractHostnameAndPort,\n getIncomingRequestAttributes,\n getIncomingRequestAttributesOnResponse,\n getIncomingRequestMetricAttributes,\n getIncomingRequestMetricAttributesOnResponse,\n getIncomingStableRequestMetricAttributesOnResponse,\n getOutgoingRequestAttributes,\n getOutgoingRequestAttributesOnResponse,\n getOutgoingRequestMetricAttributes,\n getOutgoingRequestMetricAttributesOnResponse,\n getRequestInfo,\n headerCapture,\n isValidOptionsType,\n parseResponseStatus,\n setSpanWithError,\n} from './utils';\n\n/**\n * `node:http` and `node:https` instrumentation for OpenTelemetry\n */\nexport class HttpInstrumentation extends InstrumentationBase<HttpInstrumentationConfig> {\n /** keep track on spans not ended */\n private readonly _spanNotEnded: WeakSet<Span> = new WeakSet<Span>();\n private _headerCapture;\n private _oldHttpServerDurationHistogram!: Histogram;\n private _stableHttpServerDurationHistogram!: Histogram;\n private _oldHttpClientDurationHistogram!: Histogram;\n private _stableHttpClientDurationHistogram!: Histogram;\n\n private _semconvStability = SemconvStability.OLD;\n\n constructor(config: HttpInstrumentationConfig = {}) {\n super('@opentelemetry/instrumentation-http', VERSION, config);\n this._headerCapture = this._createHeaderCapture();\n\n for (const entry in getEnv().OTEL_SEMCONV_STABILITY_OPT_IN) {\n if (entry.toLowerCase() === 'http/dup') {\n // http/dup takes highest precedence. If it is found, there is no need to read the rest of the list\n this._semconvStability = SemconvStability.DUPLICATE;\n break;\n } else if (entry.toLowerCase() === 'http') {\n this._semconvStability = SemconvStability.STABLE;\n }\n }\n }\n\n protected override _updateMetricInstruments() {\n this._oldHttpServerDurationHistogram = this.meter.createHistogram(\n 'http.server.duration',\n {\n description: 'Measures the duration of inbound HTTP requests.',\n unit: 'ms',\n valueType: ValueType.DOUBLE,\n }\n );\n this._oldHttpClientDurationHistogram = this.meter.createHistogram(\n 'http.client.duration',\n {\n description: 'Measures the duration of outbound HTTP requests.',\n unit: 'ms',\n valueType: ValueType.DOUBLE,\n }\n );\n this._stableHttpServerDurationHistogram = this.meter.createHistogram(\n METRIC_HTTP_SERVER_REQUEST_DURATION,\n {\n description: 'Duration of HTTP server requests.',\n unit: 's',\n valueType: ValueType.DOUBLE,\n advice: {\n explicitBucketBoundaries: [\n 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5,\n 7.5, 10,\n ],\n },\n }\n );\n this._stableHttpClientDurationHistogram = this.meter.createHistogram(\n METRIC_HTTP_CLIENT_REQUEST_DURATION,\n {\n description: 'Duration of HTTP client requests.',\n unit: 's',\n valueType: ValueType.DOUBLE,\n advice: {\n explicitBucketBoundaries: [\n 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5,\n 7.5, 10,\n ],\n },\n }\n );\n }\n\n private _recordServerDuration(\n durationMs: number,\n oldAttributes: Attributes,\n stableAttributes: Attributes\n ) {\n if (\n (this._semconvStability & SemconvStability.OLD) ===\n SemconvStability.OLD\n ) {\n // old histogram is counted in MS\n this._oldHttpServerDurationHistogram.record(durationMs, oldAttributes);\n }\n\n if (\n (this._semconvStability & SemconvStability.STABLE) ===\n SemconvStability.STABLE\n ) {\n // stable histogram is counted in S\n this._stableHttpServerDurationHistogram.record(\n durationMs / 1000,\n stableAttributes\n );\n }\n }\n\n private _recordClientDuration(\n durationMs: number,\n oldAttributes: Attributes,\n stableAttributes: Attributes\n ) {\n if (\n (this._semconvStability & SemconvStability.OLD) ===\n SemconvStability.OLD\n ) {\n // old histogram is counted in MS\n this._oldHttpClientDurationHistogram.record(durationMs, oldAttributes);\n }\n\n if (\n (this._semconvStability & SemconvStability.STABLE) ===\n SemconvStability.STABLE\n ) {\n // stable histogram is counted in S\n this._stableHttpClientDurationHistogram.record(\n durationMs / 1000,\n stableAttributes\n );\n }\n }\n\n override setConfig(config: HttpInstrumentationConfig = {}): void {\n super.setConfig(config);\n this._headerCapture = this._createHeaderCapture();\n }\n\n init(): [\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleDefinition,\n ] {\n return [this._getHttpsInstrumentation(), this._getHttpInstrumentation()];\n }\n\n private _getHttpInstrumentation() {\n return new InstrumentationNodeModuleDefinition(\n 'http',\n ['*'],\n (moduleExports: Http): Http => {\n const isESM = (moduleExports as any)[Symbol.toStringTag] === 'Module';\n if (!this.getConfig().disableOutgoingRequestInstrumentation) {\n const patchedRequest = this._wrap(\n moduleExports,\n 'request',\n this._getPatchOutgoingRequestFunction('http')\n ) as unknown as Func<http.ClientRequest>;\n const patchedGet = this._wrap(\n moduleExports,\n 'get',\n this._getPatchOutgoingGetFunction(patchedRequest)\n );\n if (isESM) {\n // To handle `import http from 'http'`, which returns the default\n // export, we need to set `module.default.*`.\n (moduleExports as any).default.request = patchedRequest;\n (moduleExports as any).default.get = patchedGet;\n }\n }\n if (!this.getConfig().disableIncomingRequestInstrumentation) {\n this._wrap(\n moduleExports.Server.prototype,\n 'emit',\n this._getPatchIncomingRequestFunction('http')\n );\n }\n return moduleExports;\n },\n (moduleExports: Http) => {\n if (moduleExports === undefined) return;\n\n if (!this.getConfig().disableOutgoingRequestInstrumentation) {\n this._unwrap(moduleExports, 'request');\n this._unwrap(moduleExports, 'get');\n }\n if (!this.getConfig().disableIncomingRequestInstrumentation) {\n this._unwrap(moduleExports.Server.prototype, 'emit');\n }\n }\n );\n }\n\n private _getHttpsInstrumentation() {\n return new InstrumentationNodeModuleDefinition(\n 'https',\n ['*'],\n (moduleExports: Https): Https => {\n const isESM = (moduleExports as any)[Symbol.toStringTag] === 'Module';\n if (!this.getConfig().disableOutgoingRequestInstrumentation) {\n const patchedRequest = this._wrap(\n moduleExports,\n 'request',\n this._getPatchHttpsOutgoingRequestFunction('https')\n ) as unknown as Func<http.ClientRequest>;\n const patchedGet = this._wrap(\n moduleExports,\n 'get',\n this._getPatchHttpsOutgoingGetFunction(patchedRequest)\n );\n if (isESM) {\n // To handle `import https from 'https'`, which returns the default\n // export, we need to set `module.default.*`.\n (moduleExports as any).default.request = patchedRequest;\n (moduleExports as any).default.get = patchedGet;\n }\n }\n if (!this.getConfig().disableIncomingRequestInstrumentation) {\n this._wrap(\n moduleExports.Server.prototype,\n 'emit',\n this._getPatchIncomingRequestFunction('https')\n );\n }\n return moduleExports;\n },\n (moduleExports: Https) => {\n if (moduleExports === undefined) return;\n\n if (!this.getConfig().disableOutgoingRequestInstrumentation) {\n this._unwrap(moduleExports, 'request');\n this._unwrap(moduleExports, 'get');\n }\n if (!this.getConfig().disableIncomingRequestInstrumentation) {\n this._unwrap(moduleExports.Server.prototype, 'emit');\n }\n }\n );\n }\n\n /**\n * Creates spans for incoming requests, restoring spans' context if applied.\n */\n protected _getPatchIncomingRequestFunction(component: 'http' | 'https') {\n return (\n original: (event: string, ...args: unknown[]) => boolean\n ): ((this: unknown, event: string, ...args: unknown[]) => boolean) => {\n return this._incomingRequestFunction(component, original);\n };\n }\n\n /**\n * Creates spans for outgoing requests, sending spans' context for distributed\n * tracing.\n */\n protected _getPatchOutgoingRequestFunction(component: 'http' | 'https') {\n return (original: Func<http.ClientRequest>): Func<http.ClientRequest> => {\n return this._outgoingRequestFunction(component, original);\n };\n }\n\n protected _getPatchOutgoingGetFunction(\n clientRequest: (\n options: http.RequestOptions | string | url.URL,\n ...args: HttpRequestArgs\n ) => http.ClientRequest\n ) {\n return (_original: Func<http.ClientRequest>): Func<http.ClientRequest> => {\n // Re-implement http.get. This needs to be done (instead of using\n // getPatchOutgoingRequestFunction to patch it) because we need to\n // set the trace context header before the returned http.ClientRequest is\n // ended. The Node.js docs state that the only differences between\n // request and get are that (1) get defaults to the HTTP GET method and\n // (2) the returned request object is ended immediately. The former is\n // already true (at least in supported Node versions up to v10), so we\n // simply follow the latter. Ref:\n // https://nodejs.org/dist/latest/docs/api/http.html#http_http_get_options_callback\n // https://github.com/googleapis/cloud-trace-nodejs/blob/master/src/instrumentations/instrumentation-http.ts#L198\n return function outgoingGetRequest<\n T extends http.RequestOptions | string | url.URL,\n >(options: T, ...args: HttpRequestArgs): http.ClientRequest {\n const req = clientRequest(options, ...args);\n req.end();\n return req;\n };\n };\n }\n\n /** Patches HTTPS outgoing requests */\n private _getPatchHttpsOutgoingRequestFunction(component: 'http' | 'https') {\n return (original: Func<http.ClientRequest>): Func<http.ClientRequest> => {\n const instrumentation = this;\n return function httpsOutgoingRequest(\n // eslint-disable-next-line node/no-unsupported-features/node-builtins\n options: https.RequestOptions | string | URL,\n ...args: HttpRequestArgs\n ): http.ClientRequest {\n // Makes sure options will have default HTTPS parameters\n if (\n component === 'https' &&\n typeof options === 'object' &&\n options?.constructor?.name !== 'URL'\n ) {\n options = Object.assign({}, options);\n instrumentation._setDefaultOptions(options);\n }\n return instrumentation._getPatchOutgoingRequestFunction(component)(\n original\n )(options, ...args);\n };\n };\n }\n\n private _setDefaultOptions(options: https.RequestOptions) {\n options.protocol = options.protocol || 'https:';\n options.port = options.port || 443;\n }\n\n /** Patches HTTPS outgoing get requests */\n private _getPatchHttpsOutgoingGetFunction(\n clientRequest: (\n // eslint-disable-next-line node/no-unsupported-features/node-builtins\n options: http.RequestOptions | string | URL,\n ...args: HttpRequestArgs\n ) => http.ClientRequest\n ) {\n return (original: Func<http.ClientRequest>): Func<http.ClientRequest> => {\n const instrumentation = this;\n return function httpsOutgoingRequest(\n // eslint-disable-next-line node/no-unsupported-features/node-builtins\n options: https.RequestOptions | string | URL,\n ...args: HttpRequestArgs\n ): http.ClientRequest {\n return instrumentation._getPatchOutgoingGetFunction(clientRequest)(\n original\n )(options, ...args);\n };\n };\n }\n\n /**\n * Attach event listeners to a client request to end span and add span attributes.\n *\n * @param request The original request object.\n * @param span representing the current operation\n * @param startTime representing the start time of the request to calculate duration in Metric\n * @param oldMetricAttributes metric attributes for old semantic conventions\n * @param stableMetricAttributes metric attributes for new semantic conventions\n */\n private _traceClientRequest(\n request: http.ClientRequest,\n span: Span,\n startTime: HrTime,\n oldMetricAttributes: Attributes,\n stableMetricAttributes: Attributes\n ): http.ClientRequest {\n if (this.getConfig().requestHook) {\n this._callRequestHook(span, request);\n }\n\n /**\n * Determines if the request has errored or the response has ended/errored.\n */\n let responseFinished = false;\n\n /*\n * User 'response' event listeners can be added before our listener,\n * force our listener to be the first, so response emitter is bound\n * before any user listeners are added to it.\n */\n request.prependListener(\n 'response',\n (response: http.IncomingMessage & { aborted?: boolean }) => {\n this._diag.debug('outgoingRequest on response()');\n if (request.listenerCount('response') <= 1) {\n response.resume();\n }\n const responseAttributes = getOutgoingRequestAttributesOnResponse(\n response,\n this._semconvStability\n );\n span.setAttributes(responseAttributes);\n oldMetricAttributes = Object.assign(\n oldMetricAttributes,\n getOutgoingRequestMetricAttributesOnResponse(responseAttributes)\n );\n\n if (this.getConfig().responseHook) {\n this._callResponseHook(span, response);\n }\n\n this._headerCapture.client.captureRequestHeaders(span, header =>\n request.getHeader(header)\n );\n this._headerCapture.client.captureResponseHeaders(\n span,\n header => response.headers[header]\n );\n\n context.bind(context.active(), response);\n\n const endHandler = () => {\n this._diag.debug('outgoingRequest on end()');\n if (responseFinished) {\n return;\n }\n responseFinished = true;\n let status: SpanStatus;\n\n if (response.aborted && !response.complete) {\n status = { code: SpanStatusCode.ERROR };\n } else {\n // behaves same for new and old semconv\n status = {\n code: parseResponseStatus(SpanKind.CLIENT, response.statusCode),\n };\n }\n\n span.setStatus(status);\n\n if (this.getConfig().applyCustomAttributesOnSpan) {\n safeExecuteInTheMiddle(\n () =>\n this.getConfig().applyCustomAttributesOnSpan!(\n span,\n request,\n response\n ),\n () => {},\n true\n );\n }\n\n this._closeHttpSpan(\n span,\n SpanKind.CLIENT,\n startTime,\n oldMetricAttributes,\n stableMetricAttributes\n );\n };\n\n response.on('end', endHandler);\n // See https://github.com/open-telemetry/opentelemetry-js/pull/3625#issuecomment-1475673533\n if (semver.lt(process.version, '16.0.0')) {\n response.on('close', endHandler);\n }\n response.on(errorMonitor, (error: Err) => {\n this._diag.debug('outgoingRequest on error()', error);\n if (responseFinished) {\n return;\n }\n responseFinished = true;\n setSpanWithError(span, error, this._semconvStability);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n this._closeHttpSpan(\n span,\n SpanKind.CLIENT,\n startTime,\n oldMetricAttributes,\n stableMetricAttributes\n );\n });\n }\n );\n request.on('close', () => {\n this._diag.debug('outgoingRequest on request close()');\n if (request.aborted || responseFinished) {\n return;\n }\n responseFinished = true;\n this._closeHttpSpan(\n span,\n SpanKind.CLIENT,\n startTime,\n oldMetricAttributes,\n stableMetricAttributes\n );\n });\n request.on(errorMonitor, (error: Err) => {\n this._diag.debug('outgoingRequest on request error()', error);\n if (responseFinished) {\n return;\n }\n responseFinished = true;\n setSpanWithError(span, error, this._semconvStability);\n this._closeHttpSpan(\n span,\n SpanKind.CLIENT,\n startTime,\n oldMetricAttributes,\n stableMetricAttributes\n );\n });\n\n this._diag.debug('http.ClientRequest return request');\n return request;\n }\n\n private _incomingRequestFunction(\n component: 'http' | 'https',\n original: (event: string, ...args: unknown[]) => boolean\n ) {\n const instrumentation = this;\n return function incomingRequest(\n this: unknown,\n event: string,\n ...args: unknown[]\n ): boolean {\n // Only traces request events\n if (event !== 'request') {\n return original.apply(this, [event, ...args]);\n }\n\n const request = args[0] as http.IncomingMessage;\n const response = args[1] as http.ServerResponse & { socket: Socket };\n const method = request.method || 'GET';\n\n instrumentation._diag.debug(\n `${component} instrumentation incomingRequest`\n );\n\n if (\n safeExecuteInTheMiddle(\n () =>\n instrumentation.getConfig().ignoreIncomingRequestHook?.(request),\n (e: unknown) => {\n if (e != null) {\n instrumentation._diag.error(\n 'caught ignoreIncomingRequestHook error: ',\n e\n );\n }\n },\n true\n )\n ) {\n return context.with(suppressTracing(context.active()), () => {\n context.bind(context.active(), request);\n context.bind(context.active(), response);\n return original.apply(this, [event, ...args]);\n });\n }\n\n const headers = request.headers;\n\n const spanAttributes = getIncomingRequestAttributes(request, {\n component: component,\n serverName: instrumentation.getConfig().serverName,\n hookAttributes: instrumentation._callStartSpanHook(\n request,\n instrumentation.getConfig().startIncomingSpanHook\n ),\n semconvStability: instrumentation._semconvStability,\n });\n\n const spanOptions: SpanOptions = {\n kind: SpanKind.SERVER,\n attributes: spanAttributes,\n };\n\n const startTime = hrTime();\n const oldMetricAttributes =\n getIncomingRequestMetricAttributes(spanAttributes);\n\n // request method and url.scheme are both required span attributes\n const stableMetricAttributes: Attributes = {\n [ATTR_HTTP_REQUEST_METHOD]: spanAttributes[ATTR_HTTP_REQUEST_METHOD],\n [ATTR_URL_SCHEME]: spanAttributes[ATTR_URL_SCHEME],\n };\n\n // recommended if and only if one was sent, same as span recommendation\n if (spanAttributes[ATTR_NETWORK_PROTOCOL_VERSION]) {\n stableMetricAttributes[ATTR_NETWORK_PROTOCOL_VERSION] =\n spanAttributes[ATTR_NETWORK_PROTOCOL_VERSION];\n }\n\n const ctx = propagation.extract(ROOT_CONTEXT, headers);\n const span = instrumentation._startHttpSpan(method, spanOptions, ctx);\n const rpcMetadata: RPCMetadata = {\n type: RPCType.HTTP,\n span,\n };\n\n return context.with(\n setRPCMetadata(trace.setSpan(ctx, span), rpcMetadata),\n () => {\n context.bind(context.active(), request);\n context.bind(context.active(), response);\n\n if (instrumentation.getConfig().requestHook) {\n instrumentation._callRequestHook(span, request);\n }\n if (instrumentation.getConfig().responseHook) {\n instrumentation._callResponseHook(span, response);\n }\n\n instrumentation._headerCapture.server.captureRequestHeaders(\n span,\n header => request.headers[header]\n );\n\n // After 'error', no further events other than 'close' should be emitted.\n let hasError = false;\n response.on('close', () => {\n if (hasError) {\n return;\n }\n instrumentation._onServerResponseFinish(\n request,\n response,\n span,\n oldMetricAttributes,\n stableMetricAttributes,\n startTime\n );\n });\n response.on(errorMonitor, (err: Err) => {\n hasError = true;\n instrumentation._onServerResponseError(\n span,\n oldMetricAttributes,\n stableMetricAttributes,\n startTime,\n err\n );\n });\n\n return safeExecuteInTheMiddle(\n () => original.apply(this, [event, ...args]),\n error => {\n if (error) {\n setSpanWithError(\n span,\n error,\n instrumentation._semconvStability\n );\n instrumentation._closeHttpSpan(\n span,\n SpanKind.SERVER,\n startTime,\n oldMetricAttributes,\n stableMetricAttributes\n );\n throw error;\n }\n }\n );\n }\n );\n };\n }\n\n private _outgoingRequestFunction(\n component: 'http' | 'https',\n original: Func<http.ClientRequest>\n ): Func<http.ClientRequest> {\n const instrumentation = this;\n return function outgoingRequest(\n this: unknown,\n options: url.URL | http.RequestOptions | string,\n ...args: unknown[]\n ): http.ClientRequest {\n if (!isValidOptionsType(options)) {\n return original.apply(this, [options, ...args]);\n }\n const extraOptions =\n typeof args[0] === 'object' &&\n (typeof options === 'string' || options instanceof url.URL)\n ? (args.shift() as http.RequestOptions)\n : undefined;\n const { method, optionsParsed } = getRequestInfo(options, extraOptions);\n /**\n * Node 8's https module directly call the http one so to avoid creating\n * 2 span for the same request we need to check that the protocol is correct\n * See: https://github.com/nodejs/node/blob/v8.17.0/lib/https.js#L245\n */\n if (\n component === 'http' &&\n semver.lt(process.version, '9.0.0') &&\n optionsParsed.protocol === 'https:'\n ) {\n return original.apply(this, [optionsParsed, ...args]);\n }\n\n if (\n safeExecuteInTheMiddle(\n () =>\n instrumentation\n .getConfig()\n .ignoreOutgoingRequestHook?.(optionsParsed),\n (e: unknown) => {\n if (e != null) {\n instrumentation._diag.error(\n 'caught ignoreOutgoingRequestHook error: ',\n e\n );\n }\n },\n true\n )\n ) {\n return original.apply(this, [optionsParsed, ...args]);\n }\n\n const { hostname, port } = extractHostnameAndPort(optionsParsed);\n\n const attributes = getOutgoingRequestAttributes(\n optionsParsed,\n {\n component,\n port,\n hostname,\n hookAttributes: instrumentation._callStartSpanHook(\n optionsParsed,\n instrumentation.getConfig().startOutgoingSpanHook\n ),\n },\n instrumentation._semconvStability\n );\n\n const startTime = hrTime();\n const oldMetricAttributes: Attributes =\n getOutgoingRequestMetricAttributes(attributes);\n\n // request method, server address, and server port are both required span attributes\n const stableMetricAttributes: Attributes = {\n [ATTR_HTTP_REQUEST_METHOD]: attributes[ATTR_HTTP_REQUEST_METHOD],\n [ATTR_SERVER_ADDRESS]: attributes[ATTR_SERVER_ADDRESS],\n [ATTR_SERVER_PORT]: attributes[ATTR_SERVER_PORT],\n };\n\n // required if and only if one was sent, same as span requirement\n if (attributes[ATTR_HTTP_RESPONSE_STATUS_CODE]) {\n stableMetricAttributes[ATTR_HTTP_RESPONSE_STATUS_CODE] =\n attributes[ATTR_HTTP_RESPONSE_STATUS_CODE];\n }\n\n // recommended if and only if one was sent, same as span recommendation\n if (attributes[ATTR_NETWORK_PROTOCOL_VERSION]) {\n stableMetricAttributes[ATTR_NETWORK_PROTOCOL_VERSION] =\n attributes[ATTR_NETWORK_PROTOCOL_VERSION];\n }\n\n const spanOptions: SpanOptions = {\n kind: SpanKind.CLIENT,\n attributes,\n };\n const span = instrumentation._startHttpSpan(method, spanOptions);\n\n const parentContext = context.active();\n const requestContext = trace.setSpan(parentContext, span);\n\n if (!optionsParsed.headers) {\n optionsParsed.headers = {};\n } else {\n // Make a copy of the headers object to avoid mutating an object the\n // caller might have a reference to.\n optionsParsed.headers = Object.assign({}, optionsParsed.headers);\n }\n propagation.inject(requestContext, optionsParsed.headers);\n\n return context.with(requestContext, () => {\n /*\n * The response callback is registered before ClientRequest is bound,\n * thus it is needed to bind it before the function call.\n */\n const cb = args[args.length - 1];\n if (typeof cb === 'function') {\n args[args.length - 1] = context.bind(parentContext, cb);\n }\n\n const request: http.ClientRequest = safeExecuteInTheMiddle(\n () => original.apply(this, [optionsParsed, ...args]),\n error => {\n if (error) {\n setSpanWithError(span, error, instrumentation._semconvStability);\n instrumentation._closeHttpSpan(\n span,\n SpanKind.CLIENT,\n startTime,\n oldMetricAttributes,\n stableMetricAttributes\n );\n throw error;\n }\n }\n );\n\n instrumentation._diag.debug(\n `${component} instrumentation outgoingRequest`\n );\n context.bind(parentContext, request);\n return instrumentation._traceClientRequest(\n request,\n span,\n startTime,\n oldMetricAttributes,\n stableMetricAttributes\n );\n });\n };\n }\n\n private _onServerResponseFinish(\n request: http.IncomingMessage,\n response: http.ServerResponse,\n span: Span,\n oldMetricAttributes: Attributes,\n stableMetricAttributes: Attributes,\n startTime: HrTime\n ) {\n const attributes = getIncomingRequestAttributesOnResponse(\n request,\n response,\n this._semconvStability\n );\n oldMetricAttributes = Object.assign(\n oldMetricAttributes,\n getIncomingRequestMetricAttributesOnResponse(attributes)\n );\n stableMetricAttributes = Object.assign(\n stableMetricAttributes,\n getIncomingStableRequestMetricAttributesOnResponse(attributes)\n );\n\n this._headerCapture.server.captureResponseHeaders(span, header =>\n response.getHeader(header)\n );\n\n span.setAttributes(attributes).setStatus({\n code: parseResponseStatus(SpanKind.SERVER, response.statusCode),\n });\n\n const route = attributes[SEMATTRS_HTTP_ROUTE];\n if (route) {\n span.updateName(`${request.method || 'GET'} ${route}`);\n }\n\n if (this.getConfig().applyCustomAttributesOnSpan) {\n safeExecuteInTheMiddle(\n () =>\n this.getConfig().applyCustomAttributesOnSpan!(\n span,\n request,\n response\n ),\n () => {},\n true\n );\n }\n\n this._closeHttpSpan(\n span,\n SpanKind.SERVER,\n startTime,\n oldMetricAttributes,\n stableMetricAttributes\n );\n }\n\n private _onServerResponseError(\n span: Span,\n oldMetricAttributes: Attributes,\n stableMetricAttributes: Attributes,\n startTime: HrTime,\n error: Err\n ) {\n setSpanWithError(span, error, this._semconvStability);\n // TODO get error attributes for metrics\n this._closeHttpSpan(\n span,\n SpanKind.SERVER,\n startTime,\n oldMetricAttributes,\n stableMetricAttributes\n );\n }\n\n private _startHttpSpan(\n name: string,\n options: SpanOptions,\n ctx = context.active()\n ) {\n /*\n * If a parent is required but not present, we use a `NoopSpan` to still\n * propagate context without recording it.\n */\n const requireParent =\n options.kind === SpanKind.CLIENT\n ? this.getConfig().requireParentforOutgoingSpans\n : this.getConfig().requireParentforIncomingSpans;\n\n let span: Span;\n const currentSpan = trace.getSpan(ctx);\n\n if (requireParent === true && currentSpan === undefined) {\n span = trace.wrapSpanContext(INVALID_SPAN_CONTEXT);\n } else if (requireParent === true && currentSpan?.spanContext().isRemote) {\n span = currentSpan;\n } else {\n span = this.tracer.startSpan(name, options, ctx);\n }\n this._spanNotEnded.add(span);\n return span;\n }\n\n private _closeHttpSpan(\n span: Span,\n spanKind: SpanKind,\n startTime: HrTime,\n oldMetricAttributes: Attributes,\n stableMetricAttributes: Attributes\n ) {\n if (!this._spanNotEnded.has(span)) {\n return;\n }\n\n span.end();\n this._spanNotEnded.delete(span);\n\n // Record metrics\n const duration = hrTimeToMilliseconds(hrTimeDuration(startTime, hrTime()));\n if (spanKind === SpanKind.SERVER) {\n this._recordServerDuration(\n duration,\n oldMetricAttributes,\n stableMetricAttributes\n );\n } else if (spanKind === SpanKind.CLIENT) {\n this._recordClientDuration(\n duration,\n oldMetricAttributes,\n stableMetricAttributes\n );\n }\n }\n\n private _callResponseHook(\n span: Span,\n response: http.IncomingMessage | http.ServerResponse\n ) {\n safeExecuteInTheMiddle(\n () => this.getConfig().responseHook!(span, response),\n () => {},\n true\n );\n }\n\n private _callRequestHook(\n span: Span,\n request: http.ClientRequest | http.IncomingMessage\n ) {\n safeExecuteInTheMiddle(\n () => this.getConfig().requestHook!(span, request),\n () => {},\n true\n );\n }\n\n private _callStartSpanHook(\n request: http.IncomingMessage | http.RequestOptions,\n hookFunc: Function | undefined\n ) {\n if (typeof hookFunc === 'function') {\n return safeExecuteInTheMiddle(\n () => hookFunc(request),\n () => {},\n true\n );\n }\n }\n\n private _createHeaderCapture() {\n const config = this.getConfig();\n\n return {\n client: {\n captureRequestHeaders: headerCapture(\n 'request',\n config.headersToSpanAttributes?.client?.requestHeaders ?? []\n ),\n captureResponseHeaders: headerCapture(\n 'response',\n config.headersToSpanAttributes?.client?.responseHeaders ?? []\n ),\n },\n server: {\n captureRequestHeaders: headerCapture(\n 'request',\n config.headersToSpanAttributes?.server?.requestHeaders ?? []\n ),\n captureResponseHeaders: headerCapture(\n 'response',\n config.headersToSpanAttributes?.server?.responseHeaders ?? []\n ),\n },\n };\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export { HttpInstrumentation } from './http';
2
2
  export { Err, Func, GetFunction, Http, HttpCallback, HttpCallbackOptional, HttpCustomAttributeFunction, HttpInstrumentationConfig, HttpRequestArgs, HttpRequestCustomAttributeFunction, HttpResponseCustomAttributeFunction, Https, IgnoreIncomingRequestFunction, IgnoreMatcher, IgnoreOutgoingRequestFunction, ParsedRequestOptions, RequestFunction, RequestSignature, StartIncomingSpanCustomAttributeFunction, StartOutgoingSpanCustomAttributeFunction, } from './types';
3
- export { extractHostnameAndPort, getAbsoluteUrl, getIncomingRequestAttributes, getIncomingRequestAttributesOnResponse, getIncomingRequestMetricAttributes, getIncomingRequestMetricAttributesOnResponse, getOutgoingRequestAttributes, getOutgoingRequestAttributesOnResponse, getOutgoingRequestMetricAttributes, getOutgoingRequestMetricAttributesOnResponse, getRequestInfo, headerCapture, isCompressed, isIgnored, isValidOptionsType, parseResponseStatus, satisfiesPattern, setAttributesFromHttpKind, setRequestContentLengthAttribute, setResponseContentLengthAttribute, setSpanWithError, } from './utils';
3
+ export { extractHostnameAndPort, getAbsoluteUrl, getIncomingRequestAttributes, getIncomingRequestAttributesOnResponse, getIncomingRequestMetricAttributes, getIncomingRequestMetricAttributesOnResponse, getOutgoingRequestAttributes, getOutgoingRequestAttributesOnResponse, getOutgoingRequestMetricAttributes, getOutgoingRequestMetricAttributesOnResponse, getRequestInfo, headerCapture, isCompressed, isValidOptionsType, parseResponseStatus, satisfiesPattern, setAttributesFromHttpKind, setRequestContentLengthAttribute, setResponseContentLengthAttribute, setSpanWithError, } from './utils';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.setSpanWithError = exports.setResponseContentLengthAttribute = exports.setRequestContentLengthAttribute = exports.setAttributesFromHttpKind = exports.satisfiesPattern = exports.parseResponseStatus = exports.isValidOptionsType = exports.isIgnored = exports.isCompressed = exports.headerCapture = exports.getRequestInfo = exports.getOutgoingRequestMetricAttributesOnResponse = exports.getOutgoingRequestMetricAttributes = exports.getOutgoingRequestAttributesOnResponse = exports.getOutgoingRequestAttributes = exports.getIncomingRequestMetricAttributesOnResponse = exports.getIncomingRequestMetricAttributes = exports.getIncomingRequestAttributesOnResponse = exports.getIncomingRequestAttributes = exports.getAbsoluteUrl = exports.extractHostnameAndPort = exports.HttpInstrumentation = void 0;
18
+ exports.setSpanWithError = exports.setResponseContentLengthAttribute = exports.setRequestContentLengthAttribute = exports.setAttributesFromHttpKind = exports.satisfiesPattern = exports.parseResponseStatus = exports.isValidOptionsType = exports.isCompressed = exports.headerCapture = exports.getRequestInfo = exports.getOutgoingRequestMetricAttributesOnResponse = exports.getOutgoingRequestMetricAttributes = exports.getOutgoingRequestAttributesOnResponse = exports.getOutgoingRequestAttributes = exports.getIncomingRequestMetricAttributesOnResponse = exports.getIncomingRequestMetricAttributes = exports.getIncomingRequestAttributesOnResponse = exports.getIncomingRequestAttributes = exports.getAbsoluteUrl = exports.extractHostnameAndPort = exports.HttpInstrumentation = void 0;
19
19
  var http_1 = require("./http");
20
20
  Object.defineProperty(exports, "HttpInstrumentation", { enumerable: true, get: function () { return http_1.HttpInstrumentation; } });
21
21
  var utils_1 = require("./utils");
@@ -32,7 +32,6 @@ Object.defineProperty(exports, "getOutgoingRequestMetricAttributesOnResponse", {
32
32
  Object.defineProperty(exports, "getRequestInfo", { enumerable: true, get: function () { return utils_1.getRequestInfo; } });
33
33
  Object.defineProperty(exports, "headerCapture", { enumerable: true, get: function () { return utils_1.headerCapture; } });
34
34
  Object.defineProperty(exports, "isCompressed", { enumerable: true, get: function () { return utils_1.isCompressed; } });
35
- Object.defineProperty(exports, "isIgnored", { enumerable: true, get: function () { return utils_1.isIgnored; } });
36
35
  Object.defineProperty(exports, "isValidOptionsType", { enumerable: true, get: function () { return utils_1.isValidOptionsType; } });
37
36
  Object.defineProperty(exports, "parseResponseStatus", { enumerable: true, get: function () { return utils_1.parseResponseStatus; } });
38
37
  Object.defineProperty(exports, "satisfiesPattern", { enumerable: true, get: function () { return utils_1.satisfiesPattern; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,+BAA6C;AAApC,2GAAA,mBAAmB,OAAA;AAuB5B,iCAsBiB;AArBf,+GAAA,sBAAsB,OAAA;AACtB,uGAAA,cAAc,OAAA;AACd,qHAAA,4BAA4B,OAAA;AAC5B,+HAAA,sCAAsC,OAAA;AACtC,2HAAA,kCAAkC,OAAA;AAClC,qIAAA,4CAA4C,OAAA;AAC5C,qHAAA,4BAA4B,OAAA;AAC5B,+HAAA,sCAAsC,OAAA;AACtC,2HAAA,kCAAkC,OAAA;AAClC,qIAAA,4CAA4C,OAAA;AAC5C,uGAAA,cAAc,OAAA;AACd,sGAAA,aAAa,OAAA;AACb,qGAAA,YAAY,OAAA;AACZ,kGAAA,SAAS,OAAA;AACT,2GAAA,kBAAkB,OAAA;AAClB,4GAAA,mBAAmB,OAAA;AACnB,yGAAA,gBAAgB,OAAA;AAChB,kHAAA,yBAAyB,OAAA;AACzB,yHAAA,gCAAgC,OAAA;AAChC,0HAAA,iCAAiC,OAAA;AACjC,yGAAA,gBAAgB,OAAA","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\nexport { HttpInstrumentation } from './http';\nexport {\n Err,\n Func,\n GetFunction,\n Http,\n HttpCallback,\n HttpCallbackOptional,\n HttpCustomAttributeFunction,\n HttpInstrumentationConfig,\n HttpRequestArgs,\n HttpRequestCustomAttributeFunction,\n HttpResponseCustomAttributeFunction,\n Https,\n IgnoreIncomingRequestFunction,\n IgnoreMatcher,\n IgnoreOutgoingRequestFunction,\n ParsedRequestOptions,\n RequestFunction,\n RequestSignature,\n StartIncomingSpanCustomAttributeFunction,\n StartOutgoingSpanCustomAttributeFunction,\n} from './types';\nexport {\n extractHostnameAndPort,\n getAbsoluteUrl,\n getIncomingRequestAttributes,\n getIncomingRequestAttributesOnResponse,\n getIncomingRequestMetricAttributes,\n getIncomingRequestMetricAttributesOnResponse,\n getOutgoingRequestAttributes,\n getOutgoingRequestAttributesOnResponse,\n getOutgoingRequestMetricAttributes,\n getOutgoingRequestMetricAttributesOnResponse,\n getRequestInfo,\n headerCapture,\n isCompressed,\n isIgnored,\n isValidOptionsType,\n parseResponseStatus,\n satisfiesPattern,\n setAttributesFromHttpKind,\n setRequestContentLengthAttribute,\n setResponseContentLengthAttribute,\n setSpanWithError,\n} from './utils';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,+BAA6C;AAApC,2GAAA,mBAAmB,OAAA;AAuB5B,iCAqBiB;AApBf,+GAAA,sBAAsB,OAAA;AACtB,uGAAA,cAAc,OAAA;AACd,qHAAA,4BAA4B,OAAA;AAC5B,+HAAA,sCAAsC,OAAA;AACtC,2HAAA,kCAAkC,OAAA;AAClC,qIAAA,4CAA4C,OAAA;AAC5C,qHAAA,4BAA4B,OAAA;AAC5B,+HAAA,sCAAsC,OAAA;AACtC,2HAAA,kCAAkC,OAAA;AAClC,qIAAA,4CAA4C,OAAA;AAC5C,uGAAA,cAAc,OAAA;AACd,sGAAA,aAAa,OAAA;AACb,qGAAA,YAAY,OAAA;AACZ,2GAAA,kBAAkB,OAAA;AAClB,4GAAA,mBAAmB,OAAA;AACnB,yGAAA,gBAAgB,OAAA;AAChB,kHAAA,yBAAyB,OAAA;AACzB,yHAAA,gCAAgC,OAAA;AAChC,0HAAA,iCAAiC,OAAA;AACjC,yGAAA,gBAAgB,OAAA","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\nexport { HttpInstrumentation } from './http';\nexport {\n Err,\n Func,\n GetFunction,\n Http,\n HttpCallback,\n HttpCallbackOptional,\n HttpCustomAttributeFunction,\n HttpInstrumentationConfig,\n HttpRequestArgs,\n HttpRequestCustomAttributeFunction,\n HttpResponseCustomAttributeFunction,\n Https,\n IgnoreIncomingRequestFunction,\n IgnoreMatcher,\n IgnoreOutgoingRequestFunction,\n ParsedRequestOptions,\n RequestFunction,\n RequestSignature,\n StartIncomingSpanCustomAttributeFunction,\n StartOutgoingSpanCustomAttributeFunction,\n} from './types';\nexport {\n extractHostnameAndPort,\n getAbsoluteUrl,\n getIncomingRequestAttributes,\n getIncomingRequestAttributesOnResponse,\n getIncomingRequestMetricAttributes,\n getIncomingRequestMetricAttributesOnResponse,\n getOutgoingRequestAttributes,\n getOutgoingRequestAttributesOnResponse,\n getOutgoingRequestMetricAttributes,\n getOutgoingRequestMetricAttributesOnResponse,\n getRequestInfo,\n headerCapture,\n isCompressed,\n isValidOptionsType,\n parseResponseStatus,\n satisfiesPattern,\n setAttributesFromHttpKind,\n setRequestContentLengthAttribute,\n setResponseContentLengthAttribute,\n setSpanWithError,\n} from './utils';\n"]}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Span, SpanAttributes } from '@opentelemetry/api';
2
+ import { Span, Attributes } from '@opentelemetry/api';
3
3
  import type * as http from 'http';
4
4
  import type * as https from 'https';
5
5
  import { ClientRequest, get, IncomingMessage, request, ServerResponse, RequestOptions } from 'http';
@@ -32,27 +32,17 @@ export interface HttpResponseCustomAttributeFunction {
32
32
  (span: Span, response: IncomingMessage | ServerResponse): void;
33
33
  }
34
34
  export interface StartIncomingSpanCustomAttributeFunction {
35
- (request: IncomingMessage): SpanAttributes;
35
+ (request: IncomingMessage): Attributes;
36
36
  }
37
37
  export interface StartOutgoingSpanCustomAttributeFunction {
38
- (request: RequestOptions): SpanAttributes;
38
+ (request: RequestOptions): Attributes;
39
39
  }
40
40
  /**
41
41
  * Options available for the HTTP instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-http#http-instrumentation-options))
42
42
  */
43
43
  export interface HttpInstrumentationConfig extends InstrumentationConfig {
44
- /**
45
- * Not trace all incoming requests that match paths
46
- * @deprecated use `ignoreIncomingRequestHook` instead
47
- */
48
- ignoreIncomingPaths?: IgnoreMatcher[];
49
44
  /** Not trace all incoming requests that matched with custom function */
50
45
  ignoreIncomingRequestHook?: IgnoreIncomingRequestFunction;
51
- /**
52
- * Not trace all outgoing requests that match urls
53
- * @deprecated use `ignoreOutgoingRequestHook` instead
54
- */
55
- ignoreOutgoingUrls?: IgnoreMatcher[];
56
46
  /** Not trace all outgoing requests that matched with custom function */
57
47
  ignoreOutgoingRequestHook?: IgnoreOutgoingRequestFunction;
58
48
  /** If set to true, incoming requests will not be instrumented at all. */
@@ -94,4 +84,18 @@ export interface Err extends Error {
94
84
  syscall?: string;
95
85
  stack?: string;
96
86
  }
87
+ /**
88
+ * Tracks whether this instrumentation emits old experimental,
89
+ * new stable, or both semantic conventions.
90
+ *
91
+ * Enum values chosen such that the enum may be used as a bitmask.
92
+ */
93
+ export declare const enum SemconvStability {
94
+ /** Emit only stable semantic conventions */
95
+ STABLE = 1,
96
+ /** Emit only old semantic convetions */
97
+ OLD = 2,
98
+ /** Emit both stable and old semantic convetions */
99
+ DUPLICATE = 3
100
+ }
97
101
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","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 { Span, SpanAttributes } from '@opentelemetry/api';\nimport type * as http from 'http';\nimport type * as https from 'https';\nimport {\n ClientRequest,\n get,\n IncomingMessage,\n request,\n ServerResponse,\n RequestOptions,\n} from 'http';\nimport * as url from 'url';\nimport { InstrumentationConfig } from '@opentelemetry/instrumentation';\n\nexport type IgnoreMatcher = string | RegExp | ((url: string) => boolean);\nexport type HttpCallback = (res: IncomingMessage) => void;\nexport type RequestFunction = typeof request;\nexport type GetFunction = typeof get;\n\nexport type HttpCallbackOptional = HttpCallback | undefined;\n\n// from node 10+\nexport type RequestSignature = [http.RequestOptions, HttpCallbackOptional] &\n HttpCallback;\n\nexport type HttpRequestArgs = Array<HttpCallbackOptional | RequestSignature>;\n\nexport type ParsedRequestOptions =\n | (http.RequestOptions & Partial<url.UrlWithParsedQuery>)\n | http.RequestOptions;\nexport type Http = typeof http;\nexport type Https = typeof https;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Func<T> = (...args: any[]) => T;\n\nexport interface HttpCustomAttributeFunction {\n (\n span: Span,\n request: ClientRequest | IncomingMessage,\n response: IncomingMessage | ServerResponse\n ): void;\n}\n\nexport interface IgnoreIncomingRequestFunction {\n (request: IncomingMessage): boolean;\n}\n\nexport interface IgnoreOutgoingRequestFunction {\n (request: RequestOptions): boolean;\n}\n\nexport interface HttpRequestCustomAttributeFunction {\n (span: Span, request: ClientRequest | IncomingMessage): void;\n}\n\nexport interface HttpResponseCustomAttributeFunction {\n (span: Span, response: IncomingMessage | ServerResponse): void;\n}\n\nexport interface StartIncomingSpanCustomAttributeFunction {\n (request: IncomingMessage): SpanAttributes;\n}\n\nexport interface StartOutgoingSpanCustomAttributeFunction {\n (request: RequestOptions): SpanAttributes;\n}\n\n/**\n * Options available for the HTTP instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-http#http-instrumentation-options))\n */\nexport interface HttpInstrumentationConfig extends InstrumentationConfig {\n /**\n * Not trace all incoming requests that match paths\n * @deprecated use `ignoreIncomingRequestHook` instead\n */\n ignoreIncomingPaths?: IgnoreMatcher[];\n /** Not trace all incoming requests that matched with custom function */\n ignoreIncomingRequestHook?: IgnoreIncomingRequestFunction;\n /**\n * Not trace all outgoing requests that match urls\n * @deprecated use `ignoreOutgoingRequestHook` instead\n */\n ignoreOutgoingUrls?: IgnoreMatcher[];\n /** Not trace all outgoing requests that matched with custom function */\n ignoreOutgoingRequestHook?: IgnoreOutgoingRequestFunction;\n /** If set to true, incoming requests will not be instrumented at all. */\n disableIncomingRequestInstrumentation?: boolean;\n /** If set to true, outgoing requests will not be instrumented at all. */\n disableOutgoingRequestInstrumentation?: boolean;\n /** Function for adding custom attributes after response is handled */\n applyCustomAttributesOnSpan?: HttpCustomAttributeFunction;\n /** Function for adding custom attributes before request is handled */\n requestHook?: HttpRequestCustomAttributeFunction;\n /** Function for adding custom attributes before response is handled */\n responseHook?: HttpResponseCustomAttributeFunction;\n /** Function for adding custom attributes before a span is started in incomingRequest */\n startIncomingSpanHook?: StartIncomingSpanCustomAttributeFunction;\n /** Function for adding custom attributes before a span is started in outgoingRequest */\n startOutgoingSpanHook?: StartOutgoingSpanCustomAttributeFunction;\n /** The primary server name of the matched virtual host. */\n serverName?: string;\n /** Require parent to create span for outgoing requests */\n requireParentforOutgoingSpans?: boolean;\n /** Require parent to create span for incoming requests */\n requireParentforIncomingSpans?: boolean;\n /** Map the following HTTP headers to span attributes. */\n headersToSpanAttributes?: {\n client?: { requestHeaders?: string[]; responseHeaders?: string[] };\n server?: { requestHeaders?: string[]; responseHeaders?: string[] };\n };\n}\n\nexport interface Err extends Error {\n errno?: number;\n code?: string;\n path?: string;\n syscall?: string;\n stack?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","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 { Span, Attributes } from '@opentelemetry/api';\nimport type * as http from 'http';\nimport type * as https from 'https';\nimport {\n ClientRequest,\n get,\n IncomingMessage,\n request,\n ServerResponse,\n RequestOptions,\n} from 'http';\nimport * as url from 'url';\nimport { InstrumentationConfig } from '@opentelemetry/instrumentation';\n\nexport type IgnoreMatcher = string | RegExp | ((url: string) => boolean);\nexport type HttpCallback = (res: IncomingMessage) => void;\nexport type RequestFunction = typeof request;\nexport type GetFunction = typeof get;\n\nexport type HttpCallbackOptional = HttpCallback | undefined;\n\n// from node 10+\nexport type RequestSignature = [http.RequestOptions, HttpCallbackOptional] &\n HttpCallback;\n\nexport type HttpRequestArgs = Array<HttpCallbackOptional | RequestSignature>;\n\nexport type ParsedRequestOptions =\n | (http.RequestOptions & Partial<url.UrlWithParsedQuery>)\n | http.RequestOptions;\nexport type Http = typeof http;\nexport type Https = typeof https;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Func<T> = (...args: any[]) => T;\n\nexport interface HttpCustomAttributeFunction {\n (\n span: Span,\n request: ClientRequest | IncomingMessage,\n response: IncomingMessage | ServerResponse\n ): void;\n}\n\nexport interface IgnoreIncomingRequestFunction {\n (request: IncomingMessage): boolean;\n}\n\nexport interface IgnoreOutgoingRequestFunction {\n (request: RequestOptions): boolean;\n}\n\nexport interface HttpRequestCustomAttributeFunction {\n (span: Span, request: ClientRequest | IncomingMessage): void;\n}\n\nexport interface HttpResponseCustomAttributeFunction {\n (span: Span, response: IncomingMessage | ServerResponse): void;\n}\n\nexport interface StartIncomingSpanCustomAttributeFunction {\n (request: IncomingMessage): Attributes;\n}\n\nexport interface StartOutgoingSpanCustomAttributeFunction {\n (request: RequestOptions): Attributes;\n}\n\n/**\n * Options available for the HTTP instrumentation (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-http#http-instrumentation-options))\n */\nexport interface HttpInstrumentationConfig extends InstrumentationConfig {\n /** Not trace all incoming requests that matched with custom function */\n ignoreIncomingRequestHook?: IgnoreIncomingRequestFunction;\n /** Not trace all outgoing requests that matched with custom function */\n ignoreOutgoingRequestHook?: IgnoreOutgoingRequestFunction;\n /** If set to true, incoming requests will not be instrumented at all. */\n disableIncomingRequestInstrumentation?: boolean;\n /** If set to true, outgoing requests will not be instrumented at all. */\n disableOutgoingRequestInstrumentation?: boolean;\n /** Function for adding custom attributes after response is handled */\n applyCustomAttributesOnSpan?: HttpCustomAttributeFunction;\n /** Function for adding custom attributes before request is handled */\n requestHook?: HttpRequestCustomAttributeFunction;\n /** Function for adding custom attributes before response is handled */\n responseHook?: HttpResponseCustomAttributeFunction;\n /** Function for adding custom attributes before a span is started in incomingRequest */\n startIncomingSpanHook?: StartIncomingSpanCustomAttributeFunction;\n /** Function for adding custom attributes before a span is started in outgoingRequest */\n startOutgoingSpanHook?: StartOutgoingSpanCustomAttributeFunction;\n /** The primary server name of the matched virtual host. */\n serverName?: string;\n /** Require parent to create span for outgoing requests */\n requireParentforOutgoingSpans?: boolean;\n /** Require parent to create span for incoming requests */\n requireParentforIncomingSpans?: boolean;\n /** Map the following HTTP headers to span attributes. */\n headersToSpanAttributes?: {\n client?: { requestHeaders?: string[]; responseHeaders?: string[] };\n server?: { requestHeaders?: string[]; responseHeaders?: string[] };\n };\n}\n\nexport interface Err extends Error {\n errno?: number;\n code?: string;\n path?: string;\n syscall?: string;\n stack?: string;\n}\n\n/**\n * Tracks whether this instrumentation emits old experimental,\n * new stable, or both semantic conventions.\n *\n * Enum values chosen such that the enum may be used as a bitmask.\n */\nexport const enum SemconvStability {\n /** Emit only stable semantic conventions */\n STABLE = 0x1,\n /** Emit only old semantic convetions */\n OLD = 0x2,\n /** Emit both stable and old semantic convetions */\n DUPLICATE = 0x1 | 0x2,\n}\n"]}
@@ -1,7 +1,8 @@
1
- import { MetricAttributes, SpanAttributes, SpanStatusCode, Span, SpanKind } from '@opentelemetry/api';
1
+ /// <reference types="node" />
2
+ import { Attributes, SpanStatusCode, Span, SpanKind } from '@opentelemetry/api';
2
3
  import { IncomingHttpHeaders, IncomingMessage, OutgoingHttpHeaders, RequestOptions, ServerResponse } from 'http';
3
4
  import * as url from 'url';
4
- import { Err, IgnoreMatcher, ParsedRequestOptions } from './types';
5
+ import { Err, IgnoreMatcher, ParsedRequestOptions, SemconvStability } from './types';
5
6
  /**
6
7
  * Get an absolute url
7
8
  */
@@ -16,33 +17,27 @@ export declare const parseResponseStatus: (kind: SpanKind, statusCode?: number |
16
17
  * @param pattern Match pattern
17
18
  */
18
19
  export declare const satisfiesPattern: (constant: string, pattern: IgnoreMatcher) => boolean;
19
- /**
20
- * Check whether the given request is ignored by configuration
21
- * It will not re-throw exceptions from `list` provided by the client
22
- * @param constant e.g URL of request
23
- * @param [list] List of ignore patterns
24
- * @param [onException] callback for doing something when an exception has
25
- * occurred
26
- */
27
- export declare const isIgnored: (constant: string, list?: IgnoreMatcher[] | undefined, onException?: ((error: unknown) => void) | undefined) => boolean;
28
20
  /**
29
21
  * Sets the span with the error passed in params
30
22
  * @param {Span} span the span that need to be set
31
23
  * @param {Error} error error that will be set to span
24
+ * @param {SemconvStability} semconvStability determines which semconv version to use
32
25
  */
33
- export declare const setSpanWithError: (span: Span, error: Err) => void;
26
+ export declare const setSpanWithError: (span: Span, error: Err, semconvStability: SemconvStability) => void;
34
27
  /**
35
28
  * Adds attributes for request content-length and content-encoding HTTP headers
36
29
  * @param { IncomingMessage } Request object whose headers will be analyzed
37
- * @param { SpanAttributes } SpanAttributes object to be modified
30
+ * @param { Attributes } Attributes object to be modified
38
31
  */
39
- export declare const setRequestContentLengthAttribute: (request: IncomingMessage, attributes: SpanAttributes) => void;
32
+ export declare const setRequestContentLengthAttribute: (request: IncomingMessage, attributes: Attributes) => void;
40
33
  /**
41
34
  * Adds attributes for response content-length and content-encoding HTTP headers
42
35
  * @param { IncomingMessage } Response object whose headers will be analyzed
43
- * @param { SpanAttributes } SpanAttributes object to be modified
36
+ * @param { Attributes } Attributes object to be modified
37
+ *
38
+ * @deprecated this is for an older version of semconv. It is retained for compatibility using OTEL_SEMCONV_STABILITY_OPT_IN
44
39
  */
45
- export declare const setResponseContentLengthAttribute: (response: IncomingMessage, attributes: SpanAttributes) => void;
40
+ export declare const setResponseContentLengthAttribute: (response: IncomingMessage, attributes: Attributes) => void;
46
41
  export declare const isCompressed: (headers: OutgoingHttpHeaders | IncomingHttpHeaders) => boolean;
47
42
  /**
48
43
  * Makes sure options is an url object
@@ -68,60 +63,69 @@ export declare const extractHostnameAndPort: (requestOptions: Pick<ParsedRequest
68
63
  /**
69
64
  * Returns outgoing request attributes scoped to the options passed to the request
70
65
  * @param {ParsedRequestOptions} requestOptions the same options used to make the request
71
- * @param {{ component: string, hostname: string, hookAttributes?: SpanAttributes }} options used to pass data needed to create attributes
66
+ * @param {{ component: string, hostname: string, hookAttributes?: Attributes }} options used to pass data needed to create attributes
67
+ * @param {SemconvStability} semconvStability determines which semconv version to use
72
68
  */
73
69
  export declare const getOutgoingRequestAttributes: (requestOptions: ParsedRequestOptions, options: {
74
70
  component: string;
75
71
  hostname: string;
76
72
  port: string | number;
77
- hookAttributes?: SpanAttributes;
78
- }) => SpanAttributes;
73
+ hookAttributes?: Attributes;
74
+ }, semconvStability: SemconvStability) => Attributes;
79
75
  /**
80
76
  * Returns outgoing request Metric attributes scoped to the request data
81
- * @param {SpanAttributes} spanAttributes the span attributes
77
+ * @param {Attributes} spanAttributes the span attributes
82
78
  */
83
- export declare const getOutgoingRequestMetricAttributes: (spanAttributes: SpanAttributes) => MetricAttributes;
79
+ export declare const getOutgoingRequestMetricAttributes: (spanAttributes: Attributes) => Attributes;
84
80
  /**
85
81
  * Returns attributes related to the kind of HTTP protocol used
86
82
  * @param {string} [kind] Kind of HTTP protocol used: "1.0", "1.1", "2", "SPDY" or "QUIC".
87
83
  */
88
- export declare const setAttributesFromHttpKind: (kind: string | undefined, attributes: SpanAttributes) => void;
84
+ export declare const setAttributesFromHttpKind: (kind: string | undefined, attributes: Attributes) => void;
89
85
  /**
90
86
  * Returns outgoing request attributes scoped to the response data
91
87
  * @param {IncomingMessage} response the response object
92
- * @param {{ hostname: string }} options used to pass data needed to create attributes
88
+ * @param {SemconvStability} semconvStability determines which semconv version to use
93
89
  */
94
- export declare const getOutgoingRequestAttributesOnResponse: (response: IncomingMessage) => SpanAttributes;
90
+ export declare const getOutgoingRequestAttributesOnResponse: (response: IncomingMessage, semconvStability: SemconvStability) => Attributes;
95
91
  /**
96
92
  * Returns outgoing request Metric attributes scoped to the response data
97
- * @param {SpanAttributes} spanAttributes the span attributes
93
+ * @param {Attributes} spanAttributes the span attributes
98
94
  */
99
- export declare const getOutgoingRequestMetricAttributesOnResponse: (spanAttributes: SpanAttributes) => MetricAttributes;
95
+ export declare const getOutgoingRequestMetricAttributesOnResponse: (spanAttributes: Attributes) => Attributes;
96
+ /**
97
+ * Get server.address and port according to http semconv 1.27
98
+ * https://github.com/open-telemetry/semantic-conventions/blob/bf0a2c1134f206f034408b201dbec37960ed60ec/docs/http/http-spans.md#setting-serveraddress-and-serverport-attributes
99
+ */
100
+ export declare function getRemoteClientAddress(request: IncomingMessage): string | null;
100
101
  /**
101
102
  * Returns incoming request attributes scoped to the request data
102
103
  * @param {IncomingMessage} request the request object
103
- * @param {{ component: string, serverName?: string, hookAttributes?: SpanAttributes }} options used to pass data needed to create attributes
104
+ * @param {{ component: string, serverName?: string, hookAttributes?: Attributes }} options used to pass data needed to create attributes
105
+ * @param {SemconvStability} semconvStability determines which semconv version to use
104
106
  */
105
107
  export declare const getIncomingRequestAttributes: (request: IncomingMessage, options: {
106
- component: string;
108
+ component: 'http' | 'https';
107
109
  serverName?: string;
108
- hookAttributes?: SpanAttributes;
109
- }) => SpanAttributes;
110
+ hookAttributes?: Attributes;
111
+ semconvStability: SemconvStability;
112
+ }) => Attributes;
110
113
  /**
111
114
  * Returns incoming request Metric attributes scoped to the request data
112
- * @param {SpanAttributes} spanAttributes the span attributes
115
+ * @param {Attributes} spanAttributes the span attributes
113
116
  * @param {{ component: string }} options used to pass data needed to create attributes
114
117
  */
115
- export declare const getIncomingRequestMetricAttributes: (spanAttributes: SpanAttributes) => MetricAttributes;
118
+ export declare const getIncomingRequestMetricAttributes: (spanAttributes: Attributes) => Attributes;
116
119
  /**
117
120
  * Returns incoming request attributes scoped to the response data
118
121
  * @param {(ServerResponse & { socket: Socket; })} response the response object
119
122
  */
120
- export declare const getIncomingRequestAttributesOnResponse: (request: IncomingMessage, response: ServerResponse) => SpanAttributes;
123
+ export declare const getIncomingRequestAttributesOnResponse: (request: IncomingMessage, response: ServerResponse, semconvStability: SemconvStability) => Attributes;
121
124
  /**
122
125
  * Returns incoming request Metric attributes scoped to the request data
123
- * @param {SpanAttributes} spanAttributes the span attributes
126
+ * @param {Attributes} spanAttributes the span attributes
124
127
  */
125
- export declare const getIncomingRequestMetricAttributesOnResponse: (spanAttributes: SpanAttributes) => MetricAttributes;
128
+ export declare const getIncomingRequestMetricAttributesOnResponse: (spanAttributes: Attributes) => Attributes;
129
+ export declare const getIncomingStableRequestMetricAttributesOnResponse: (spanAttributes: Attributes) => Attributes;
126
130
  export declare function headerCapture(type: 'request' | 'response', headers: string[]): (span: Span, getHeader: (key: string) => undefined | string | string[] | number) => void;
127
131
  //# sourceMappingURL=utils.d.ts.map