BaseChannel.prototype.sendMessage = function()

in src/plugins/AMQPLibPlugin.ts [42:79]


    BaseChannel.prototype.sendMessage = function (fields: any, properties: any, content: any) {
      const topic = fields.exchange || '';
      const queue = fields.routingKey || '';
      const peer = `${this.connection.stream.remoteAddress}:${this.connection.stream.remotePort}`;
      const span = ContextManager.current.newExitSpan(
        'RabbitMQ/' + topic + '/' + queue + '/Producer',
        Component.RABBITMQ_PRODUCER,
      );

      span.start();

      try {
        span.inject().items.forEach((item) => {
          fields.headers[item.key] = item.value;
        });

        span.component = Component.RABBITMQ_PRODUCER;
        span.layer = SpanLayer.MQ;
        span.peer = peer;

        span.tag(Tag.mqBroker((this.connection.stream.constructor.name === 'Socket' ? 'amqp://' : 'amqps://') + peer));

        if (topic) span.tag(Tag.mqTopic(topic));

        if (queue) span.tag(Tag.mqQueue(queue));

        const ret = _sendMessage.call(this, fields, properties, content);

        span.stop();

        return ret;
      } catch (e) {
        span.error(e);
        span.stop();

        throw e;
      }
    };