From ffdb7a0bb5ef3ad8bbf84396a6f879d7c37e9a6f Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 8 Jun 2023 13:57:10 -0400 Subject: [PATCH] create transcribe and listen child spans properly for dial (#373) * create transcribe and listen child spans properly for dial * fix prev commit: proper time to start span is in dial exec --- lib/tasks/dial.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/tasks/dial.js b/lib/tasks/dial.js index 7eae9ed8..5beb1c4f 100644 --- a/lib/tasks/dial.js +++ b/lib/tasks/dial.js @@ -166,6 +166,16 @@ class TaskDial extends Task { async exec(cs) { await super.exec(cs); try { + if (this.listenTask) { + const {span, ctx} = this.startChildSpan(`nested:${this.listenTask.summary}`); + this.listenTask.span = span; + this.listenTask.ctx = ctx; + } + if (this.transcribeTask) { + const {span, ctx} = this.startChildSpan(`nested:${this.transcribeTask.summary}`); + this.transcribeTask.span = span; + this.transcribeTask.ctx = ctx; + } if (this.data.amd) { this.startAmd = cs.startAmd; this.stopAmd = cs.stopAmd; @@ -223,10 +233,12 @@ class TaskDial extends Task { if (this.callSid) sessionTracker.remove(this.callSid); if (this.listenTask) { await this.listenTask.kill(cs); + this.listenTask.span.end(); this.listenTask = null; } if (this.transcribeTask) { await this.transcribeTask.kill(cs); + this.transcribeTask.span.end(); this.transcribeTask = null; } this.notifyTaskDone();