some tracing cleanup

This commit is contained in:
Dave Horton
2022-03-31 08:03:17 -04:00
parent 6072dcf11c
commit f280f9436f
2 changed files with 6 additions and 6 deletions

View File

@@ -184,9 +184,9 @@ class TaskGather extends Task {
this._killAudio(cs);
this.ep.removeAllListeners('dtmf');
clearTimeout(this.interDigitTimer);
this._resolve('killed');
this.playTask?.span.end();
this.sayTask?.span.end();
this._resolve('killed');
}
updateTimeout(timeout) {

View File

@@ -44,7 +44,6 @@ class TaskSay extends Task {
this.logger.info({vendor, language, voice}, 'TaskSay:exec');
this.ep = ep;
let span;
try {
if (!credentials) {
writeAlerts({
@@ -58,11 +57,12 @@ class TaskSay extends Task {
let lastUpdated = false;
/* otel: trace time for tts */
span = this.startSpan('tts-generation', {
const {span} = this.startChildSpan('tts-generation', {
'tts.vendor': vendor,
'tts.language': language,
'tts.voice': voice
});
this.ttsSpan = span;
const filepath = (await Promise.all(this.text.map(async(text) => {
if (this.killed) return;
@@ -91,10 +91,10 @@ class TaskSay extends Task {
updateSpeechCredentialLastUsed(credentials.speech_credential_sid)
.catch(() => {/*already logged error */});
}
span.setAttributes({'tts.cached': servedFromCache});
this.ttsSpan.setAttributes({'tts.cached': servedFromCache});
return filePath;
}))).filter((fp) => fp && fp.length);
span?.end();
this.ttsSpan?.end();
this.logger.debug({filepath}, 'synthesized files for tts');
while (!this.killed && (this.loop === 'forever' || this.loop--) && this.ep?.connected) {
@@ -112,7 +112,7 @@ class TaskSay extends Task {
} while (!this.killed && ++segment < filepath.length);
}
} catch (err) {
span?.end();
this.ttsSpan?.end();
this.logger.info(err, 'TaskSay:exec error');
}
this.emit('playDone');