diff --git a/src/lang/std/engineConnection.ts b/src/lang/std/engineConnection.ts index 33605d3e9..8104f9d3a 100644 --- a/src/lang/std/engineConnection.ts +++ b/src/lang/std/engineConnection.ts @@ -193,15 +193,17 @@ export class EngineConnection { ) } - Promise.all([ - handshakeSpan.promise, - iceSpan.promise, - dataChannelSpan.promise, - mediaTrackSpan.promise, - ]).then(() => { - console.log('All spans finished, reporting') - webrtcMediaTransaction?.finish() - }) + if (this.shouldTrace()) { + Promise.all([ + handshakeSpan.promise, + iceSpan.promise, + dataChannelSpan.promise, + mediaTrackSpan.promise, + ]).then(() => { + console.log('All spans finished, reporting') + webrtcMediaTransaction?.finish() + }) + } this.onWebsocketOpen(this) }) @@ -302,7 +304,9 @@ export class EngineConnection { this.pc.addEventListener('connectionstatechange', (event) => { if (this.pc?.iceConnectionState === 'connected') { - iceSpan.resolve?.() + if (this.shouldTrace()) { + iceSpan.resolve?.() + } } })