@opentelemetry/instrumentation-amqplib 0.46.1 → 0.48.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.
@@ -27,10 +27,10 @@ const version_1 = require("./version");
27
27
  const supportedVersions = ['>=0.5.5 <1'];
28
28
  class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
29
29
  constructor(config = {}) {
30
- super(version_1.PACKAGE_NAME, version_1.PACKAGE_VERSION, Object.assign(Object.assign({}, types_1.DEFAULT_CONFIG), config));
30
+ super(version_1.PACKAGE_NAME, version_1.PACKAGE_VERSION, { ...types_1.DEFAULT_CONFIG, ...config });
31
31
  }
32
32
  setConfig(config = {}) {
33
- super.setConfig(Object.assign(Object.assign({}, types_1.DEFAULT_CONFIG), config));
33
+ super.setConfig({ ...types_1.DEFAULT_CONFIG, ...config });
34
34
  }
35
35
  init() {
36
36
  const channelModelModuleFile = new instrumentation_1.InstrumentationNodeModuleFile('amqplib/lib/channel_model.js', supportedVersions, this.patchChannelModel.bind(this), this.unpatchChannelModel.bind(this));
@@ -123,7 +123,10 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
123
123
  // in the package itself
124
124
  // currently setting as any to calm typescript
125
125
  const serverAttributes = (0, utils_1.getConnectionAttributesFromServer)(conn);
126
- conn[utils_1.CONNECTION_ATTRIBUTES] = Object.assign(Object.assign({}, urlAttributes), serverAttributes);
126
+ conn[utils_1.CONNECTION_ATTRIBUTES] = {
127
+ ...urlAttributes,
128
+ ...serverAttributes,
129
+ };
127
130
  }
128
131
  openCallback.apply(this, arguments);
129
132
  });
@@ -156,11 +159,10 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
156
159
  getAckPatch(isRejected, endOperation, original) {
157
160
  const self = this;
158
161
  return function ack(message, allUpToOrRequeue, requeue) {
159
- var _a;
160
162
  const channel = this;
161
163
  // we use this patch in reject function as well, but it has different signature
162
164
  const requeueResolved = endOperation === types_1.EndOperation.Reject ? allUpToOrRequeue : requeue;
163
- const spansNotEnded = (_a = channel[utils_1.CHANNEL_SPANS_NOT_ENDED]) !== null && _a !== void 0 ? _a : [];
165
+ const spansNotEnded = channel[utils_1.CHANNEL_SPANS_NOT_ENDED] ?? [];
164
166
  const msgIndex = spansNotEnded.findIndex(msgDetails => msgDetails.msg === message);
165
167
  if (msgIndex < 0) {
166
168
  // should not happen in happy flow
@@ -196,20 +198,19 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
196
198
  channel[utils_1.CHANNEL_SPANS_NOT_ENDED] = [];
197
199
  }
198
200
  const patchedOnMessage = function (msg) {
199
- var _a, _b, _c, _d, _e;
200
201
  // msg is expected to be null for signaling consumer cancel notification
201
202
  // https://www.rabbitmq.com/consumer-cancel.html
202
203
  // in this case, we do not start a span, as this is not a real message.
203
204
  if (!msg) {
204
205
  return onMessage.call(this, msg);
205
206
  }
206
- const headers = (_a = msg.properties.headers) !== null && _a !== void 0 ? _a : {};
207
+ const headers = msg.properties.headers ?? {};
207
208
  let parentContext = api_1.propagation.extract(api_1.ROOT_CONTEXT, headers);
208
- const exchange = (_b = msg.fields) === null || _b === void 0 ? void 0 : _b.exchange;
209
+ const exchange = msg.fields?.exchange;
209
210
  let links;
210
211
  if (self._config.useLinksForConsume) {
211
212
  const parentSpanContext = parentContext
212
- ? (_c = api_1.trace.getSpan(parentContext)) === null || _c === void 0 ? void 0 : _c.spanContext()
213
+ ? api_1.trace.getSpan(parentContext)?.spanContext()
213
214
  : undefined;
214
215
  parentContext = undefined;
215
216
  if (parentSpanContext) {
@@ -222,7 +223,15 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
222
223
  }
223
224
  const span = self.tracer.startSpan(`${queue} process`, {
224
225
  kind: api_1.SpanKind.CONSUMER,
225
- attributes: Object.assign(Object.assign({}, (_d = channel === null || channel === void 0 ? void 0 : channel.connection) === null || _d === void 0 ? void 0 : _d[utils_1.CONNECTION_ATTRIBUTES]), { [semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION]: exchange, [semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION_KIND]: semantic_conventions_1.MESSAGINGDESTINATIONKINDVALUES_TOPIC, [semantic_conventions_1.SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: (_e = msg.fields) === null || _e === void 0 ? void 0 : _e.routingKey, [semantic_conventions_1.SEMATTRS_MESSAGING_OPERATION]: semantic_conventions_1.MESSAGINGOPERATIONVALUES_PROCESS, [semantic_conventions_1.SEMATTRS_MESSAGING_MESSAGE_ID]: msg === null || msg === void 0 ? void 0 : msg.properties.messageId, [semantic_conventions_1.SEMATTRS_MESSAGING_CONVERSATION_ID]: msg === null || msg === void 0 ? void 0 : msg.properties.correlationId }),
226
+ attributes: {
227
+ ...channel?.connection?.[utils_1.CONNECTION_ATTRIBUTES],
228
+ [semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION]: exchange,
229
+ [semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION_KIND]: semantic_conventions_1.MESSAGINGDESTINATIONKINDVALUES_TOPIC,
230
+ [semantic_conventions_1.SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: msg.fields?.routingKey,
231
+ [semantic_conventions_1.SEMATTRS_MESSAGING_OPERATION]: semantic_conventions_1.MESSAGINGOPERATIONVALUES_PROCESS,
232
+ [semantic_conventions_1.SEMATTRS_MESSAGING_MESSAGE_ID]: msg?.properties.messageId,
233
+ [semantic_conventions_1.SEMATTRS_MESSAGING_CONVERSATION_ID]: msg?.properties.correlationId,
234
+ },
226
235
  links,
227
236
  }, parentContext);
228
237
  const { consumeHook } = self.getConfig();
@@ -233,7 +242,7 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
233
242
  }
234
243
  }, true);
235
244
  }
236
- if (!(options === null || options === void 0 ? void 0 : options.noAck)) {
245
+ if (!options?.noAck) {
237
246
  // store the message on the channel so we can close the span on ackAll etc
238
247
  channel[utils_1.CHANNEL_SPANS_NOT_ENDED].push({
239
248
  msg,
@@ -248,7 +257,7 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
248
257
  api_1.context.with(api_1.trace.setSpan(setContext, span), () => {
249
258
  onMessage.call(this, msg);
250
259
  });
251
- if (options === null || options === void 0 ? void 0 : options.noAck) {
260
+ if (options?.noAck) {
252
261
  self.callConsumeEndHook(span, msg, false, types_1.EndOperation.AutoAck);
253
262
  span.end();
254
263
  }
@@ -279,7 +288,7 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
279
288
  }
280
289
  const patchedOnConfirm = function (err, ok) {
281
290
  try {
282
- callback === null || callback === void 0 ? void 0 : callback.call(this, err, ok);
291
+ callback?.call(this, err, ok);
283
292
  }
284
293
  finally {
285
294
  const { publishConfirmHook } = self.getConfig();
@@ -352,14 +361,20 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
352
361
  };
353
362
  }
354
363
  createPublishSpan(self, exchange, routingKey, channel, options) {
355
- var _a;
356
364
  const normalizedExchange = (0, utils_1.normalizeExchange)(exchange);
357
365
  const span = self.tracer.startSpan(`publish ${normalizedExchange}`, {
358
366
  kind: api_1.SpanKind.PRODUCER,
359
- attributes: Object.assign(Object.assign({}, channel.connection[utils_1.CONNECTION_ATTRIBUTES]), { [semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION]: exchange, [semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION_KIND]: semantic_conventions_1.MESSAGINGDESTINATIONKINDVALUES_TOPIC, [semantic_conventions_1.SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: routingKey, [semantic_conventions_1.SEMATTRS_MESSAGING_MESSAGE_ID]: options === null || options === void 0 ? void 0 : options.messageId, [semantic_conventions_1.SEMATTRS_MESSAGING_CONVERSATION_ID]: options === null || options === void 0 ? void 0 : options.correlationId }),
367
+ attributes: {
368
+ ...channel.connection[utils_1.CONNECTION_ATTRIBUTES],
369
+ [semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION]: exchange,
370
+ [semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION_KIND]: semantic_conventions_1.MESSAGINGDESTINATIONKINDVALUES_TOPIC,
371
+ [semantic_conventions_1.SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: routingKey,
372
+ [semantic_conventions_1.SEMATTRS_MESSAGING_MESSAGE_ID]: options?.messageId,
373
+ [semantic_conventions_1.SEMATTRS_MESSAGING_CONVERSATION_ID]: options?.correlationId,
374
+ },
360
375
  });
361
- const modifiedOptions = options !== null && options !== void 0 ? options : {};
362
- modifiedOptions.headers = (_a = modifiedOptions.headers) !== null && _a !== void 0 ? _a : {};
376
+ const modifiedOptions = options ?? {};
377
+ modifiedOptions.headers = modifiedOptions.headers ?? {};
363
378
  api_1.propagation.inject(api_1.trace.setSpan(api_1.context.active(), span), modifiedOptions.headers);
364
379
  return { span, modifiedOptions };
365
380
  }
@@ -385,8 +400,7 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
385
400
  message[utils_1.MESSAGE_STORED_SPAN] = undefined;
386
401
  }
387
402
  endAllSpansOnChannel(channel, isRejected, operation, requeue) {
388
- var _a;
389
- const spansNotEnded = (_a = channel[utils_1.CHANNEL_SPANS_NOT_ENDED]) !== null && _a !== void 0 ? _a : [];
403
+ const spansNotEnded = channel[utils_1.CHANNEL_SPANS_NOT_ENDED] ?? [];
390
404
  spansNotEnded.forEach(msgDetails => {
391
405
  this.endConsumerSpan(msgDetails.msg, isRejected, operation, requeue);
392
406
  });
@@ -403,9 +417,8 @@ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
403
417
  }, true);
404
418
  }
405
419
  checkConsumeTimeoutOnChannel(channel) {
406
- var _a;
407
420
  const currentTime = (0, core_1.hrTime)();
408
- const spansNotEnded = (_a = channel[utils_1.CHANNEL_SPANS_NOT_ENDED]) !== null && _a !== void 0 ? _a : [];
421
+ const spansNotEnded = channel[utils_1.CHANNEL_SPANS_NOT_ENDED] ?? [];
409
422
  let i;
410
423
  const { consumeTimeoutMs } = this.getConfig();
411
424
  for (i = 0; i < spansNotEnded.length; i++) {
@@ -1 +1 @@
1
- {"version":3,"file":"amqplib.js","sourceRoot":"","sources":["../../src/amqplib.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAW4B;AAC5B,8CAI6B;AAC7B,oEAMwC;AACxC,8EAS6C;AAQ7C,mCAIiB;AACjB,mCAciB;AACjB,kBAAkB;AAClB,uCAA0D;AAE1D,MAAM,iBAAiB,GAAG,CAAC,YAAY,CAAC,CAAC;AAEzC,MAAa,sBAAuB,SAAQ,qCAAiD;IAC3F,YAAY,SAAuC,EAAE;QACnD,KAAK,CAAC,sBAAY,EAAE,yBAAe,kCAAO,sBAAc,GAAK,MAAM,EAAG,CAAC;IACzE,CAAC;IAEQ,SAAS,CAAC,SAAuC,EAAE;QAC1D,KAAK,CAAC,SAAS,iCAAM,sBAAc,GAAK,MAAM,EAAG,CAAC;IACpD,CAAC;IAES,IAAI;QACZ,MAAM,sBAAsB,GAAG,IAAI,+CAA6B,CAC9D,8BAA8B,EAC9B,iBAAiB,EACjB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EACjC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CACpC,CAAC;QAEF,MAAM,uBAAuB,GAAG,IAAI,+CAA6B,CAC/D,+BAA+B,EAC/B,iBAAiB,EACjB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EACjC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CACpC,CAAC;QAEF,MAAM,iBAAiB,GAAG,IAAI,+CAA6B,CACzD,wBAAwB,EACxB,iBAAiB,EACjB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAC/B,CAAC;QAEF,MAA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AAE;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;AA9qBD,wDA8qBC","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} from '@opentelemetry/instrumentation';\nimport {\n SEMATTRS_MESSAGING_DESTINATION,\n SEMATTRS_MESSAGING_DESTINATION_KIND,\n MESSAGINGDESTINATIONKINDVALUES_TOPIC,\n SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY,\n SEMATTRS_MESSAGING_OPERATION,\n MESSAGINGOPERATIONVALUES_PROCESS,\n SEMATTRS_MESSAGING_MESSAGE_ID,\n SEMATTRS_MESSAGING_CONVERSATION_ID,\n} from '@opentelemetry/semantic-conventions';\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 InstrumentationConsumeChannel,\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 constructor(config: AmqplibInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, { ...DEFAULT_CONFIG, ...config });\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 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: Connection) {\n if (err == null) {\n const urlAttributes = getConnectionAttributesFromUrl(url);\n // the type of conn in @types/amqplib is amqp.Connection, but in practice the library send the\n // `serverProperties` on the `conn` and not in a property `connection`.\n // I don't have capacity to debug it currently but it should probably be fixed in @types or\n // in the package itself\n // currently setting as any to calm typescript\n const serverAttributes = getConnectionAttributesFromServer(\n conn as any\n );\n (conn as any)[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: InstrumentationMessage | 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 [SEMATTRS_MESSAGING_DESTINATION]: exchange,\n [SEMATTRS_MESSAGING_DESTINATION_KIND]:\n MESSAGINGDESTINATIONKINDVALUES_TOPIC,\n [SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: msg.fields?.routingKey,\n [SEMATTRS_MESSAGING_OPERATION]: MESSAGINGOPERATIONVALUES_PROCESS,\n [SEMATTRS_MESSAGING_MESSAGE_ID]: msg?.properties.messageId,\n [SEMATTRS_MESSAGING_CONVERSATION_ID]:\n 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 [SEMATTRS_MESSAGING_DESTINATION]: exchange,\n [SEMATTRS_MESSAGING_DESTINATION_KIND]:\n MESSAGINGDESTINATIONKINDVALUES_TOPIC,\n [SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: routingKey,\n [SEMATTRS_MESSAGING_MESSAGE_ID]: options?.messageId,\n [SEMATTRS_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: ConsumeMessage,\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;;;;;;;;;;;;;;GAcG;AACH,4CAW4B;AAC5B,8CAI6B;AAC7B,oEAMwC;AACxC,8EAS6C;AAQ7C,mCAIiB;AACjB,mCAciB;AACjB,kBAAkB;AAClB,uCAA0D;AAE1D,MAAM,iBAAiB,GAAG,CAAC,YAAY,CAAC,CAAC;AAEzC,MAAa,sBAAuB,SAAQ,qCAAiD;IAC3F,YAAY,SAAuC,EAAE;QACnD,KAAK,CAAC,sBAAY,EAAE,yBAAe,EAAE,EAAE,GAAG,sBAAc,EAAE,GAAG,MAAM,EAAE,C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AQ,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;AA9qBD,wDA8qBC","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} from '@opentelemetry/instrumentation';\nimport {\n SEMATTRS_MESSAGING_DESTINATION,\n SEMATTRS_MESSAGING_DESTINATION_KIND,\n MESSAGINGDESTINATIONKINDVALUES_TOPIC,\n SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY,\n SEMATTRS_MESSAGING_OPERATION,\n MESSAGINGOPERATIONVALUES_PROCESS,\n SEMATTRS_MESSAGING_MESSAGE_ID,\n SEMATTRS_MESSAGING_CONVERSATION_ID,\n} from '@opentelemetry/semantic-conventions';\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 InstrumentationConsumeChannel,\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 constructor(config: AmqplibInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, { ...DEFAULT_CONFIG, ...config });\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 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: Connection) {\n if (err == null) {\n const urlAttributes = getConnectionAttributesFromUrl(url);\n // the type of conn in @types/amqplib is amqp.Connection, but in practice the library send the\n // `serverProperties` on the `conn` and not in a property `connection`.\n // I don't have capacity to debug it currently but it should probably be fixed in @types or\n // in the package itself\n // currently setting as any to calm typescript\n const serverAttributes = getConnectionAttributesFromServer(\n conn as any\n );\n (conn as any)[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: InstrumentationMessage | 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 [SEMATTRS_MESSAGING_DESTINATION]: exchange,\n [SEMATTRS_MESSAGING_DESTINATION_KIND]:\n MESSAGINGDESTINATIONKINDVALUES_TOPIC,\n [SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: msg.fields?.routingKey,\n [SEMATTRS_MESSAGING_OPERATION]: MESSAGINGOPERATIONVALUES_PROCESS,\n [SEMATTRS_MESSAGING_MESSAGE_ID]: msg?.properties.messageId,\n [SEMATTRS_MESSAGING_CONVERSATION_ID]:\n 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 [SEMATTRS_MESSAGING_DESTINATION]: exchange,\n [SEMATTRS_MESSAGING_DESTINATION_KIND]:\n MESSAGINGDESTINATIONKINDVALUES_TOPIC,\n [SEMATTRS_MESSAGING_RABBITMQ_ROUTING_KEY]: routingKey,\n [SEMATTRS_MESSAGING_MESSAGE_ID]: options?.messageId,\n [SEMATTRS_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: ConsumeMessage,\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,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAA0B;AAC1B,0CAAwB","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 * from './amqplib';\nexport * from './types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAA0B;AAC1B,0CAAwB","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 * from './amqplib';\nexport * from './types';\n"]}
@@ -5,12 +5,12 @@ export declare const MESSAGE_STORED_SPAN: unique symbol;
5
5
  export declare const CHANNEL_SPANS_NOT_ENDED: unique symbol;
6
6
  export declare const CHANNEL_CONSUME_TIMEOUT_TIMER: unique symbol;
7
7
  export declare const CONNECTION_ATTRIBUTES: unique symbol;
8
- export declare type InstrumentationPublishChannel = (amqp.Channel | amqp.ConfirmChannel) & {
8
+ export type InstrumentationPublishChannel = (amqp.Channel | amqp.ConfirmChannel) & {
9
9
  connection: {
10
10
  [CONNECTION_ATTRIBUTES]: Attributes;
11
11
  };
12
12
  };
13
- export declare type InstrumentationConsumeChannel = amqp.Channel & {
13
+ export type InstrumentationConsumeChannel = amqp.Channel & {
14
14
  connection: {
15
15
  [CONNECTION_ATTRIBUTES]: Attributes;
16
16
  };
@@ -20,7 +20,7 @@ export declare type InstrumentationConsumeChannel = amqp.Channel & {
20
20
  }[];
21
21
  [CHANNEL_CONSUME_TIMEOUT_TIMER]?: NodeJS.Timeout;
22
22
  };
23
- export declare type InstrumentationMessage = amqp.Message & {
23
+ export type InstrumentationMessage = amqp.Message & {
24
24
  [MESSAGE_STORED_SPAN]?: Span;
25
25
  };
26
26
  export declare const normalizeExchange: (exchangeName: string) => string;
@@ -59,8 +59,7 @@ const extractConnectionAttributeOrLog = (url, attributeKey, attributeValue, name
59
59
  }
60
60
  };
61
61
  const getConnectionAttributesFromServer = (conn) => {
62
- var _a, _b;
63
- const product = (_b = (_a = conn.serverProperties.product) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a);
62
+ const product = conn.serverProperties.product?.toLowerCase?.();
64
63
  if (product) {
65
64
  return {
66
65
  [semantic_conventions_1.SEMATTRS_MESSAGING_SYSTEM]: product,
@@ -78,12 +77,18 @@ const getConnectionAttributesFromUrl = (url) => {
78
77
  url = url || 'amqp://localhost';
79
78
  if (typeof url === 'object') {
80
79
  const connectOptions = url;
81
- const protocol = getProtocol(connectOptions === null || connectOptions === void 0 ? void 0 : connectOptions.protocol);
82
- Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(url, semantic_conventions_1.SEMATTRS_MESSAGING_PROTOCOL, protocol, 'protocol')));
83
- const hostname = getHostname(connectOptions === null || connectOptions === void 0 ? void 0 : connectOptions.hostname);
84
- Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(url, semantic_conventions_1.SEMATTRS_NET_PEER_NAME, hostname, 'hostname')));
80
+ const protocol = getProtocol(connectOptions?.protocol);
81
+ Object.assign(attributes, {
82
+ ...extractConnectionAttributeOrLog(url, semantic_conventions_1.SEMATTRS_MESSAGING_PROTOCOL, protocol, 'protocol'),
83
+ });
84
+ const hostname = getHostname(connectOptions?.hostname);
85
+ Object.assign(attributes, {
86
+ ...extractConnectionAttributeOrLog(url, semantic_conventions_1.SEMATTRS_NET_PEER_NAME, hostname, 'hostname'),
87
+ });
85
88
  const port = getPort(connectOptions.port, protocol);
86
- Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(url, semantic_conventions_1.SEMATTRS_NET_PEER_PORT, port, 'port')));
89
+ Object.assign(attributes, {
90
+ ...extractConnectionAttributeOrLog(url, semantic_conventions_1.SEMATTRS_NET_PEER_PORT, port, 'port'),
91
+ });
87
92
  }
88
93
  else {
89
94
  const censoredUrl = censorPassword(url);
@@ -91,11 +96,17 @@ const getConnectionAttributesFromUrl = (url) => {
91
96
  try {
92
97
  const urlParts = new URL(censoredUrl);
93
98
  const protocol = getProtocol(urlParts.protocol);
94
- Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(censoredUrl, semantic_conventions_1.SEMATTRS_MESSAGING_PROTOCOL, protocol, 'protocol')));
99
+ Object.assign(attributes, {
100
+ ...extractConnectionAttributeOrLog(censoredUrl, semantic_conventions_1.SEMATTRS_MESSAGING_PROTOCOL, protocol, 'protocol'),
101
+ });
95
102
  const hostname = getHostname(urlParts.hostname);
96
- Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(censoredUrl, semantic_conventions_1.SEMATTRS_NET_PEER_NAME, hostname, 'hostname')));
103
+ Object.assign(attributes, {
104
+ ...extractConnectionAttributeOrLog(censoredUrl, semantic_conventions_1.SEMATTRS_NET_PEER_NAME, hostname, 'hostname'),
105
+ });
97
106
  const port = getPort(urlParts.port ? parseInt(urlParts.port) : undefined, protocol);
98
- Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(censoredUrl, semantic_conventions_1.SEMATTRS_NET_PEER_PORT, port, 'port')));
107
+ Object.assign(attributes, {
108
+ ...extractConnectionAttributeOrLog(censoredUrl, semantic_conventions_1.SEMATTRS_NET_PEER_PORT, port, 'port'),
109
+ });
99
110
  }
100
111
  catch (err) {
101
112
  api_1.diag.error('amqplib instrumentation: error while extracting connection details from connection url', {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAQ4B;AAC5B,8EAO6C;AAGhC,QAAA,mBAAmB,GAAkB,MAAM,CACtD,2CAA2C,CAC5C,CAAC;AACW,QAAA,uBAAuB,GAAkB,MAAM,CAC1D,+CAA+C,CAChD,CAAC;AACW,QAAA,6BAA6B,GAAkB,MAAM,CAChE,sDAAsD,CACvD,CAAC;AACW,QAAA,qBAAqB,GAAkB,MAAM,CACxD,6CAA6C,CAC9C,CAAC;AAkBF,MAAM,8BAA8B,GAAW,IAAA,sBAAgB,EAC7D,kDAAkD,CACnD,CAAC;AAEK,MAAM,iBAAiB,GAAG,CAAC,YAAoB,EAAE,EAAE,CACxD,YAAY,KAAK,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,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,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 {\n SEMATTRS_MESSAGING_PROTOCOL,\n SEMATTRS_MESSAGING_PROTOCOL_VERSION,\n SEMATTRS_MESSAGING_SYSTEM,\n SEMATTRS_MESSAGING_URL,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_PEER_PORT,\n} from '@opentelemetry/semantic-conventions';\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 InstrumentationPublishChannel = (\n | amqp.Channel\n | amqp.ConfirmChannel\n) & { connection: { [CONNECTION_ATTRIBUTES]: Attributes } };\nexport type InstrumentationConsumeChannel = amqp.Channel & {\n connection: { [CONNECTION_ATTRIBUTES]: Attributes };\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};\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['connection']\n): Attributes => {\n const product = conn.serverProperties.product?.toLowerCase?.();\n if (product) {\n return {\n [SEMATTRS_MESSAGING_SYSTEM]: product,\n };\n } else {\n return {};\n }\n};\n\nexport const getConnectionAttributesFromUrl = (\n url: string | amqp.Options.Connect\n): Attributes => {\n const attributes: Attributes = {\n [SEMATTRS_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 SEMATTRS_MESSAGING_PROTOCOL,\n protocol,\n 'protocol'\n ),\n });\n\n const hostname = getHostname(connectOptions?.hostname);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n SEMATTRS_NET_PEER_NAME,\n hostname,\n 'hostname'\n ),\n });\n\n const port = getPort(connectOptions.port, protocol);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n SEMATTRS_NET_PEER_PORT,\n port,\n 'port'\n ),\n });\n } else {\n const censoredUrl = censorPassword(url);\n attributes[SEMATTRS_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 SEMATTRS_MESSAGING_PROTOCOL,\n protocol,\n 'protocol'\n ),\n });\n\n const hostname = getHostname(urlParts.hostname);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n SEMATTRS_NET_PEER_NAME,\n hostname,\n 'hostname'\n ),\n });\n\n const port = getPort(\n urlParts.port ? parseInt(urlParts.port) : undefined,\n protocol\n );\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n SEMATTRS_NET_PEER_PORT,\n port,\n 'port'\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
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAQ4B;AAC5B,8EAO6C;AAGhC,QAAA,mBAAmB,GAAkB,MAAM,CACtD,2CAA2C,CAC5C,CAAC;AACW,QAAA,uBAAuB,GAAkB,MAAM,CAC1D,+CAA+C,CAChD,CAAC;AACW,QAAA,6BAA6B,GAAkB,MAAM,CAChE,sDAAsD,CACvD,CAAC;AACW,QAAA,qBAAqB,GAAkB,MAAM,CACxD,6CAA6C,CAC9C,CAAC;AAkBF,MAAM,8BAA8B,GAAW,IAAA,sBAAgB,EAC7D,kDAAkD,CACnD,CAAC;AAEK,MAAM,iBAAiB,GAAG,CAAC,YAAoB,EAAE,EAAE,CACxD,YAAY,KAAK,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;AADtC,QAAA,iBAAiB,qBACqB;AAEnD,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IAC7C,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CACd,WAA+B,EAC/B,gBAAwB,EAChB,EAAE;IACV,yDAAyD;IACzD,qFAAqF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;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 {\n SEMATTRS_MESSAGING_PROTOCOL,\n SEMATTRS_MESSAGING_PROTOCOL_VERSION,\n SEMATTRS_MESSAGING_SYSTEM,\n SEMATTRS_MESSAGING_URL,\n SEMATTRS_NET_PEER_NAME,\n SEMATTRS_NET_PEER_PORT,\n} from '@opentelemetry/semantic-conventions';\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 InstrumentationPublishChannel = (\n | amqp.Channel\n | amqp.ConfirmChannel\n) & { connection: { [CONNECTION_ATTRIBUTES]: Attributes } };\nexport type InstrumentationConsumeChannel = amqp.Channel & {\n connection: { [CONNECTION_ATTRIBUTES]: Attributes };\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};\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['connection']\n): Attributes => {\n const product = conn.serverProperties.product?.toLowerCase?.();\n if (product) {\n return {\n [SEMATTRS_MESSAGING_SYSTEM]: product,\n };\n } else {\n return {};\n }\n};\n\nexport const getConnectionAttributesFromUrl = (\n url: string | amqp.Options.Connect\n): Attributes => {\n const attributes: Attributes = {\n [SEMATTRS_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 SEMATTRS_MESSAGING_PROTOCOL,\n protocol,\n 'protocol'\n ),\n });\n\n const hostname = getHostname(connectOptions?.hostname);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n SEMATTRS_NET_PEER_NAME,\n hostname,\n 'hostname'\n ),\n });\n\n const port = getPort(connectOptions.port, protocol);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n url,\n SEMATTRS_NET_PEER_PORT,\n port,\n 'port'\n ),\n });\n } else {\n const censoredUrl = censorPassword(url);\n attributes[SEMATTRS_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 SEMATTRS_MESSAGING_PROTOCOL,\n protocol,\n 'protocol'\n ),\n });\n\n const hostname = getHostname(urlParts.hostname);\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n SEMATTRS_NET_PEER_NAME,\n hostname,\n 'hostname'\n ),\n });\n\n const port = getPort(\n urlParts.port ? parseInt(urlParts.port) : undefined,\n protocol\n );\n Object.assign(attributes, {\n ...extractConnectionAttributeOrLog(\n censoredUrl,\n SEMATTRS_NET_PEER_PORT,\n port,\n 'port'\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.46.1";
1
+ export declare const PACKAGE_VERSION = "0.48.0";
2
2
  export declare const PACKAGE_NAME = "@opentelemetry/instrumentation-amqplib";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -17,6 +17,6 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.PACKAGE_VERSION = '0.46.1';
20
+ exports.PACKAGE_VERSION = '0.48.0';
21
21
  exports.PACKAGE_NAME = '@opentelemetry/instrumentation-amqplib';
22
22
  //# 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.46.1';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-amqplib';\n"]}
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.48.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.46.1",
3
+ "version": "0.48.0",
4
4
  "description": "OpenTelemetry instrumentation for the `amqplib` messaging client for RabbitMQ",
5
5
  "keywords": [
6
6
  "amqplib",
@@ -44,28 +44,28 @@
44
44
  "@opentelemetry/api": "^1.3.0"
45
45
  },
46
46
  "dependencies": {
47
- "@opentelemetry/core": "^1.8.0",
48
- "@opentelemetry/instrumentation": "^0.57.1",
47
+ "@opentelemetry/core": "^2.0.0",
48
+ "@opentelemetry/instrumentation": "^0.201.0",
49
49
  "@opentelemetry/semantic-conventions": "^1.27.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@opentelemetry/api": "^1.3.0",
53
- "@opentelemetry/contrib-test-utils": "^0.45.1",
53
+ "@opentelemetry/contrib-test-utils": "^0.47.0",
54
54
  "@types/amqplib": "^0.5.17",
55
55
  "@types/lodash": "4.14.199",
56
- "@types/mocha": "8.2.3",
56
+ "@types/mocha": "10.0.10",
57
57
  "@types/node": "18.18.14",
58
- "@types/sinon": "10.0.20",
58
+ "@types/sinon": "17.0.4",
59
59
  "amqplib": "0.8.0",
60
60
  "expect": "29.2.0",
61
61
  "lodash": "4.17.21",
62
- "nyc": "15.1.0",
62
+ "nyc": "17.1.0",
63
63
  "sinon": "15.2.0",
64
64
  "test-all-versions": "6.1.0",
65
- "typescript": "4.4.4"
65
+ "typescript": "5.0.4"
66
66
  },
67
67
  "engines": {
68
- "node": ">=14"
68
+ "node": "^18.19.0 || >=20.6.0"
69
69
  },
70
- "gitHead": "1eb77007669bae87fe5664d68ba6533b95275d52"
70
+ "gitHead": "393b51596dc869983a03ce8857658029ca122a15"
71
71
  }