mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
tts stream should save tts.response_time metric (#1086)
* tts stream should save tts.response_time metric * wip
This commit is contained in:
@@ -213,7 +213,7 @@ class TaskSay extends TtsTask {
|
|||||||
ep.once('playback-start', (evt) => {
|
ep.once('playback-start', (evt) => {
|
||||||
this.logger.debug({evt}, 'Say got playback-start');
|
this.logger.debug({evt}, 'Say got playback-start');
|
||||||
if (this.otelSpan) {
|
if (this.otelSpan) {
|
||||||
this._addStreamingTtsAttributes(this.otelSpan, evt);
|
this._addStreamingTtsAttributes(this.otelSpan, evt, vendor);
|
||||||
this.otelSpan.end();
|
this.otelSpan.end();
|
||||||
this.otelSpan = null;
|
this.otelSpan = null;
|
||||||
if (evt.variable_tts_cache_filename) {
|
if (evt.variable_tts_cache_filename) {
|
||||||
@@ -308,7 +308,7 @@ class TaskSay extends TtsTask {
|
|||||||
this.notifyTaskDone();
|
this.notifyTaskDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
_addStreamingTtsAttributes(span, evt) {
|
_addStreamingTtsAttributes(span, evt, vendor) {
|
||||||
const attrs = {'tts.cached': false};
|
const attrs = {'tts.cached': false};
|
||||||
for (const [key, value] of Object.entries(evt)) {
|
for (const [key, value] of Object.entries(evt)) {
|
||||||
if (key.startsWith('variable_tts_')) {
|
if (key.startsWith('variable_tts_')) {
|
||||||
@@ -322,6 +322,9 @@ class TaskSay extends TtsTask {
|
|||||||
.replace('elevenlabs_', 'elevenlabs.');
|
.replace('elevenlabs_', 'elevenlabs.');
|
||||||
if (spanMapping[newKey]) newKey = spanMapping[newKey];
|
if (spanMapping[newKey]) newKey = spanMapping[newKey];
|
||||||
attrs[newKey] = value;
|
attrs[newKey] = value;
|
||||||
|
if (key === 'variable_tts_time_to_first_byte_ms' && value) {
|
||||||
|
this.cs.srf.locals.stats.histogram('tts.response_time', value, [`vendor:${vendor}`]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete attrs['cache_filename']; //no value in adding this to the span
|
delete attrs['cache_filename']; //no value in adding this to the span
|
||||||
|
|||||||
Reference in New Issue
Block a user