Skip to content

Commit ba30818

Browse files
authored
fix: Updated MessageConsumerSubscriber to end transaction created for a given message consumption (#3503)
1 parent 63e531b commit ba30818

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/subscribers/message-consumer.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ class MessageConsumerSubscriber extends Subscriber {
6565
}
6666
}
6767

68+
/**
69+
* Ends the transaction created for the consumption callback.
70+
*/
71+
asyncEnd() {
72+
const ctx = this.agent.tracer.getContext()
73+
ctx?.transaction?.end()
74+
}
75+
6876
enable() {
6977
super.enable()
7078
this.channel.asyncStart.bindStore(this.store, (data) => {
@@ -83,9 +91,8 @@ class MessageConsumerSubscriber extends Subscriber {
8391
/**
8492
* Used to create a transaction for every consumption callback.
8593
*
86-
* @param {object} data event passed to asyncStart handler
8794
*/
88-
asyncStart(data) {
95+
asyncStart() {
8996
const ctx = this.agent.tracer.getContext()
9097
const tx = ctx?.transaction
9198
tx.setPartialName(this.name)

test/versioned/amqplib/callback.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ test('amqplib callback instrumentation', async function (t) {
323323

324324
channel.ack(msg)
325325
produceTx.end()
326-
consumeTx.end()
327326
resolve()
328327
})
329328
helper.runInTransaction(agent, function (tx) {
@@ -373,7 +372,6 @@ test('amqplib callback instrumentation', async function (t) {
373372

374373
channel.ack(msg)
375374
produceTx.end()
376-
consumeTx.end()
377375
resolve()
378376
})
379377

0 commit comments

Comments
 (0)