From 57b9c6fdda9084ef1a387e0718e759b2385f0368 Mon Sep 17 00:00:00 2001 From: Pavel Puchkov <0x6368656174@gmail.com> Date: Mon, 10 Nov 2025 21:44:07 +1100 Subject: [PATCH] fix: fix MessageQueue._publish Otel span ending Signed-off-by: Pavel Puchkov --- src/publisher/message-queues.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/publisher/message-queues.ts b/src/publisher/message-queues.ts index 2d307cea1..c7d4a1999 100644 --- a/src/publisher/message-queues.ts +++ b/src/publisher/message-queues.ts @@ -173,12 +173,15 @@ export abstract class MessageQueue extends EventEmitter { throw e; } finally { messages.forEach(m => { - // We're finished with both the RPC and the whole publish operation, - // so close out all of the related spans. - rpcSpan?.end(); tracing.PubsubEvents.publishEnd(m); - m.parentSpan?.end(); }); + + // We're finished with both the RPC and the whole publish operation, + // so close out all of the related spans. + new Set(messages.map(m => m.parentSpan)).forEach(parentSpan => { + parentSpan?.end(); + }); + rpcSpan?.end(); } } }