@opentelemetry/instrumentation-amqplib 0.61.0 → 0.63.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 CHANGED
@@ -17,7 +17,7 @@ npm install --save @opentelemetry/instrumentation-amqplib
17
17
 
18
18
  ## Supported Versions
19
19
 
20
- - [`amqplib`](https://www.npmjs.com/package/amqplib) versions `>=0.5.5 <1`
20
+ - [`amqplib`](https://www.npmjs.com/package/amqplib) versions `>=0.5.5 <2`
21
21
 
22
22
  ## Usage
23
23
 
@@ -3,18 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AmqplibInstrumentation = void 0;
4
4
  /*
5
5
  * Copyright The OpenTelemetry Authors
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * https://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
6
+ * SPDX-License-Identifier: Apache-2.0
18
7
  */
19
8
  const api_1 = require("@opentelemetry/api");
20
9
  const core_1 = require("@opentelemetry/core");
@@ -25,7 +14,7 @@ const types_1 = require("./types");
25
14
  const utils_1 = require("./utils");
26
15
  /** @knipignore */
27
16
  const version_1 = require("./version");
28
- const supportedVersions = ['>=0.5.5 <1'];
17
+ const supportedVersions = ['>=0.5.5 <2'];
29
18
  class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
30
19
  _netSemconvStability;
31
20
  constructor(config = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"amqplib.js","sourceRoot":"","sources":["../../src/amqplib.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAW4B;AAC5B,8CAI6B;AAC7B,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;aACP;YACD,IAAI,CAAC,eAAe,CAClB,WAAW,CAAC,GAAG,EACf,IAAI,EACJ,oBAAY,CAAC,sBAAsB,EACnC,IAAI,CACL,CAAC;SACH;QACD,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF;AAtrBD,wDAsrBC","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 diag,\n propagation,\n trace,\n Span,\n SpanKind,\n SpanStatusCode,\n ROOT_CONTEXT,\n Link,\n Context,\n} from '@opentelemetry/api';\nimport {\n hrTime,\n hrTimeDuration,\n hrTimeToMilliseconds,\n} from '@opentelemetry/core';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n SemconvStability,\n semconvStabilityFromStr,\n} from '@opentelemetry/instrumentation';\nimport { ATTR_MESSAGING_OPERATION } from './semconv';\nimport {\n ATTR_MESSAGING_DESTINATION,\n ATTR_MESSAGING_DESTINATION_KIND,\n ATTR_MESSAGING_RABBITMQ_ROUTING_KEY,\n MESSAGING_DESTINATION_KIND_VALUE_TOPIC,\n MESSAGING_OPERATION_VALUE_PROCESS,\n OLD_ATTR_MESSAGING_MESSAGE_ID,\n ATTR_MESSAGING_CONVERSATION_ID,\n} from '../src/semconv-obsolete';\nimport type {\n Connection,\n ConsumeMessage,\n Message,\n Options,\n Replies,\n} from 'amqplib';\nimport {\n AmqplibInstrumentationConfig,\n DEFAULT_CONFIG,\n EndOperation,\n} from './types';\nimport {\n CHANNEL_CONSUME_TIMEOUT_TIMER,\n CHANNEL_SPANS_NOT_ENDED,\n CONNECTION_ATTRIBUTES,\n getConnectionAttributesFromServer,\n getConnectionAttributesFromUrl,\n InstrumentationConnection,\n InstrumentationConsumeChannel,\n InstrumentationConsumeMessage,\n InstrumentationMessage,\n InstrumentationPublishChannel,\n isConfirmChannelTracing,\n markConfirmChannelTracing,\n MESSAGE_STORED_SPAN,\n normalizeExchange,\n unmarkConfirmChannelTracing,\n} from './utils';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\n\nconst supportedVersions = ['>=0.5.5 <1'];\n\nexport class AmqplibInstrumentation extends InstrumentationBase<AmqplibInstrumentationConfig> {\n private _netSemconvStability!: SemconvStability;\n\n constructor(config: AmqplibInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, { ...DEFAULT_CONFIG, ...config });\n this._setSemconvStabilityFromEnv();\n }\n\n // Used for testing.\n private _setSemconvStabilityFromEnv() {\n this._netSemconvStability = semconvStabilityFromStr(\n 'http',\n process.env.OTEL_SEMCONV_STABILITY_OPT_IN\n );\n }\n\n override setConfig(config: AmqplibInstrumentationConfig = {}) {\n super.setConfig({ ...DEFAULT_CONFIG, ...config });\n }\n\n protected init() {\n const channelModelModuleFile = new InstrumentationNodeModuleFile(\n 'amqplib/lib/channel_model.js',\n supportedVersions,\n this.patchChannelModel.bind(this),\n this.unpatchChannelModel.bind(this)\n );\n\n const callbackModelModuleFile = new InstrumentationNodeModuleFile(\n 'amqplib/lib/callback_model.js',\n supportedVersions,\n this.patchChannelModel.bind(this),\n this.unpatchChannelModel.bind(this)\n );\n\n const connectModuleFile = new InstrumentationNodeModuleFile(\n 'amqplib/lib/connect.js',\n supportedVersions,\n this.patchConnect.bind(this),\n this.unpatchConnect.bind(this)\n );\n\n const module = new InstrumentationNodeModuleDefinition(\n 'amqplib',\n supportedVersions,\n undefined,\n undefined,\n [channelModelModuleFile, connectModuleFile, callbackModelModuleFile]\n );\n return module;\n }\n\n private patchConnect(moduleExports: any) {\n moduleExports = this.unpatchConnect(moduleExports);\n if (!isWrapped(moduleExports.connect)) {\n this._wrap(moduleExports, 'connect', this.getConnectPatch.bind(this));\n }\n return moduleExports;\n }\n\n private unpatchConnect(moduleExports: any) {\n if (isWrapped(moduleExports.connect)) {\n this._unwrap(moduleExports, 'connect');\n }\n return moduleExports;\n }\n\n private patchChannelModel(\n moduleExports: any,\n moduleVersion: string | undefined\n ) {\n if (!isWrapped(moduleExports.Channel.prototype.publish)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'publish',\n this.getPublishPatch.bind(this, moduleVersion)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.consume)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'consume',\n this.getConsumePatch.bind(this, moduleVersion)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.ack)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'ack',\n this.getAckPatch.bind(this, false, EndOperation.Ack)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.nack)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'nack',\n this.getAckPatch.bind(this, true, EndOperation.Nack)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.reject)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'reject',\n this.getAckPatch.bind(this, true, EndOperation.Reject)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.ackAll)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'ackAll',\n this.getAckAllPatch.bind(this, false, EndOperation.AckAll)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.nackAll)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'nackAll',\n this.getAckAllPatch.bind(this, true, EndOperation.NackAll)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.emit)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'emit',\n this.getChannelEmitPatch.bind(this)\n );\n }\n if (!isWrapped(moduleExports.ConfirmChannel.prototype.publish)) {\n this._wrap(\n moduleExports.ConfirmChannel.prototype,\n 'publish',\n this.getConfirmedPublishPatch.bind(this, moduleVersion)\n );\n }\n return moduleExports;\n }\n\n private unpatchChannelModel(moduleExports: any) {\n if (isWrapped(moduleExports.Channel.prototype.publish)) {\n this._unwrap(moduleExports.Channel.prototype, 'publish');\n }\n if (isWrapped(moduleExports.Channel.prototype.consume)) {\n this._unwrap(moduleExports.Channel.prototype, 'consume');\n }\n if (isWrapped(moduleExports.Channel.prototype.ack)) {\n this._unwrap(moduleExports.Channel.prototype, 'ack');\n }\n if (isWrapped(moduleExports.Channel.prototype.nack)) {\n this._unwrap(moduleExports.Channel.prototype, 'nack');\n }\n if (isWrapped(moduleExports.Channel.prototype.reject)) {\n this._unwrap(moduleExports.Channel.prototype, 'reject');\n }\n if (isWrapped(moduleExports.Channel.prototype.ackAll)) {\n this._unwrap(moduleExports.Channel.prototype, 'ackAll');\n }\n if (isWrapped(moduleExports.Channel.prototype.nackAll)) {\n this._unwrap(moduleExports.Channel.prototype, 'nackAll');\n }\n if (isWrapped(moduleExports.Channel.prototype.emit)) {\n this._unwrap(moduleExports.Channel.prototype, 'emit');\n }\n if (isWrapped(moduleExports.ConfirmChannel.prototype.publish)) {\n this._unwrap(moduleExports.ConfirmChannel.prototype, 'publish');\n }\n return moduleExports;\n }\n\n private getConnectPatch(\n original: (\n url: string | Options.Connect,\n socketOptions: any,\n openCallback: (err: any, connection: Connection) => void\n ) => Connection\n ) {\n const self = this;\n return function patchedConnect(\n this: unknown,\n url: string | Options.Connect,\n socketOptions: any,\n openCallback: Function\n ) {\n return original.call(\n this,\n url,\n socketOptions,\n function (this: unknown, err, conn: InstrumentationConnection) {\n if (err == null) {\n const urlAttributes = getConnectionAttributesFromUrl(\n url,\n self._netSemconvStability\n );\n const serverAttributes = getConnectionAttributesFromServer(conn);\n conn[CONNECTION_ATTRIBUTES] = {\n ...urlAttributes,\n ...serverAttributes,\n };\n }\n openCallback.apply(this, arguments);\n }\n );\n };\n }\n\n private getChannelEmitPatch(original: Function) {\n const self = this;\n return function emit(\n this: InstrumentationConsumeChannel,\n eventName: string\n ) {\n if (eventName === 'close') {\n self.endAllSpansOnChannel(\n this,\n true,\n EndOperation.ChannelClosed,\n undefined\n );\n const activeTimer = this[CHANNEL_CONSUME_TIMEOUT_TIMER];\n if (activeTimer) {\n clearInterval(activeTimer);\n }\n this[CHANNEL_CONSUME_TIMEOUT_TIMER] = undefined;\n } else if (eventName === 'error') {\n self.endAllSpansOnChannel(\n this,\n true,\n EndOperation.ChannelError,\n undefined\n );\n }\n return original.apply(this, arguments);\n };\n }\n\n private getAckAllPatch(\n isRejected: boolean,\n endOperation: EndOperation,\n original: Function\n ) {\n const self = this;\n return function ackAll(\n this: InstrumentationConsumeChannel,\n requeueOrEmpty?: boolean\n ): void {\n self.endAllSpansOnChannel(this, isRejected, endOperation, requeueOrEmpty);\n return original.apply(this, arguments);\n };\n }\n\n private getAckPatch(\n isRejected: boolean,\n endOperation: EndOperation,\n original: Function\n ) {\n const self = this;\n return function ack(\n this: InstrumentationConsumeChannel,\n message: Message,\n allUpToOrRequeue?: boolean,\n requeue?: boolean\n ): void {\n const channel = this;\n // we use this patch in reject function as well, but it has different signature\n const requeueResolved =\n endOperation === EndOperation.Reject ? allUpToOrRequeue : requeue;\n\n const spansNotEnded: { msg: Message }[] =\n channel[CHANNEL_SPANS_NOT_ENDED] ?? [];\n const msgIndex = spansNotEnded.findIndex(\n msgDetails => msgDetails.msg === message\n );\n if (msgIndex < 0) {\n // should not happen in happy flow\n // but possible if user is calling the api function ack twice with same message\n self.endConsumerSpan(\n message,\n isRejected,\n endOperation,\n requeueResolved\n );\n } else if (endOperation !== EndOperation.Reject && allUpToOrRequeue) {\n for (let i = 0; i <= msgIndex; i++) {\n self.endConsumerSpan(\n spansNotEnded[i].msg,\n isRejected,\n endOperation,\n requeueResolved\n );\n }\n spansNotEnded.splice(0, msgIndex + 1);\n } else {\n self.endConsumerSpan(\n message,\n isRejected,\n endOperation,\n requeueResolved\n );\n spansNotEnded.splice(msgIndex, 1);\n }\n return original.apply(this, arguments);\n };\n }\n\n private getConsumePatch(\n moduleVersion: string | undefined,\n original: Function\n ) {\n const self = this;\n return function consume(\n this: InstrumentationConsumeChannel,\n queue: string,\n onMessage: (msg: ConsumeMessage | null) => void,\n options?: Options.Consume\n ): Promise<Replies.Consume> {\n const channel = this;\n if (\n !Object.prototype.hasOwnProperty.call(channel, CHANNEL_SPANS_NOT_ENDED)\n ) {\n const { consumeTimeoutMs } = self.getConfig();\n if (consumeTimeoutMs) {\n const timer = setInterval(() => {\n self.checkConsumeTimeoutOnChannel(channel);\n }, consumeTimeoutMs);\n timer.unref();\n channel[CHANNEL_CONSUME_TIMEOUT_TIMER] = timer;\n }\n channel[CHANNEL_SPANS_NOT_ENDED] = [];\n }\n\n const patchedOnMessage = function (\n this: unknown,\n msg: InstrumentationConsumeMessage | null\n ) {\n // msg is expected to be null for signaling consumer cancel notification\n // https://www.rabbitmq.com/consumer-cancel.html\n // in this case, we do not start a span, as this is not a real message.\n if (!msg) {\n return onMessage.call(this, msg);\n }\n\n const headers = msg.properties.headers ?? {};\n let parentContext: Context | undefined = propagation.extract(\n ROOT_CONTEXT,\n headers\n );\n const exchange = msg.fields?.exchange;\n let links: Link[] | undefined;\n if (self._config.useLinksForConsume) {\n const parentSpanContext = parentContext\n ? trace.getSpan(parentContext)?.spanContext()\n : undefined;\n parentContext = undefined;\n if (parentSpanContext) {\n links = [\n {\n context: parentSpanContext,\n },\n ];\n }\n }\n const span = self.tracer.startSpan(\n `${queue} process`,\n {\n kind: SpanKind.CONSUMER,\n attributes: {\n ...channel?.connection?.[CONNECTION_ATTRIBUTES],\n [ATTR_MESSAGING_DESTINATION]: exchange,\n [ATTR_MESSAGING_DESTINATION_KIND]:\n MESSAGING_DESTINATION_KIND_VALUE_TOPIC,\n [ATTR_MESSAGING_RABBITMQ_ROUTING_KEY]: msg.fields?.routingKey,\n [ATTR_MESSAGING_OPERATION]: MESSAGING_OPERATION_VALUE_PROCESS,\n [OLD_ATTR_MESSAGING_MESSAGE_ID]: msg?.properties.messageId,\n [ATTR_MESSAGING_CONVERSATION_ID]: msg?.properties.correlationId,\n },\n links,\n },\n parentContext\n );\n\n const { consumeHook } = self.getConfig();\n if (consumeHook) {\n safeExecuteInTheMiddle(\n () => consumeHook(span, { moduleVersion, msg }),\n e => {\n if (e) {\n diag.error('amqplib instrumentation: consumerHook error', e);\n }\n },\n true\n );\n }\n\n if (!options?.noAck) {\n // store the message on the channel so we can close the span on ackAll etc\n channel[CHANNEL_SPANS_NOT_ENDED]!.push({\n msg,\n timeOfConsume: hrTime(),\n });\n\n // store the span on the message, so we can end it when user call 'ack' on it\n msg[MESSAGE_STORED_SPAN] = span;\n }\n const setContext: Context = parentContext\n ? parentContext\n : ROOT_CONTEXT;\n context.with(trace.setSpan(setContext, span), () => {\n onMessage.call(this, msg);\n });\n\n if (options?.noAck) {\n self.callConsumeEndHook(span, msg, false, EndOperation.AutoAck);\n span.end();\n }\n };\n arguments[1] = patchedOnMessage;\n return original.apply(this, arguments);\n };\n }\n\n private getConfirmedPublishPatch(\n moduleVersion: string | undefined,\n original: Function\n ) {\n const self = this;\n return function confirmedPublish(\n this: InstrumentationConsumeChannel,\n exchange: string,\n routingKey: string,\n content: Buffer,\n options?: Options.Publish,\n callback?: (err: any, ok: Replies.Empty) => void\n ): boolean {\n const channel = this;\n const { span, modifiedOptions } = self.createPublishSpan(\n self,\n exchange,\n routingKey,\n channel,\n options\n );\n\n const { publishHook } = self.getConfig();\n if (publishHook) {\n safeExecuteInTheMiddle(\n () =>\n publishHook(span, {\n moduleVersion,\n exchange,\n routingKey,\n content,\n options: modifiedOptions,\n isConfirmChannel: true,\n }),\n e => {\n if (e) {\n diag.error('amqplib instrumentation: publishHook error', e);\n }\n },\n true\n );\n }\n\n const patchedOnConfirm = function (\n this: unknown,\n err: any,\n ok: Replies.Empty\n ) {\n try {\n callback?.call(this, err, ok);\n } finally {\n const { publishConfirmHook } = self.getConfig();\n if (publishConfirmHook) {\n safeExecuteInTheMiddle(\n () =>\n publishConfirmHook(span, {\n moduleVersion,\n exchange,\n routingKey,\n content,\n options,\n isConfirmChannel: true,\n confirmError: err,\n }),\n e => {\n if (e) {\n diag.error(\n 'amqplib instrumentation: publishConfirmHook error',\n e\n );\n }\n },\n true\n );\n }\n\n if (err) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: \"message confirmation has been nack'ed\",\n });\n }\n span.end();\n }\n };\n\n // calling confirm channel publish function is storing the message in queue and registering the callback for broker confirm.\n // span ends in the patched callback.\n const markedContext = markConfirmChannelTracing(context.active());\n const argumentsCopy = [...arguments];\n argumentsCopy[3] = modifiedOptions;\n argumentsCopy[4] = context.bind(\n unmarkConfirmChannelTracing(trace.setSpan(markedContext, span)),\n patchedOnConfirm\n );\n return context.with(markedContext, original.bind(this, ...argumentsCopy));\n };\n }\n\n private getPublishPatch(\n moduleVersion: string | undefined,\n original: Function\n ) {\n const self = this;\n return function publish(\n this: InstrumentationPublishChannel,\n exchange: string,\n routingKey: string,\n content: Buffer,\n options?: Options.Publish\n ): boolean {\n if (isConfirmChannelTracing(context.active())) {\n // work already done\n return original.apply(this, arguments);\n } else {\n const channel = this;\n const { span, modifiedOptions } = self.createPublishSpan(\n self,\n exchange,\n routingKey,\n channel,\n options\n );\n\n const { publishHook } = self.getConfig();\n if (publishHook) {\n safeExecuteInTheMiddle(\n () =>\n publishHook(span, {\n moduleVersion,\n exchange,\n routingKey,\n content,\n options: modifiedOptions,\n isConfirmChannel: false,\n }),\n e => {\n if (e) {\n diag.error('amqplib instrumentation: publishHook error', e);\n }\n },\n true\n );\n }\n\n // calling normal channel publish function is only storing the message in queue.\n // it does not send it and waits for an ack, so the span duration is expected to be very short.\n const argumentsCopy = [...arguments];\n argumentsCopy[3] = modifiedOptions;\n const originalRes = original.apply(this, argumentsCopy as any);\n span.end();\n return originalRes;\n }\n };\n }\n\n private createPublishSpan(\n self: this,\n exchange: string,\n routingKey: string,\n channel: InstrumentationPublishChannel,\n options?: Options.Publish\n ) {\n const normalizedExchange = normalizeExchange(exchange);\n\n const span = self.tracer.startSpan(`publish ${normalizedExchange}`, {\n kind: SpanKind.PRODUCER,\n attributes: {\n ...channel.connection[CONNECTION_ATTRIBUTES],\n [ATTR_MESSAGING_DESTINATION]: exchange,\n [ATTR_MESSAGING_DESTINATION_KIND]:\n MESSAGING_DESTINATION_KIND_VALUE_TOPIC,\n\n [ATTR_MESSAGING_RABBITMQ_ROUTING_KEY]: routingKey,\n [OLD_ATTR_MESSAGING_MESSAGE_ID]: options?.messageId,\n [ATTR_MESSAGING_CONVERSATION_ID]: options?.correlationId,\n },\n });\n const modifiedOptions = options ?? {};\n modifiedOptions.headers = modifiedOptions.headers ?? {};\n\n propagation.inject(\n trace.setSpan(context.active(), span),\n modifiedOptions.headers\n );\n\n return { span, modifiedOptions };\n }\n\n private endConsumerSpan(\n message: InstrumentationMessage,\n isRejected: boolean | null,\n operation: EndOperation,\n requeue: boolean | undefined\n ) {\n const storedSpan: Span | undefined = message[MESSAGE_STORED_SPAN];\n if (!storedSpan) return;\n if (isRejected !== false) {\n storedSpan.setStatus({\n code: SpanStatusCode.ERROR,\n message:\n operation !== EndOperation.ChannelClosed &&\n operation !== EndOperation.ChannelError\n ? `${operation} called on message${\n requeue === true\n ? ' with requeue'\n : requeue === false\n ? ' without requeue'\n : ''\n }`\n : operation,\n });\n }\n this.callConsumeEndHook(storedSpan, message, isRejected, operation);\n storedSpan.end();\n message[MESSAGE_STORED_SPAN] = undefined;\n }\n\n private endAllSpansOnChannel(\n channel: InstrumentationConsumeChannel,\n isRejected: boolean,\n operation: EndOperation,\n requeue: boolean | undefined\n ) {\n const spansNotEnded: { msg: Message }[] =\n channel[CHANNEL_SPANS_NOT_ENDED] ?? [];\n spansNotEnded.forEach(msgDetails => {\n this.endConsumerSpan(msgDetails.msg, isRejected, operation, requeue);\n });\n channel[CHANNEL_SPANS_NOT_ENDED] = [];\n }\n\n private callConsumeEndHook(\n span: Span,\n msg: InstrumentationMessage,\n rejected: boolean | null,\n endOperation: EndOperation\n ) {\n const { consumeEndHook } = this.getConfig();\n if (!consumeEndHook) return;\n\n safeExecuteInTheMiddle(\n () => consumeEndHook(span, { msg, rejected, endOperation }),\n e => {\n if (e) {\n diag.error('amqplib instrumentation: consumerEndHook error', e);\n }\n },\n true\n );\n }\n\n private checkConsumeTimeoutOnChannel(channel: InstrumentationConsumeChannel) {\n const currentTime = hrTime();\n const spansNotEnded = channel[CHANNEL_SPANS_NOT_ENDED] ?? [];\n let i: number;\n const { consumeTimeoutMs } = this.getConfig();\n for (i = 0; i < spansNotEnded.length; i++) {\n const currMessage = spansNotEnded[i];\n const timeFromConsume = hrTimeDuration(\n currMessage.timeOfConsume,\n currentTime\n );\n if (hrTimeToMilliseconds(timeFromConsume) < consumeTimeoutMs!) {\n break;\n }\n this.endConsumerSpan(\n currMessage.msg,\n null,\n EndOperation.InstrumentationTimeout,\n true\n );\n }\n spansNotEnded.splice(0, i);\n }\n}\n"]}
1
+ {"version":3,"file":"amqplib.js","sourceRoot":"","sources":["../../src/amqplib.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,4CAW4B;AAC5B,8CAI6B;AAC7B,oEAQwC;AACxC,uCAAqD;AACrD,8DAQiC;AAQjC,mCAIiB;AACjB,mCAgBiB;AACjB,kBAAkB;AAClB,uCAA0D;AAE1D,MAAM,iBAAiB,GAAG,CAAC,YAAY,CAAC,CAAC;AAEzC,MAAa,sBAAuB,SAAQ,qCAAiD;IACnF,oBAAoB,CAAoB;IAEhD,YAAY,SAAuC,EAAE;QACnD,KAAK,CAAC,sBAAY,EAAE,yBAAe,EAAE,EAAE,GAAG,sBAAc,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;QACvE,IAAI,CAAC,2BAA2B,EAAE,CAAC;IACrC,CAAC;IAED,oBAAoB;IACZ,2BAA2B;QACjC,IAAI,CAAC,oBAA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AG,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,EAC3D,CAAC,CAAC,EAAE;YACF,IAAI,CAAC,EAAE;gBACL,UAAI,CAAC,KAAK,CAAC,gDAAgD,EAAE,CAAC,CAAC,CAAC;aACjE;QACH,CAAC,EACD,IAAI,CACL,CAAC;IACJ,CAAC;IAEO,4BAA4B,CAAC,OAAsC;QACzE,MAAM,WAAW,GAAG,IAAA,aAAM,GAAE,CAAC;QAC7B,MAAM,aAAa,GAAG,OAAO,CAAC,+BAAuB,CAAC,IAAI,EAAE,CAAC;QAC7D,IAAI,CAAS,CAAC;QACd,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC9C,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACzC,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YACrC,MAAM,eAAe,GAAG,IAAA,qBAAc,EACpC,WAAW,CAAC,aAAa,EACzB,WAAW,CACZ,CAAC;YACF,IAAI,IAAA,2BAAoB,EAAC,eAAe,CAAC,GAAG,gBAAiB,EAAE;gBAC7D,MAAM;aACP;YACD,IAAI,CAAC,eAAe,CAClB,WAAW,CAAC,GAAG,EACf,IAAI,EACJ,oBAAY,CAAC,sBAAsB,EACnC,IAAI,CACL,CAAC;SACH;QACD,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF;AAtrBD,wDAsrBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n context,\n diag,\n propagation,\n trace,\n Span,\n SpanKind,\n SpanStatusCode,\n ROOT_CONTEXT,\n Link,\n Context,\n} from '@opentelemetry/api';\nimport {\n hrTime,\n hrTimeDuration,\n hrTimeToMilliseconds,\n} from '@opentelemetry/core';\nimport {\n InstrumentationBase,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n SemconvStability,\n semconvStabilityFromStr,\n} from '@opentelemetry/instrumentation';\nimport { ATTR_MESSAGING_OPERATION } from './semconv';\nimport {\n ATTR_MESSAGING_DESTINATION,\n ATTR_MESSAGING_DESTINATION_KIND,\n ATTR_MESSAGING_RABBITMQ_ROUTING_KEY,\n MESSAGING_DESTINATION_KIND_VALUE_TOPIC,\n MESSAGING_OPERATION_VALUE_PROCESS,\n OLD_ATTR_MESSAGING_MESSAGE_ID,\n ATTR_MESSAGING_CONVERSATION_ID,\n} from '../src/semconv-obsolete';\nimport type {\n Connection,\n ConsumeMessage,\n Message,\n Options,\n Replies,\n} from 'amqplib';\nimport {\n AmqplibInstrumentationConfig,\n DEFAULT_CONFIG,\n EndOperation,\n} from './types';\nimport {\n CHANNEL_CONSUME_TIMEOUT_TIMER,\n CHANNEL_SPANS_NOT_ENDED,\n CONNECTION_ATTRIBUTES,\n getConnectionAttributesFromServer,\n getConnectionAttributesFromUrl,\n InstrumentationConnection,\n InstrumentationConsumeChannel,\n InstrumentationConsumeMessage,\n InstrumentationMessage,\n InstrumentationPublishChannel,\n isConfirmChannelTracing,\n markConfirmChannelTracing,\n MESSAGE_STORED_SPAN,\n normalizeExchange,\n unmarkConfirmChannelTracing,\n} from './utils';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\n\nconst supportedVersions = ['>=0.5.5 <2'];\n\nexport class AmqplibInstrumentation extends InstrumentationBase<AmqplibInstrumentationConfig> {\n private _netSemconvStability!: SemconvStability;\n\n constructor(config: AmqplibInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, { ...DEFAULT_CONFIG, ...config });\n this._setSemconvStabilityFromEnv();\n }\n\n // Used for testing.\n private _setSemconvStabilityFromEnv() {\n this._netSemconvStability = semconvStabilityFromStr(\n 'http',\n process.env.OTEL_SEMCONV_STABILITY_OPT_IN\n );\n }\n\n override setConfig(config: AmqplibInstrumentationConfig = {}) {\n super.setConfig({ ...DEFAULT_CONFIG, ...config });\n }\n\n protected init() {\n const channelModelModuleFile = new InstrumentationNodeModuleFile(\n 'amqplib/lib/channel_model.js',\n supportedVersions,\n this.patchChannelModel.bind(this),\n this.unpatchChannelModel.bind(this)\n );\n\n const callbackModelModuleFile = new InstrumentationNodeModuleFile(\n 'amqplib/lib/callback_model.js',\n supportedVersions,\n this.patchChannelModel.bind(this),\n this.unpatchChannelModel.bind(this)\n );\n\n const connectModuleFile = new InstrumentationNodeModuleFile(\n 'amqplib/lib/connect.js',\n supportedVersions,\n this.patchConnect.bind(this),\n this.unpatchConnect.bind(this)\n );\n\n const module = new InstrumentationNodeModuleDefinition(\n 'amqplib',\n supportedVersions,\n undefined,\n undefined,\n [channelModelModuleFile, connectModuleFile, callbackModelModuleFile]\n );\n return module;\n }\n\n private patchConnect(moduleExports: any) {\n moduleExports = this.unpatchConnect(moduleExports);\n if (!isWrapped(moduleExports.connect)) {\n this._wrap(moduleExports, 'connect', this.getConnectPatch.bind(this));\n }\n return moduleExports;\n }\n\n private unpatchConnect(moduleExports: any) {\n if (isWrapped(moduleExports.connect)) {\n this._unwrap(moduleExports, 'connect');\n }\n return moduleExports;\n }\n\n private patchChannelModel(\n moduleExports: any,\n moduleVersion: string | undefined\n ) {\n if (!isWrapped(moduleExports.Channel.prototype.publish)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'publish',\n this.getPublishPatch.bind(this, moduleVersion)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.consume)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'consume',\n this.getConsumePatch.bind(this, moduleVersion)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.ack)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'ack',\n this.getAckPatch.bind(this, false, EndOperation.Ack)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.nack)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'nack',\n this.getAckPatch.bind(this, true, EndOperation.Nack)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.reject)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'reject',\n this.getAckPatch.bind(this, true, EndOperation.Reject)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.ackAll)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'ackAll',\n this.getAckAllPatch.bind(this, false, EndOperation.AckAll)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.nackAll)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'nackAll',\n this.getAckAllPatch.bind(this, true, EndOperation.NackAll)\n );\n }\n if (!isWrapped(moduleExports.Channel.prototype.emit)) {\n this._wrap(\n moduleExports.Channel.prototype,\n 'emit',\n this.getChannelEmitPatch.bind(this)\n );\n }\n if (!isWrapped(moduleExports.ConfirmChannel.prototype.publish)) {\n this._wrap(\n moduleExports.ConfirmChannel.prototype,\n 'publish',\n this.getConfirmedPublishPatch.bind(this, moduleVersion)\n );\n }\n return moduleExports;\n }\n\n private unpatchChannelModel(moduleExports: any) {\n if (isWrapped(moduleExports.Channel.prototype.publish)) {\n this._unwrap(moduleExports.Channel.prototype, 'publish');\n }\n if (isWrapped(moduleExports.Channel.prototype.consume)) {\n this._unwrap(moduleExports.Channel.prototype, 'consume');\n }\n if (isWrapped(moduleExports.Channel.prototype.ack)) {\n this._unwrap(moduleExports.Channel.prototype, 'ack');\n }\n if (isWrapped(moduleExports.Channel.prototype.nack)) {\n this._unwrap(moduleExports.Channel.prototype, 'nack');\n }\n if (isWrapped(moduleExports.Channel.prototype.reject)) {\n this._unwrap(moduleExports.Channel.prototype, 'reject');\n }\n if (isWrapped(moduleExports.Channel.prototype.ackAll)) {\n this._unwrap(moduleExports.Channel.prototype, 'ackAll');\n }\n if (isWrapped(moduleExports.Channel.prototype.nackAll)) {\n this._unwrap(moduleExports.Channel.prototype, 'nackAll');\n }\n if (isWrapped(moduleExports.Channel.prototype.emit)) {\n this._unwrap(moduleExports.Channel.prototype, 'emit');\n }\n if (isWrapped(moduleExports.ConfirmChannel.prototype.publish)) {\n this._unwrap(moduleExports.ConfirmChannel.prototype, 'publish');\n }\n return moduleExports;\n }\n\n private getConnectPatch(\n original: (\n url: string | Options.Connect,\n socketOptions: any,\n openCallback: (err: any, connection: Connection) => void\n ) => Connection\n ) {\n const self = this;\n return function patchedConnect(\n this: unknown,\n url: string | Options.Connect,\n socketOptions: any,\n openCallback: Function\n ) {\n return original.call(\n this,\n url,\n socketOptions,\n function (this: unknown, err, conn: InstrumentationConnection) {\n if (err == null) {\n const urlAttributes = getConnectionAttributesFromUrl(\n url,\n self._netSemconvStability\n );\n const serverAttributes = getConnectionAttributesFromServer(conn);\n conn[CONNECTION_ATTRIBUTES] = {\n ...urlAttributes,\n ...serverAttributes,\n };\n }\n openCallback.apply(this, arguments);\n }\n );\n };\n }\n\n private getChannelEmitPatch(original: Function) {\n const self = this;\n return function emit(\n this: InstrumentationConsumeChannel,\n eventName: string\n ) {\n if (eventName === 'close') {\n self.endAllSpansOnChannel(\n this,\n true,\n EndOperation.ChannelClosed,\n undefined\n );\n const activeTimer = this[CHANNEL_CONSUME_TIMEOUT_TIMER];\n if (activeTimer) {\n clearInterval(activeTimer);\n }\n this[CHANNEL_CONSUME_TIMEOUT_TIMER] = undefined;\n } else if (eventName === 'error') {\n self.endAllSpansOnChannel(\n this,\n true,\n EndOperation.ChannelError,\n undefined\n );\n }\n return original.apply(this, arguments);\n };\n }\n\n private getAckAllPatch(\n isRejected: boolean,\n endOperation: EndOperation,\n original: Function\n ) {\n const self = this;\n return function ackAll(\n this: InstrumentationConsumeChannel,\n requeueOrEmpty?: boolean\n ): void {\n self.endAllSpansOnChannel(this, isRejected, endOperation, requeueOrEmpty);\n return original.apply(this, arguments);\n };\n }\n\n private getAckPatch(\n isRejected: boolean,\n endOperation: EndOperation,\n original: Function\n ) {\n const self = this;\n return function ack(\n this: InstrumentationConsumeChannel,\n message: Message,\n allUpToOrRequeue?: boolean,\n requeue?: boolean\n ): void {\n const channel = this;\n // we use this patch in reject function as well, but it has different signature\n const requeueResolved =\n endOperation === EndOperation.Reject ? allUpToOrRequeue : requeue;\n\n const spansNotEnded: { msg: Message }[] =\n channel[CHANNEL_SPANS_NOT_ENDED] ?? [];\n const msgIndex = spansNotEnded.findIndex(\n msgDetails => msgDetails.msg === message\n );\n if (msgIndex < 0) {\n // should not happen in happy flow\n // but possible if user is calling the api function ack twice with same message\n self.endConsumerSpan(\n message,\n isRejected,\n endOperation,\n requeueResolved\n );\n } else if (endOperation !== EndOperation.Reject && allUpToOrRequeue) {\n for (let i = 0; i <= msgIndex; i++) {\n self.endConsumerSpan(\n spansNotEnded[i].msg,\n isRejected,\n endOperation,\n requeueResolved\n );\n }\n spansNotEnded.splice(0, msgIndex + 1);\n } else {\n self.endConsumerSpan(\n message,\n isRejected,\n endOperation,\n requeueResolved\n );\n spansNotEnded.splice(msgIndex, 1);\n }\n return original.apply(this, arguments);\n };\n }\n\n private getConsumePatch(\n moduleVersion: string | undefined,\n original: Function\n ) {\n const self = this;\n return function consume(\n this: InstrumentationConsumeChannel,\n queue: string,\n onMessage: (msg: ConsumeMessage | null) => void,\n options?: Options.Consume\n ): Promise<Replies.Consume> {\n const channel = this;\n if (\n !Object.prototype.hasOwnProperty.call(channel, CHANNEL_SPANS_NOT_ENDED)\n ) {\n const { consumeTimeoutMs } = self.getConfig();\n if (consumeTimeoutMs) {\n const timer = setInterval(() => {\n self.checkConsumeTimeoutOnChannel(channel);\n }, consumeTimeoutMs);\n timer.unref();\n channel[CHANNEL_CONSUME_TIMEOUT_TIMER] = timer;\n }\n channel[CHANNEL_SPANS_NOT_ENDED] = [];\n }\n\n const patchedOnMessage = function (\n this: unknown,\n msg: InstrumentationConsumeMessage | null\n ) {\n // msg is expected to be null for signaling consumer cancel notification\n // https://www.rabbitmq.com/consumer-cancel.html\n // in this case, we do not start a span, as this is not a real message.\n if (!msg) {\n return onMessage.call(this, msg);\n }\n\n const headers = msg.properties.headers ?? {};\n let parentContext: Context | undefined = propagation.extract(\n ROOT_CONTEXT,\n headers\n );\n const exchange = msg.fields?.exchange;\n let links: Link[] | undefined;\n if (self._config.useLinksForConsume) {\n const parentSpanContext = parentContext\n ? trace.getSpan(parentContext)?.spanContext()\n : undefined;\n parentContext = undefined;\n if (parentSpanContext) {\n links = [\n {\n context: parentSpanContext,\n },\n ];\n }\n }\n const span = self.tracer.startSpan(\n `${queue} process`,\n {\n kind: SpanKind.CONSUMER,\n attributes: {\n ...channel?.connection?.[CONNECTION_ATTRIBUTES],\n [ATTR_MESSAGING_DESTINATION]: exchange,\n [ATTR_MESSAGING_DESTINATION_KIND]:\n MESSAGING_DESTINATION_KIND_VALUE_TOPIC,\n [ATTR_MESSAGING_RABBITMQ_ROUTING_KEY]: msg.fields?.routingKey,\n [ATTR_MESSAGING_OPERATION]: MESSAGING_OPERATION_VALUE_PROCESS,\n [OLD_ATTR_MESSAGING_MESSAGE_ID]: msg?.properties.messageId,\n [ATTR_MESSAGING_CONVERSATION_ID]: msg?.properties.correlationId,\n },\n links,\n },\n parentContext\n );\n\n const { consumeHook } = self.getConfig();\n if (consumeHook) {\n safeExecuteInTheMiddle(\n () => consumeHook(span, { moduleVersion, msg }),\n e => {\n if (e) {\n diag.error('amqplib instrumentation: consumerHook error', e);\n }\n },\n true\n );\n }\n\n if (!options?.noAck) {\n // store the message on the channel so we can close the span on ackAll etc\n channel[CHANNEL_SPANS_NOT_ENDED]!.push({\n msg,\n timeOfConsume: hrTime(),\n });\n\n // store the span on the message, so we can end it when user call 'ack' on it\n msg[MESSAGE_STORED_SPAN] = span;\n }\n const setContext: Context = parentContext\n ? parentContext\n : ROOT_CONTEXT;\n context.with(trace.setSpan(setContext, span), () => {\n onMessage.call(this, msg);\n });\n\n if (options?.noAck) {\n self.callConsumeEndHook(span, msg, false, EndOperation.AutoAck);\n span.end();\n }\n };\n arguments[1] = patchedOnMessage;\n return original.apply(this, arguments);\n };\n }\n\n private getConfirmedPublishPatch(\n moduleVersion: string | undefined,\n original: Function\n ) {\n const self = this;\n return function confirmedPublish(\n this: InstrumentationConsumeChannel,\n exchange: string,\n routingKey: string,\n content: Buffer,\n options?: Options.Publish,\n callback?: (err: any, ok: Replies.Empty) => void\n ): boolean {\n const channel = this;\n const { span, modifiedOptions } = self.createPublishSpan(\n self,\n exchange,\n routingKey,\n channel,\n options\n );\n\n const { publishHook } = self.getConfig();\n if (publishHook) {\n safeExecuteInTheMiddle(\n () =>\n publishHook(span, {\n moduleVersion,\n exchange,\n routingKey,\n content,\n options: modifiedOptions,\n isConfirmChannel: true,\n }),\n e => {\n if (e) {\n diag.error('amqplib instrumentation: publishHook error', e);\n }\n },\n true\n );\n }\n\n const patchedOnConfirm = function (\n this: unknown,\n err: any,\n ok: Replies.Empty\n ) {\n try {\n callback?.call(this, err, ok);\n } finally {\n const { publishConfirmHook } = self.getConfig();\n if (publishConfirmHook) {\n safeExecuteInTheMiddle(\n () =>\n publishConfirmHook(span, {\n moduleVersion,\n exchange,\n routingKey,\n content,\n options,\n isConfirmChannel: true,\n confirmError: err,\n }),\n e => {\n if (e) {\n diag.error(\n 'amqplib instrumentation: publishConfirmHook error',\n e\n );\n }\n },\n true\n );\n }\n\n if (err) {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: \"message confirmation has been nack'ed\",\n });\n }\n span.end();\n }\n };\n\n // calling confirm channel publish function is storing the message in queue and registering the callback for broker confirm.\n // span ends in the patched callback.\n const markedContext = markConfirmChannelTracing(context.active());\n const argumentsCopy = [...arguments];\n argumentsCopy[3] = modifiedOptions;\n argumentsCopy[4] = context.bind(\n unmarkConfirmChannelTracing(trace.setSpan(markedContext, span)),\n patchedOnConfirm\n );\n return context.with(markedContext, original.bind(this, ...argumentsCopy));\n };\n }\n\n private getPublishPatch(\n moduleVersion: string | undefined,\n original: Function\n ) {\n const self = this;\n return function publish(\n this: InstrumentationPublishChannel,\n exchange: string,\n routingKey: string,\n content: Buffer,\n options?: Options.Publish\n ): boolean {\n if (isConfirmChannelTracing(context.active())) {\n // work already done\n return original.apply(this, arguments);\n } else {\n const channel = this;\n const { span, modifiedOptions } = self.createPublishSpan(\n self,\n exchange,\n routingKey,\n channel,\n options\n );\n\n const { publishHook } = self.getConfig();\n if (publishHook) {\n safeExecuteInTheMiddle(\n () =>\n publishHook(span, {\n moduleVersion,\n exchange,\n routingKey,\n content,\n options: modifiedOptions,\n isConfirmChannel: false,\n }),\n e => {\n if (e) {\n diag.error('amqplib instrumentation: publishHook error', e);\n }\n },\n true\n );\n }\n\n // calling normal channel publish function is only storing the message in queue.\n // it does not send it and waits for an ack, so the span duration is expected to be very short.\n const argumentsCopy = [...arguments];\n argumentsCopy[3] = modifiedOptions;\n const originalRes = original.apply(this, argumentsCopy as any);\n span.end();\n return originalRes;\n }\n };\n }\n\n private createPublishSpan(\n self: this,\n exchange: string,\n routingKey: string,\n channel: InstrumentationPublishChannel,\n options?: Options.Publish\n ) {\n const normalizedExchange = normalizeExchange(exchange);\n\n const span = self.tracer.startSpan(`publish ${normalizedExchange}`, {\n kind: SpanKind.PRODUCER,\n attributes: {\n ...channel.connection[CONNECTION_ATTRIBUTES],\n [ATTR_MESSAGING_DESTINATION]: exchange,\n [ATTR_MESSAGING_DESTINATION_KIND]:\n MESSAGING_DESTINATION_KIND_VALUE_TOPIC,\n\n [ATTR_MESSAGING_RABBITMQ_ROUTING_KEY]: routingKey,\n [OLD_ATTR_MESSAGING_MESSAGE_ID]: options?.messageId,\n [ATTR_MESSAGING_CONVERSATION_ID]: options?.correlationId,\n },\n });\n const modifiedOptions = options ?? {};\n modifiedOptions.headers = modifiedOptions.headers ?? {};\n\n propagation.inject(\n trace.setSpan(context.active(), span),\n modifiedOptions.headers\n );\n\n return { span, modifiedOptions };\n }\n\n private endConsumerSpan(\n message: InstrumentationMessage,\n isRejected: boolean | null,\n operation: EndOperation,\n requeue: boolean | undefined\n ) {\n const storedSpan: Span | undefined = message[MESSAGE_STORED_SPAN];\n if (!storedSpan) return;\n if (isRejected !== false) {\n storedSpan.setStatus({\n code: SpanStatusCode.ERROR,\n message:\n operation !== EndOperation.ChannelClosed &&\n operation !== EndOperation.ChannelError\n ? `${operation} called on message${\n requeue === true\n ? ' with requeue'\n : requeue === false\n ? ' without requeue'\n : ''\n }`\n : operation,\n });\n }\n this.callConsumeEndHook(storedSpan, message, isRejected, operation);\n storedSpan.end();\n message[MESSAGE_STORED_SPAN] = undefined;\n }\n\n private endAllSpansOnChannel(\n channel: InstrumentationConsumeChannel,\n isRejected: boolean,\n operation: EndOperation,\n requeue: boolean | undefined\n ) {\n const spansNotEnded: { msg: Message }[] =\n channel[CHANNEL_SPANS_NOT_ENDED] ?? [];\n spansNotEnded.forEach(msgDetails => {\n this.endConsumerSpan(msgDetails.msg, isRejected, operation, requeue);\n });\n channel[CHANNEL_SPANS_NOT_ENDED] = [];\n }\n\n private callConsumeEndHook(\n span: Span,\n msg: InstrumentationMessage,\n rejected: boolean | null,\n endOperation: EndOperation\n ) {\n const { consumeEndHook } = this.getConfig();\n if (!consumeEndHook) return;\n\n safeExecuteInTheMiddle(\n () => consumeEndHook(span, { msg, rejected, endOperation }),\n e => {\n if (e) {\n diag.error('amqplib instrumentation: consumerEndHook error', e);\n }\n },\n true\n );\n }\n\n private checkConsumeTimeoutOnChannel(channel: InstrumentationConsumeChannel) {\n const currentTime = hrTime();\n const spansNotEnded = channel[CHANNEL_SPANS_NOT_ENDED] ?? [];\n let i: number;\n const { consumeTimeoutMs } = this.getConfig();\n for (i = 0; i < spansNotEnded.length; i++) {\n const currMessage = spansNotEnded[i];\n const timeFromConsume = hrTimeDuration(\n currMessage.timeOfConsume,\n currentTime\n );\n if (hrTimeToMilliseconds(timeFromConsume) < consumeTimeoutMs!) {\n break;\n }\n this.endConsumerSpan(\n currMessage.msg,\n null,\n EndOperation.InstrumentationTimeout,\n true\n );\n }\n spansNotEnded.splice(0, i);\n }\n}\n"]}
@@ -3,18 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EndOperation = exports.DEFAULT_CONFIG = exports.AmqplibInstrumentation = void 0;
4
4
  /*
5
5
  * Copyright The OpenTelemetry Authors
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * https://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
6
+ * SPDX-License-Identifier: Apache-2.0
18
7
  */
19
8
  var amqplib_1 = require("./amqplib");
20
9
  Object.defineProperty(exports, "AmqplibInstrumentation", { enumerable: true, get: function () { return amqplib_1.AmqplibInstrumentation; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,qCAAmD;AAA1C,iHAAA,sBAAsB,OAAA;AAC/B,iCAAuD;AAA9C,uGAAA,cAAc,OAAA;AAAE,qGAAA,YAAY,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 */\nexport { AmqplibInstrumentation } from './amqplib';\nexport { DEFAULT_CONFIG, EndOperation } from './types';\nexport type {\n AmqplibConsumeCustomAttributeFunction,\n AmqplibConsumeEndCustomAttributeFunction,\n AmqplibInstrumentationConfig,\n AmqplibPublishConfirmCustomAttributeFunction,\n AmqplibPublishCustomAttributeFunction,\n AmqplibPublishOptions,\n CommonMessageFields,\n ConsumeEndInfo,\n ConsumeInfo,\n ConsumeMessage,\n ConsumeMessageFields,\n Message,\n MessageFields,\n MessageProperties,\n PublishConfirmedInfo,\n PublishInfo,\n} from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,qCAAmD;AAA1C,iHAAA,sBAAsB,OAAA;AAC/B,iCAAuD;AAA9C,uGAAA,cAAc,OAAA;AAAE,qGAAA,YAAY,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nexport { AmqplibInstrumentation } from './amqplib';\nexport { DEFAULT_CONFIG, EndOperation } from './types';\nexport type {\n AmqplibConsumeCustomAttributeFunction,\n AmqplibConsumeEndCustomAttributeFunction,\n AmqplibInstrumentationConfig,\n AmqplibPublishConfirmCustomAttributeFunction,\n AmqplibPublishCustomAttributeFunction,\n AmqplibPublishOptions,\n CommonMessageFields,\n ConsumeEndInfo,\n ConsumeInfo,\n ConsumeMessage,\n ConsumeMessageFields,\n Message,\n MessageFields,\n MessageProperties,\n PublishConfirmedInfo,\n PublishInfo,\n} from './types';\n"]}
@@ -1,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.ATTR_MESSAGING_CONVERSATION_ID = exports.OLD_ATTR_MESSAGING_MESSAGE_ID = exports.MESSAGING_DESTINATION_KIND_VALUE_TOPIC = exports.ATTR_MESSAGING_URL = exports.ATTR_MESSAGING_PROTOCOL_VERSION = exports.ATTR_MESSAGING_PROTOCOL = exports.MESSAGING_OPERATION_VALUE_PROCESS = exports.ATTR_MESSAGING_RABBITMQ_ROUTING_KEY = exports.ATTR_MESSAGING_DESTINATION_KIND = exports.ATTR_MESSAGING_DESTINATION = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"semconv-obsolete.js","sourceRoot":"","sources":["../../src/semconv-obsolete.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;;;;GAOG;AAEH;;;;GAIG;AACU,QAAA,0BAA0B,GAAG,uBAAgC,CAAC;AAE3E;;;;GAIG;AACU,QAAA,+BAA+B,GAC1C,4BAAqC,CAAC;AAExC;;;;GAIG;AACU,QAAA,mCAAmC,GAC9C,gCAAyC,CAAC;AAE5C;;;;GAIG;AACU,QAAA,iCAAiC,GAAG,SAAkB,CAAC;AAEpE;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,oBAA6B,CAAC;AAErE;;;;GAIG;AACU,QAAA,+BAA+B,GAC1C,4BAAqC,CAAC;AAExC;;;;GAIG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;GAIG;AACU,QAAA,sCAAsC,GAAG,OAAgB,CAAC;AAEvE;;;;;;GAMG;AACU,QAAA,6BAA6B,GAAG,sBAA+B,CAAC;AAE7E;;;;GAIG;AACU,QAAA,8BAA8B,GACzC,2BAAoC,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/*\n * This file contains constants for values that where replaced/removed from\n * Semantic Conventions long enough ago that they do not have `ATTR_*`\n * constants in the `@opentelemetry/semantic-conventions` package. Eventually\n * it is expected that this instrumention will be updated to emit telemetry\n * using modern Semantic Conventions, dropping the need for the constants in\n * this file.\n */\n\n/**\n * The message destination name. This might be equal to the span name but is required nevertheless.\n *\n * @deprecated Use ATTR_MESSAGING_DESTINATION_NAME in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n */\nexport const ATTR_MESSAGING_DESTINATION = 'messaging.destination' as const;\n\n/**\n * The kind of message destination.\n *\n * @deprecated Removed in semconv v1.20.0.\n */\nexport const ATTR_MESSAGING_DESTINATION_KIND =\n 'messaging.destination_kind' as const;\n\n/**\n * RabbitMQ message routing key.\n *\n * @deprecated Use ATTR_MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n */\nexport const ATTR_MESSAGING_RABBITMQ_ROUTING_KEY =\n 'messaging.rabbitmq.routing_key' as const;\n\n/**\n * A string identifying the kind of message consumption as defined in the [Operation names](#operation-names) section above. If the operation is &#34;send&#34;, this attribute MUST NOT be set, since the operation can be inferred from the span kind in that case.\n *\n * @deprecated Use MESSAGING_OPERATION_TYPE_VALUE_PROCESS in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n */\nexport const MESSAGING_OPERATION_VALUE_PROCESS = 'process' as const;\n\n/**\n * The name of the transport protocol.\n *\n * @deprecated Use ATTR_NETWORK_PROTOCOL_NAME.\n */\nexport const ATTR_MESSAGING_PROTOCOL = 'messaging.protocol' as const;\n\n/**\n * The version of the transport protocol.\n *\n * @deprecated Use ATTR_NETWORK_PROTOCOL_VERSION.\n */\nexport const ATTR_MESSAGING_PROTOCOL_VERSION =\n 'messaging.protocol_version' as const;\n\n/**\n * Connection string.\n *\n * @deprecated Removed in semconv v1.17.0.\n */\nexport const ATTR_MESSAGING_URL = 'messaging.url' as const;\n\n/**\n * The kind of message destination.\n *\n * @deprecated Removed in semconv v1.20.0.\n */\nexport const MESSAGING_DESTINATION_KIND_VALUE_TOPIC = 'topic' as const;\n\n/**\n * A value used by the messaging system as an identifier for the message, represented as a string.\n *\n * @deprecated Use ATTR_MESSAGING_MESSAGE_ID in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n *\n * Note: changing to `ATTR_MESSAGING_MESSAGE_ID` means a change in value from `messaging.message_id` to `messaging.message.id`.\n */\nexport const OLD_ATTR_MESSAGING_MESSAGE_ID = 'messaging.message_id' as const;\n\n/**\n * The [conversation ID](#conversations) identifying the conversation to which the message belongs, represented as a string. Sometimes called &#34;Correlation ID&#34;.\n *\n * @deprecated Use ATTR_MESSAGING_MESSAGE_CONVERSATION_ID in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n */\nexport const ATTR_MESSAGING_CONVERSATION_ID =\n 'messaging.conversation_id' as const;\n"]}
1
+ {"version":3,"file":"semconv-obsolete.js","sourceRoot":"","sources":["../../src/semconv-obsolete.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;GAOG;AAEH;;;;GAIG;AACU,QAAA,0BAA0B,GAAG,uBAAgC,CAAC;AAE3E;;;;GAIG;AACU,QAAA,+BAA+B,GAC1C,4BAAqC,CAAC;AAExC;;;;GAIG;AACU,QAAA,mCAAmC,GAC9C,gCAAyC,CAAC;AAE5C;;;;GAIG;AACU,QAAA,iCAAiC,GAAG,SAAkB,CAAC;AAEpE;;;;GAIG;AACU,QAAA,uBAAuB,GAAG,oBAA6B,CAAC;AAErE;;;;GAIG;AACU,QAAA,+BAA+B,GAC1C,4BAAqC,CAAC;AAExC;;;;GAIG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;GAIG;AACU,QAAA,sCAAsC,GAAG,OAAgB,CAAC;AAEvE;;;;;;GAMG;AACU,QAAA,6BAA6B,GAAG,sBAA+B,CAAC;AAE7E;;;;GAIG;AACU,QAAA,8BAA8B,GACzC,2BAAoC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/*\n * This file contains constants for values that where replaced/removed from\n * Semantic Conventions long enough ago that they do not have `ATTR_*`\n * constants in the `@opentelemetry/semantic-conventions` package. Eventually\n * it is expected that this instrumention will be updated to emit telemetry\n * using modern Semantic Conventions, dropping the need for the constants in\n * this file.\n */\n\n/**\n * The message destination name. This might be equal to the span name but is required nevertheless.\n *\n * @deprecated Use ATTR_MESSAGING_DESTINATION_NAME in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n */\nexport const ATTR_MESSAGING_DESTINATION = 'messaging.destination' as const;\n\n/**\n * The kind of message destination.\n *\n * @deprecated Removed in semconv v1.20.0.\n */\nexport const ATTR_MESSAGING_DESTINATION_KIND =\n 'messaging.destination_kind' as const;\n\n/**\n * RabbitMQ message routing key.\n *\n * @deprecated Use ATTR_MESSAGING_RABBITMQ_DESTINATION_ROUTING_KEY in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n */\nexport const ATTR_MESSAGING_RABBITMQ_ROUTING_KEY =\n 'messaging.rabbitmq.routing_key' as const;\n\n/**\n * A string identifying the kind of message consumption as defined in the [Operation names](#operation-names) section above. If the operation is &#34;send&#34;, this attribute MUST NOT be set, since the operation can be inferred from the span kind in that case.\n *\n * @deprecated Use MESSAGING_OPERATION_TYPE_VALUE_PROCESS in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n */\nexport const MESSAGING_OPERATION_VALUE_PROCESS = 'process' as const;\n\n/**\n * The name of the transport protocol.\n *\n * @deprecated Use ATTR_NETWORK_PROTOCOL_NAME.\n */\nexport const ATTR_MESSAGING_PROTOCOL = 'messaging.protocol' as const;\n\n/**\n * The version of the transport protocol.\n *\n * @deprecated Use ATTR_NETWORK_PROTOCOL_VERSION.\n */\nexport const ATTR_MESSAGING_PROTOCOL_VERSION =\n 'messaging.protocol_version' as const;\n\n/**\n * Connection string.\n *\n * @deprecated Removed in semconv v1.17.0.\n */\nexport const ATTR_MESSAGING_URL = 'messaging.url' as const;\n\n/**\n * The kind of message destination.\n *\n * @deprecated Removed in semconv v1.20.0.\n */\nexport const MESSAGING_DESTINATION_KIND_VALUE_TOPIC = 'topic' as const;\n\n/**\n * A value used by the messaging system as an identifier for the message, represented as a string.\n *\n * @deprecated Use ATTR_MESSAGING_MESSAGE_ID in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n *\n * Note: changing to `ATTR_MESSAGING_MESSAGE_ID` means a change in value from `messaging.message_id` to `messaging.message.id`.\n */\nexport const OLD_ATTR_MESSAGING_MESSAGE_ID = 'messaging.message_id' as const;\n\n/**\n * The [conversation ID](#conversations) identifying the conversation to which the message belongs, represented as a string. Sometimes called &#34;Correlation ID&#34;.\n *\n * @deprecated Use ATTR_MESSAGING_MESSAGE_CONVERSATION_ID in [incubating entry-point]({@link https://github.com/open-telemetry/opentelemetry-js/blob/main/semantic-conventions/README.md#unstable-semconv}).\n */\nexport const ATTR_MESSAGING_CONVERSATION_ID =\n 'messaging.conversation_id' as const;\n"]}
@@ -1,18 +1,7 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.ATTR_NET_PEER_PORT = exports.ATTR_NET_PEER_NAME = exports.ATTR_MESSAGING_SYSTEM = exports.ATTR_MESSAGING_OPERATION = void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH;;;;;;;;;;GAUG;AACU,QAAA,wBAAwB,GAAG,qBAA8B,CAAC;AAEvE;;;;;;GAMG;AACU,QAAA,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,eAAwB,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/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Deprecated, use `messaging.operation.type` instead.\n *\n * @example publish\n * @example create\n * @example process\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `messaging.operation.type`.\n */\nexport const ATTR_MESSAGING_OPERATION = 'messaging.operation' as const;\n\n/**\n * The messaging system as identified by the client instrumentation.\n *\n * @note The actual messaging system may differ from the one known by the client. For example, when using Kafka client libraries to communicate with Azure Event Hubs, the `messaging.system` is set to `kafka` based on the instrumentation's best knowledge.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_SYSTEM = 'messaging.system' as const;\n\n/**\n * Deprecated, use `server.address` on client spans and `client.address` on server spans.\n *\n * @example example.com\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.address` on client spans and `client.address` on server spans.\n */\nexport const ATTR_NET_PEER_NAME = 'net.peer.name' as const;\n\n/**\n * Deprecated, use `server.port` on client spans and `client.port` on server spans.\n *\n * @example 8080\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.port` on client spans and `client.port` on server spans.\n */\nexport const ATTR_NET_PEER_PORT = 'net.peer.port' as const;\n"]}
1
+ {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH;;;;;;;;;;GAUG;AACU,QAAA,wBAAwB,GAAG,qBAA8B,CAAC;AAEvE;;;;;;GAMG;AACU,QAAA,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;;;GAQG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Deprecated, use `messaging.operation.type` instead.\n *\n * @example publish\n * @example create\n * @example process\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `messaging.operation.type`.\n */\nexport const ATTR_MESSAGING_OPERATION = 'messaging.operation' as const;\n\n/**\n * The messaging system as identified by the client instrumentation.\n *\n * @note The actual messaging system may differ from the one known by the client. For example, when using Kafka client libraries to communicate with Azure Event Hubs, the `messaging.system` is set to `kafka` based on the instrumentation's best knowledge.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_SYSTEM = 'messaging.system' as const;\n\n/**\n * Deprecated, use `server.address` on client spans and `client.address` on server spans.\n *\n * @example example.com\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.address` on client spans and `client.address` on server spans.\n */\nexport const ATTR_NET_PEER_NAME = 'net.peer.name' as const;\n\n/**\n * Deprecated, use `server.port` on client spans and `client.port` on server spans.\n *\n * @example 8080\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `server.port` on client spans and `client.port` on server spans.\n */\nexport const ATTR_NET_PEER_PORT = 'net.peer.port' as const;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AA0DA,IAAY,YAUX;AAVD,WAAY,YAAY;IACtB,oCAAoB,CAAA;IACpB,2BAAW,CAAA;IACX,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,gDAAgC,CAAA;IAChC,8CAA8B,CAAA;IAC9B,kEAAkD,CAAA;AACpD,CAAC,EAVW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAUvB;AAmCY,QAAA,cAAc,GAAiC;IAC1D,gBAAgB,EAAE,IAAI,GAAG,EAAE;IAC3B,kBAAkB,EAAE,KAAK;CAC1B,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 { Span } from '@opentelemetry/api';\nimport { InstrumentationConfig } from '@opentelemetry/instrumentation';\n\nexport interface PublishInfo {\n moduleVersion: string | undefined;\n exchange: string;\n routingKey: string;\n content: Buffer;\n options?: AmqplibPublishOptions;\n isConfirmChannel?: boolean;\n}\n\nexport interface PublishConfirmedInfo extends PublishInfo {\n confirmError?: any;\n}\n\nexport interface ConsumeInfo {\n moduleVersion: string | undefined;\n msg: ConsumeMessage;\n}\n\nexport interface ConsumeEndInfo {\n msg: ConsumeMessage;\n rejected: boolean | null;\n endOperation: EndOperation;\n}\n\nexport interface AmqplibPublishCustomAttributeFunction {\n (span: Span, publishInfo: PublishInfo): void;\n}\n\nexport interface AmqplibPublishConfirmCustomAttributeFunction {\n (span: Span, publishConfirmedInto: PublishConfirmedInfo): void;\n}\n\nexport interface AmqplibConsumeCustomAttributeFunction {\n (span: Span, consumeInfo: ConsumeInfo): void;\n}\n\nexport interface AmqplibConsumeEndCustomAttributeFunction {\n (span: Span, consumeEndInfo: ConsumeEndInfo): void;\n}\n\nexport enum EndOperation {\n AutoAck = 'auto ack',\n Ack = 'ack',\n AckAll = 'ackAll',\n Reject = 'reject',\n Nack = 'nack',\n NackAll = 'nackAll',\n ChannelClosed = 'channel closed',\n ChannelError = 'channel error',\n InstrumentationTimeout = 'instrumentation timeout',\n}\n\nexport interface AmqplibInstrumentationConfig extends InstrumentationConfig {\n /** hook for adding custom attributes before publish message is sent */\n publishHook?: AmqplibPublishCustomAttributeFunction;\n\n /** hook for adding custom attributes after publish message is confirmed by the broker */\n publishConfirmHook?: AmqplibPublishConfirmCustomAttributeFunction;\n\n /** hook for adding custom attributes before consumer message is processed */\n consumeHook?: AmqplibConsumeCustomAttributeFunction;\n\n /** hook for adding custom attributes after consumer message is acked to server */\n consumeEndHook?: AmqplibConsumeEndCustomAttributeFunction;\n\n /**\n * When user is setting up consume callback, it is user's responsibility to call\n * ack/nack etc on the msg to resolve it in the server.\n * If user is not calling the ack, the message will stay in the queue until\n * channel is closed, or until server timeout expires (if configured).\n * While we wait for the ack, a reference to the message is stored in plugin, which\n * will never be garbage collected.\n * To prevent memory leak, plugin has it's own configuration of timeout, which\n * will close the span if user did not call ack after this timeout.\n * If timeout is not big enough, span might be closed with 'InstrumentationTimeout',\n * and then received valid ack from the user later which will not be instrumented.\n *\n * Default is 1 minute\n */\n consumeTimeoutMs?: number;\n\n /** option to use a span link for the consume message instead of continuing a trace */\n useLinksForConsume?: boolean;\n}\n\nexport const DEFAULT_CONFIG: AmqplibInstrumentationConfig = {\n consumeTimeoutMs: 1000 * 60, // 1 minute\n useLinksForConsume: false,\n};\n\n// The following types are vendored from `@types/amqplib@0.10.1` - commit SHA: 4205e03127692a40b4871709a7134fe4e2ed5510\n\n// Vendored from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/4205e03127692a40b4871709a7134fe4e2ed5510/types/amqplib/properties.d.ts#L108\n// This exists in `@types/amqplib` as `Options.Publish`. We're renaming things\n// here to avoid importing the whole Options namespace.\nexport interface AmqplibPublishOptions {\n expiration?: string | number;\n userId?: string;\n CC?: string | string[];\n\n mandatory?: boolean;\n persistent?: boolean;\n deliveryMode?: boolean | number;\n BCC?: string | string[];\n\n contentType?: string;\n contentEncoding?: string;\n headers?: any;\n priority?: number;\n correlationId?: string;\n replyTo?: string;\n messageId?: string;\n timestamp?: number;\n type?: string;\n appId?: string;\n}\n\n// Vendored from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/4205e03127692a40b4871709a7134fe4e2ed5510/types/amqplib/properties.d.ts#L142\nexport interface Message {\n content: Buffer;\n fields: MessageFields;\n properties: MessageProperties;\n}\n\nexport interface ConsumeMessage extends Message {\n fields: ConsumeMessageFields;\n}\n\nexport interface CommonMessageFields {\n deliveryTag: number;\n redelivered: boolean;\n exchange: string;\n routingKey: string;\n}\n\nexport interface MessageFields extends CommonMessageFields {\n messageCount?: number;\n consumerTag?: string;\n}\n\nexport interface ConsumeMessageFields extends CommonMessageFields {\n deliveryTag: number;\n}\n\nexport interface MessageProperties {\n contentType: any | undefined;\n contentEncoding: any | undefined;\n headers: any;\n deliveryMode: any | undefined;\n priority: any | undefined;\n correlationId: any | undefined;\n replyTo: any | undefined;\n expiration: any | undefined;\n messageId: any | undefined;\n timestamp: any | undefined;\n type: any | undefined;\n userId: any | undefined;\n appId: any | undefined;\n clusterId: any | undefined;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AA+CA,IAAY,YAUX;AAVD,WAAY,YAAY;IACtB,oCAAoB,CAAA;IACpB,2BAAW,CAAA;IACX,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,gDAAgC,CAAA;IAChC,8CAA8B,CAAA;IAC9B,kEAAkD,CAAA;AACpD,CAAC,EAVW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAUvB;AAmCY,QAAA,cAAc,GAAiC;IAC1D,gBAAgB,EAAE,IAAI,GAAG,EAAE;IAC3B,kBAAkB,EAAE,KAAK;CAC1B,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { Span } from '@opentelemetry/api';\nimport { InstrumentationConfig } from '@opentelemetry/instrumentation';\n\nexport interface PublishInfo {\n moduleVersion: string | undefined;\n exchange: string;\n routingKey: string;\n content: Buffer;\n options?: AmqplibPublishOptions;\n isConfirmChannel?: boolean;\n}\n\nexport interface PublishConfirmedInfo extends PublishInfo {\n confirmError?: any;\n}\n\nexport interface ConsumeInfo {\n moduleVersion: string | undefined;\n msg: ConsumeMessage;\n}\n\nexport interface ConsumeEndInfo {\n msg: ConsumeMessage;\n rejected: boolean | null;\n endOperation: EndOperation;\n}\n\nexport interface AmqplibPublishCustomAttributeFunction {\n (span: Span, publishInfo: PublishInfo): void;\n}\n\nexport interface AmqplibPublishConfirmCustomAttributeFunction {\n (span: Span, publishConfirmedInto: PublishConfirmedInfo): void;\n}\n\nexport interface AmqplibConsumeCustomAttributeFunction {\n (span: Span, consumeInfo: ConsumeInfo): void;\n}\n\nexport interface AmqplibConsumeEndCustomAttributeFunction {\n (span: Span, consumeEndInfo: ConsumeEndInfo): void;\n}\n\nexport enum EndOperation {\n AutoAck = 'auto ack',\n Ack = 'ack',\n AckAll = 'ackAll',\n Reject = 'reject',\n Nack = 'nack',\n NackAll = 'nackAll',\n ChannelClosed = 'channel closed',\n ChannelError = 'channel error',\n InstrumentationTimeout = 'instrumentation timeout',\n}\n\nexport interface AmqplibInstrumentationConfig extends InstrumentationConfig {\n /** hook for adding custom attributes before publish message is sent */\n publishHook?: AmqplibPublishCustomAttributeFunction;\n\n /** hook for adding custom attributes after publish message is confirmed by the broker */\n publishConfirmHook?: AmqplibPublishConfirmCustomAttributeFunction;\n\n /** hook for adding custom attributes before consumer message is processed */\n consumeHook?: AmqplibConsumeCustomAttributeFunction;\n\n /** hook for adding custom attributes after consumer message is acked to server */\n consumeEndHook?: AmqplibConsumeEndCustomAttributeFunction;\n\n /**\n * When user is setting up consume callback, it is user's responsibility to call\n * ack/nack etc on the msg to resolve it in the server.\n * If user is not calling the ack, the message will stay in the queue until\n * channel is closed, or until server timeout expires (if configured).\n * While we wait for the ack, a reference to the message is stored in plugin, which\n * will never be garbage collected.\n * To prevent memory leak, plugin has it's own configuration of timeout, which\n * will close the span if user did not call ack after this timeout.\n * If timeout is not big enough, span might be closed with 'InstrumentationTimeout',\n * and then received valid ack from the user later which will not be instrumented.\n *\n * Default is 1 minute\n */\n consumeTimeoutMs?: number;\n\n /** option to use a span link for the consume message instead of continuing a trace */\n useLinksForConsume?: boolean;\n}\n\nexport const DEFAULT_CONFIG: AmqplibInstrumentationConfig = {\n consumeTimeoutMs: 1000 * 60, // 1 minute\n useLinksForConsume: false,\n};\n\n// The following types are vendored from `@types/amqplib@0.10.1` - commit SHA: 4205e03127692a40b4871709a7134fe4e2ed5510\n\n// Vendored from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/4205e03127692a40b4871709a7134fe4e2ed5510/types/amqplib/properties.d.ts#L108\n// This exists in `@types/amqplib` as `Options.Publish`. We're renaming things\n// here to avoid importing the whole Options namespace.\nexport interface AmqplibPublishOptions {\n expiration?: string | number;\n userId?: string;\n CC?: string | string[];\n\n mandatory?: boolean;\n persistent?: boolean;\n deliveryMode?: boolean | number;\n BCC?: string | string[];\n\n contentType?: string;\n contentEncoding?: string;\n headers?: any;\n priority?: number;\n correlationId?: string;\n replyTo?: string;\n messageId?: string;\n timestamp?: number;\n type?: string;\n appId?: string;\n}\n\n// Vendored from: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/4205e03127692a40b4871709a7134fe4e2ed5510/types/amqplib/properties.d.ts#L142\nexport interface Message {\n content: Buffer;\n fields: MessageFields;\n properties: MessageProperties;\n}\n\nexport interface ConsumeMessage extends Message {\n fields: ConsumeMessageFields;\n}\n\nexport interface CommonMessageFields {\n deliveryTag: number;\n redelivered: boolean;\n exchange: string;\n routingKey: string;\n}\n\nexport interface MessageFields extends CommonMessageFields {\n messageCount?: number;\n consumerTag?: string;\n}\n\nexport interface ConsumeMessageFields extends CommonMessageFields {\n deliveryTag: number;\n}\n\nexport interface MessageProperties {\n contentType: any | undefined;\n contentEncoding: any | undefined;\n headers: any;\n deliveryMode: any | undefined;\n priority: any | undefined;\n correlationId: any | undefined;\n replyTo: any | undefined;\n expiration: any | undefined;\n messageId: any | undefined;\n timestamp: any | undefined;\n type: any | undefined;\n userId: any | undefined;\n appId: any | undefined;\n clusterId: any | undefined;\n}\n"]}
@@ -3,18 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isConfirmChannelTracing = exports.unmarkConfirmChannelTracing = exports.markConfirmChannelTracing = exports.getConnectionAttributesFromUrl = exports.getConnectionAttributesFromServer = exports.normalizeExchange = exports.CONNECTION_ATTRIBUTES = exports.CHANNEL_CONSUME_TIMEOUT_TIMER = exports.CHANNEL_SPANS_NOT_ENDED = exports.MESSAGE_STORED_SPAN = void 0;
4
4
  /*
5
5
  * Copyright The OpenTelemetry Authors
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * https://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
6
+ * SPDX-License-Identifier: Apache-2.0
18
7
  */
19
8
  const api_1 = require("@opentelemetry/api");
20
9
  const instrumentation_1 = require("@opentelemetry/instrumentation");
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAQ4B;AAC5B,oEAAkE;AAClE,8EAG6C;AAC7C,uCAImB;AACnB,8DAIiC;AAGpB,QAAA,mBAAmB,GAAkB,MAAM,CACtD,2CAA2C,CAC5C,CAAC;AACW,QAAA,uBAAuB,GAAkB,MAAM,CAC1D,+CAA+C,CAChD,CAAC;AACW,QA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AAEK,MAAM,2BAA2B,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC9D,OAAO,OAAO,CAAC,WAAW,CAAC,8BAA8B,CAAC,CAAC;AAC7D,CAAC,CAAC;AAFW,QAAA,2BAA2B,+BAEtC;AAEK,MAAM,uBAAuB,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC1D,OAAO,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,KAAK,IAAI,CAAC;AACnE,CAAC,CAAC;AAFW,QAAA,uBAAuB,2BAElC","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 createContextKey,\n diag,\n HrTime,\n Span,\n Attributes,\n AttributeValue,\n} from '@opentelemetry/api';\nimport { SemconvStability } from '@opentelemetry/instrumentation';\nimport {\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport {\n ATTR_MESSAGING_SYSTEM,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n} from './semconv';\nimport {\n ATTR_MESSAGING_PROTOCOL,\n ATTR_MESSAGING_PROTOCOL_VERSION,\n ATTR_MESSAGING_URL,\n} from '../src/semconv-obsolete';\nimport type * as amqp from 'amqplib';\n\nexport const MESSAGE_STORED_SPAN: unique symbol = Symbol(\n 'opentelemetry.amqplib.message.stored-span'\n);\nexport const CHANNEL_SPANS_NOT_ENDED: unique symbol = Symbol(\n 'opentelemetry.amqplib.channel.spans-not-ended'\n);\nexport const CHANNEL_CONSUME_TIMEOUT_TIMER: unique symbol = Symbol(\n 'opentelemetry.amqplib.channel.consumer-timeout-timer'\n);\nexport const CONNECTION_ATTRIBUTES: unique symbol = Symbol(\n 'opentelemetry.amqplib.connection.attributes'\n);\n\nexport type InstrumentationConnection = amqp.Connection & {\n [CONNECTION_ATTRIBUTES]?: Attributes;\n};\nexport type InstrumentationPublishChannel = (\n | amqp.Channel\n | amqp.ConfirmChannel\n) & { connection: InstrumentationConnection };\nexport type InstrumentationConsumeChannel = amqp.Channel & {\n connection: InstrumentationConnection;\n [CHANNEL_SPANS_NOT_ENDED]?: {\n msg: amqp.ConsumeMessage;\n timeOfConsume: HrTime;\n }[];\n [CHANNEL_CONSUME_TIMEOUT_TIMER]?: NodeJS.Timeout;\n};\nexport type InstrumentationMessage = amqp.Message & {\n [MESSAGE_STORED_SPAN]?: Span;\n};\nexport type InstrumentationConsumeMessage = amqp.ConsumeMessage & {\n [MESSAGE_STORED_SPAN]?: Span;\n};\n\nconst IS_CONFIRM_CHANNEL_CONTEXT_KEY: symbol = createContextKey(\n 'opentelemetry.amqplib.channel.is-confirm-channel'\n);\n\nexport const normalizeExchange = (exchangeName: string) =>\n exchangeName !== '' ? exchangeName : '<default>';\n\nconst censorPassword = (url: string): string => {\n return url.replace(/:[^:@/]*@/, ':***@');\n};\n\nconst getPort = (\n portFromUrl: number | undefined,\n resolvedProtocol: string\n): number => {\n // we are using the resolved protocol which is upper case\n // this code mimic the behavior of the amqplib which is used to set connection params\n return portFromUrl || (resolvedProtocol === 'AMQP' ? 5672 : 5671);\n};\n\nconst getProtocol = (protocolFromUrl: string | undefined): string => {\n const resolvedProtocol = protocolFromUrl || 'amqp';\n // the substring removed the ':' part of the protocol ('amqp:' -> 'amqp')\n const noEndingColon = resolvedProtocol.endsWith(':')\n ? resolvedProtocol.substring(0, resolvedProtocol.length - 1)\n : resolvedProtocol;\n // upper cases to match spec\n return noEndingColon.toUpperCase();\n};\n\nconst getHostname = (hostnameFromUrl: string | undefined): string => {\n // if user supplies empty hostname, it gets forwarded to 'net' package which default it to localhost.\n // https://nodejs.org/docs/latest-v12.x/api/net.html#net_socket_connect_options_connectlistener\n return hostnameFromUrl || 'localhost';\n};\n\nconst extractConnectionAttributeOrLog = (\n url: string | amqp.Options.Connect,\n attributeKey: string,\n attributeValue: AttributeValue,\n nameForLog: string\n): Attributes => {\n if (attributeValue) {\n return { [attributeKey]: attributeValue };\n } else {\n diag.error(\n `amqplib instrumentation: could not extract connection attribute ${nameForLog} from user supplied url`,\n {\n url,\n }\n );\n return {};\n }\n};\n\nexport const getConnectionAttributesFromServer = (\n conn: amqp.Connection\n): Attributes => {\n const product = conn.serverProperties.product?.toLowerCase?.();\n if (product) {\n return {\n [ATTR_MESSAGING_SYSTEM]: product,\n };\n } else {\n return {};\n }\n};\n\nexport const getConnectionAttributesFromUrl = (\n url: string | amqp.Options.Connect,\n netSemconvStability: SemconvStability\n): Attributes => {\n const attributes: Attributes = {\n [ATTR_MESSAGING_PROTOCOL_VERSION]: '0.9.1', // this is the only protocol supported by the instrumented library\n };\n\n url = url || 'amqp://localhost';\n if (typeof url === 'object') {\n const connectOptions = url as amqp.Options.Connect;\n\n const protocol = getProtocol(connectOptions?.protocol);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n ATTR_MESSAGING_PROTOCOL,\n protocol,\n 'protocol'\n ),\n });\n\n const hostname = getHostname(connectOptions?.hostname);\n if (netSemconvStability & SemconvStability.OLD) {\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n ATTR_NET_PEER_NAME,\n hostname,\n 'hostname'\n ),\n });\n }\n if (netSemconvStability & SemconvStability.STABLE) {\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n ATTR_SERVER_ADDRESS,\n hostname,\n 'hostname'\n ),\n });\n }\n\n const port = getPort(connectOptions.port, protocol);\n if (netSemconvStability & SemconvStability.OLD) {\n Object.assign(\n attributes,\n extractConnectionAttributeOrLog(url, ATTR_NET_PEER_PORT, port, 'port')\n );\n }\n if (netSemconvStability & SemconvStability.STABLE) {\n Object.assign(\n attributes,\n extractConnectionAttributeOrLog(url, ATTR_SERVER_PORT, port, 'port')\n );\n }\n } else {\n const censoredUrl = censorPassword(url);\n attributes[ATTR_MESSAGING_URL] = censoredUrl;\n try {\n const urlParts = new URL(censoredUrl);\n\n const protocol = getProtocol(urlParts.protocol);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_MESSAGING_PROTOCOL,\n protocol,\n 'protocol'\n ),\n });\n\n const hostname = getHostname(urlParts.hostname);\n if (netSemconvStability & SemconvStability.OLD) {\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_NET_PEER_NAME,\n hostname,\n 'hostname'\n ),\n });\n }\n if (netSemconvStability & SemconvStability.STABLE) {\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_SERVER_ADDRESS,\n hostname,\n 'hostname'\n ),\n });\n }\n\n const port = getPort(\n urlParts.port ? parseInt(urlParts.port) : undefined,\n protocol\n );\n if (netSemconvStability & SemconvStability.OLD) {\n Object.assign(\n attributes,\n extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_NET_PEER_PORT,\n port,\n 'port'\n )\n );\n }\n if (netSemconvStability & SemconvStability.STABLE) {\n Object.assign(\n attributes,\n extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_SERVER_PORT,\n port,\n 'port'\n )\n );\n }\n } catch (err) {\n diag.error(\n 'amqplib instrumentation: error while extracting connection details from connection url',\n {\n censoredUrl,\n err,\n }\n );\n }\n }\n return attributes;\n};\n\nexport const markConfirmChannelTracing = (context: Context) => {\n return context.setValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY, true);\n};\n\nexport const unmarkConfirmChannelTracing = (context: Context) => {\n return context.deleteValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY);\n};\n\nexport const isConfirmChannelTracing = (context: Context) => {\n return context.getValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY) ===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,EACxF;gBACE,WAAW;gBACX,GAAG;aACJ,CACF,CAAC;SACH;KACF;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AApIW,QAAA,8BAA8B,kCAoIzC;AAEK,MAAM,yBAAyB,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC5D,OAAO,OAAO,CAAC,QAAQ,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,yBAAyB,6BAEpC;AAEK,MAAM,2BAA2B,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC9D,OAAO,OAAO,CAAC,WAAW,CAAC,8BAA8B,CAAC,CAAC;AAC7D,CAAC,CAAC;AAFW,QAAA,2BAA2B,+BAEtC;AAEK,MAAM,uBAAuB,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC1D,OAAO,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,KAAK,IAAI,CAAC;AACnE,CAAC,CAAC;AAFW,QAAA,uBAAuB,2BAElC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n Context,\n createContextKey,\n diag,\n HrTime,\n Span,\n Attributes,\n AttributeValue,\n} from '@opentelemetry/api';\nimport { SemconvStability } from '@opentelemetry/instrumentation';\nimport {\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions';\nimport {\n ATTR_MESSAGING_SYSTEM,\n ATTR_NET_PEER_NAME,\n ATTR_NET_PEER_PORT,\n} from './semconv';\nimport {\n ATTR_MESSAGING_PROTOCOL,\n ATTR_MESSAGING_PROTOCOL_VERSION,\n ATTR_MESSAGING_URL,\n} from '../src/semconv-obsolete';\nimport type * as amqp from 'amqplib';\n\nexport const MESSAGE_STORED_SPAN: unique symbol = Symbol(\n 'opentelemetry.amqplib.message.stored-span'\n);\nexport const CHANNEL_SPANS_NOT_ENDED: unique symbol = Symbol(\n 'opentelemetry.amqplib.channel.spans-not-ended'\n);\nexport const CHANNEL_CONSUME_TIMEOUT_TIMER: unique symbol = Symbol(\n 'opentelemetry.amqplib.channel.consumer-timeout-timer'\n);\nexport const CONNECTION_ATTRIBUTES: unique symbol = Symbol(\n 'opentelemetry.amqplib.connection.attributes'\n);\n\nexport type InstrumentationConnection = amqp.Connection & {\n [CONNECTION_ATTRIBUTES]?: Attributes;\n};\nexport type InstrumentationPublishChannel = (\n | amqp.Channel\n | amqp.ConfirmChannel\n) & { connection: InstrumentationConnection };\nexport type InstrumentationConsumeChannel = amqp.Channel & {\n connection: InstrumentationConnection;\n [CHANNEL_SPANS_NOT_ENDED]?: {\n msg: amqp.ConsumeMessage;\n timeOfConsume: HrTime;\n }[];\n [CHANNEL_CONSUME_TIMEOUT_TIMER]?: NodeJS.Timeout;\n};\nexport type InstrumentationMessage = amqp.Message & {\n [MESSAGE_STORED_SPAN]?: Span;\n};\nexport type InstrumentationConsumeMessage = amqp.ConsumeMessage & {\n [MESSAGE_STORED_SPAN]?: Span;\n};\n\nconst IS_CONFIRM_CHANNEL_CONTEXT_KEY: symbol = createContextKey(\n 'opentelemetry.amqplib.channel.is-confirm-channel'\n);\n\nexport const normalizeExchange = (exchangeName: string) =>\n exchangeName !== '' ? exchangeName : '<default>';\n\nconst censorPassword = (url: string): string => {\n return url.replace(/:[^:@/]*@/, ':***@');\n};\n\nconst getPort = (\n portFromUrl: number | undefined,\n resolvedProtocol: string\n): number => {\n // we are using the resolved protocol which is upper case\n // this code mimic the behavior of the amqplib which is used to set connection params\n return portFromUrl || (resolvedProtocol === 'AMQP' ? 5672 : 5671);\n};\n\nconst getProtocol = (protocolFromUrl: string | undefined): string => {\n const resolvedProtocol = protocolFromUrl || 'amqp';\n // the substring removed the ':' part of the protocol ('amqp:' -> 'amqp')\n const noEndingColon = resolvedProtocol.endsWith(':')\n ? resolvedProtocol.substring(0, resolvedProtocol.length - 1)\n : resolvedProtocol;\n // upper cases to match spec\n return noEndingColon.toUpperCase();\n};\n\nconst getHostname = (hostnameFromUrl: string | undefined): string => {\n // if user supplies empty hostname, it gets forwarded to 'net' package which default it to localhost.\n // https://nodejs.org/docs/latest-v12.x/api/net.html#net_socket_connect_options_connectlistener\n return hostnameFromUrl || 'localhost';\n};\n\nconst extractConnectionAttributeOrLog = (\n url: string | amqp.Options.Connect,\n attributeKey: string,\n attributeValue: AttributeValue,\n nameForLog: string\n): Attributes => {\n if (attributeValue) {\n return { [attributeKey]: attributeValue };\n } else {\n diag.error(\n `amqplib instrumentation: could not extract connection attribute ${nameForLog} from user supplied url`,\n {\n url,\n }\n );\n return {};\n }\n};\n\nexport const getConnectionAttributesFromServer = (\n conn: amqp.Connection\n): Attributes => {\n const product = conn.serverProperties.product?.toLowerCase?.();\n if (product) {\n return {\n [ATTR_MESSAGING_SYSTEM]: product,\n };\n } else {\n return {};\n }\n};\n\nexport const getConnectionAttributesFromUrl = (\n url: string | amqp.Options.Connect,\n netSemconvStability: SemconvStability\n): Attributes => {\n const attributes: Attributes = {\n [ATTR_MESSAGING_PROTOCOL_VERSION]: '0.9.1', // this is the only protocol supported by the instrumented library\n };\n\n url = url || 'amqp://localhost';\n if (typeof url === 'object') {\n const connectOptions = url as amqp.Options.Connect;\n\n const protocol = getProtocol(connectOptions?.protocol);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n ATTR_MESSAGING_PROTOCOL,\n protocol,\n 'protocol'\n ),\n });\n\n const hostname = getHostname(connectOptions?.hostname);\n if (netSemconvStability & SemconvStability.OLD) {\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n ATTR_NET_PEER_NAME,\n hostname,\n 'hostname'\n ),\n });\n }\n if (netSemconvStability & SemconvStability.STABLE) {\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n ATTR_SERVER_ADDRESS,\n hostname,\n 'hostname'\n ),\n });\n }\n\n const port = getPort(connectOptions.port, protocol);\n if (netSemconvStability & SemconvStability.OLD) {\n Object.assign(\n attributes,\n extractConnectionAttributeOrLog(url, ATTR_NET_PEER_PORT, port, 'port')\n );\n }\n if (netSemconvStability & SemconvStability.STABLE) {\n Object.assign(\n attributes,\n extractConnectionAttributeOrLog(url, ATTR_SERVER_PORT, port, 'port')\n );\n }\n } else {\n const censoredUrl = censorPassword(url);\n attributes[ATTR_MESSAGING_URL] = censoredUrl;\n try {\n const urlParts = new URL(censoredUrl);\n\n const protocol = getProtocol(urlParts.protocol);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_MESSAGING_PROTOCOL,\n protocol,\n 'protocol'\n ),\n });\n\n const hostname = getHostname(urlParts.hostname);\n if (netSemconvStability & SemconvStability.OLD) {\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_NET_PEER_NAME,\n hostname,\n 'hostname'\n ),\n });\n }\n if (netSemconvStability & SemconvStability.STABLE) {\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_SERVER_ADDRESS,\n hostname,\n 'hostname'\n ),\n });\n }\n\n const port = getPort(\n urlParts.port ? parseInt(urlParts.port) : undefined,\n protocol\n );\n if (netSemconvStability & SemconvStability.OLD) {\n Object.assign(\n attributes,\n extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_NET_PEER_PORT,\n port,\n 'port'\n )\n );\n }\n if (netSemconvStability & SemconvStability.STABLE) {\n Object.assign(\n attributes,\n extractConnectionAttributeOrLog(\n censoredUrl,\n ATTR_SERVER_PORT,\n port,\n 'port'\n )\n );\n }\n } catch (err) {\n diag.error(\n 'amqplib instrumentation: error while extracting connection details from connection url',\n {\n censoredUrl,\n err,\n }\n );\n }\n }\n return attributes;\n};\n\nexport const markConfirmChannelTracing = (context: Context) => {\n return context.setValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY, true);\n};\n\nexport const unmarkConfirmChannelTracing = (context: Context) => {\n return context.deleteValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY);\n};\n\nexport const isConfirmChannelTracing = (context: Context) => {\n return context.getValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY) === true;\n};\n"]}
@@ -1,3 +1,3 @@
1
- export declare const PACKAGE_VERSION = "0.61.0";
1
+ export declare const PACKAGE_VERSION = "0.63.0";
2
2
  export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-amqplib";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,22 +1,11 @@
1
1
  "use strict";
2
2
  /*
3
3
  * Copyright The OpenTelemetry Authors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
4
+ * SPDX-License-Identifier: Apache-2.0
16
5
  */
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
19
8
  // this is autogenerated file, see scripts/version-update.js
20
- exports.PACKAGE_VERSION = '0.61.0';
9
+ exports.PACKAGE_VERSION = '0.63.0';
21
10
  exports.PACKAGE_NAME = '@opentelemetry/instrumentation-amqplib';
22
11
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,wCAAwC,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 PACKAGE_VERSION = '0.61.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-amqplib';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,wCAAwC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.63.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-amqplib';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/instrumentation-amqplib",
3
- "version": "0.61.0",
3
+ "version": "0.63.0",
4
4
  "description": "OpenTelemetry instrumentation for the `amqplib` messaging client for RabbitMQ",
5
5
  "keywords": [
6
6
  "amqplib",
@@ -51,19 +51,19 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "@opentelemetry/core": "^2.0.0",
54
- "@opentelemetry/instrumentation": "^0.214.0",
54
+ "@opentelemetry/instrumentation": "^0.216.0",
55
55
  "@opentelemetry/semantic-conventions": "^1.33.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@opentelemetry/api": "^1.3.0",
59
- "@opentelemetry/contrib-test-utils": "^0.61.0",
59
+ "@opentelemetry/contrib-test-utils": "^0.63.0",
60
60
  "@types/amqplib": "^0.10.7",
61
61
  "@types/lodash": "4.17.24",
62
- "amqplib": "0.8.0",
63
- "lodash": "4.17.23"
62
+ "amqplib": "^1.0.3",
63
+ "lodash": "4.18.1"
64
64
  },
65
65
  "engines": {
66
66
  "node": "^18.19.0 || >=20.6.0"
67
67
  },
68
- "gitHead": "ed97091c9890dd18e52759f2ea98e9d7593b3ae4"
68
+ "gitHead": "03ed3a3a4ab3f9fd481ba81dddb72b3f8e7dae30"
69
69
  }