From 32476571fb860650e6c0db828aa67f72fc166872 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 24 Apr 2023 17:57:05 +0100 Subject: [PATCH] End spans when calls are replaced by a different call --- src/otel/OTelGroupCallMembership.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/otel/OTelGroupCallMembership.ts b/src/otel/OTelGroupCallMembership.ts index 8c31fba..9f7573e 100644 --- a/src/otel/OTelGroupCallMembership.ts +++ b/src/otel/OTelGroupCallMembership.ts @@ -210,7 +210,12 @@ export class OTelGroupCallMembership { for (const callTrackingInfo of this.callsByCallId.values()) { const userCalls = calls.get(callTrackingInfo.userId); - if (!userCalls || !userCalls.has(callTrackingInfo.deviceId)) { + if ( + !userCalls || + !userCalls.has(callTrackingInfo.deviceId) || + userCalls.get(callTrackingInfo.deviceId).callId !== + callTrackingInfo.call.callId + ) { callTrackingInfo.span.end(); this.callsByCallId.delete(callTrackingInfo.call.callId); }