From 7a184a8bbc52635afa22967074b06458024d45c5 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Mon, 8 May 2023 14:35:07 -0400 Subject: [PATCH] Fix/tracing cleanup (#342) * tracing usability * fix bug in prev commit * more cleanup * further tracing UI cleanup --- lib/session/call-session.js | 14 +++++++++----- lib/tasks/config.js | 14 ++++++++------ lib/tasks/task.js | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 35515734..8681011c 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -761,6 +761,7 @@ class CallSession extends Emitter { } if (!skip) { const {span, ctx} = this.rootSpan.startChildSpan(`verb:${task.summary}`); + span.setAttributes({'verb.summary': task.summary}); task.span = span; task.ctx = ctx; await task.exec(this, resources); @@ -782,19 +783,22 @@ class CallSession extends Emitter { } if (0 === this.tasks.length && this.requestor instanceof WsRequestor && !this.callGone) { - let span; + //let span; try { - const {span} = this.rootSpan.startChildSpan('waiting for commands'); - const {reason, queue, command} = await this._awaitCommandsOrHangup(); + //const {span} = this.rootSpan.startChildSpan('waiting for commands'); + //const {reason, queue, command} = await this._awaitCommandsOrHangup(); + /* span.setAttributes({ 'completion.reason': reason, 'async.request.queue': queue, 'async.request.command': command }); span.end(); + */ + await this._awaitCommandsOrHangup(); if (this.callGone) break; } catch (err) { - span.end(); + //span.end(); this.logger.info(err, 'CallSession:exec - error waiting for new commands'); break; } @@ -1288,8 +1292,8 @@ class CallSession extends Emitter { this.wakeupResolver = null; } else { - const {span} = this.rootSpan.startChildSpan('async command'); const {queue, command} = resolution; + const {span} = this.rootSpan.startChildSpan(`recv cmd: ${command}`); span.setAttributes({ 'async.request.queue': queue, 'async.request.command': command diff --git a/lib/tasks/config.js b/lib/tasks/config.js index a7737fbf..84927800 100644 --- a/lib/tasks/config.js +++ b/lib/tasks/config.js @@ -30,6 +30,12 @@ class TaskConfig extends Task { if (this.bargeIn[k]) this.gatherOpts[k] = this.bargeIn[k]; }); } + + if (this.data.reset) { + if (typeof this.data.reset === 'string') this.data.reset = [this.data.reset]; + } + else this.data.reset = []; + if (this.bargeIn.sticky) this.autoEnable = true; this.preconditions = (this.bargeIn.enable || this.record?.action || this.listen?.url || this.data.amd) ? TaskPreconditions.Endpoint : @@ -47,11 +53,7 @@ class TaskConfig extends Task { const phrase = []; /* reset recognizer and/or synthesizer to default values? */ - if (this.data.reset) { - if (typeof this.data.reset === 'string') this.data.reset = [this.data.reset]; - phrase.push(`reset ${this.data.reset.join(',')}`); - } - else this.data.reset = []; + if (this.data.reset.length) phrase.push(`reset ${this.data.reset.join(',')}`); if (this.bargeIn.enable) phrase.push('enable barge-in'); if (this.hasSynthesizer) { @@ -70,7 +72,7 @@ class TaskConfig extends Task { } if (this.data.amd) phrase.push('enable amd'); if (this.notifyEvents) phrase.push(`event notification ${this.notifyEvents ? 'on' : 'off'}`); - return `${this.name}{${phrase.join(',')}`; + return `${this.name}{${phrase.join(',')}}`; } async exec(cs, {ep} = {}) { diff --git a/lib/tasks/task.js b/lib/tasks/task.js index 2583d7f7..00f0053a 100644 --- a/lib/tasks/task.js +++ b/lib/tasks/task.js @@ -155,7 +155,7 @@ class Task extends Emitter { if (this.actionHook) { const type = this.name === TaskName.Redirect ? 'session:redirect' : 'verb:hook'; const params = results ? Object.assign(this.cs.callInfo.toJSON(), results) : this.cs.callInfo.toJSON(); - const span = this.startSpan(type, {'hook.url': this.actionHook}); + const span = this.startSpan(`${type} (${this.actionHook})`); const b3 = this.getTracingPropagation('b3', span); const httpHeaders = b3 && {b3}; span.setAttributes({'http.body': JSON.stringify(params)});