transports(daily): don't send empty metrics

This commit is contained in:
Aleix Conchillo Flaqué
2024-07-23 10:50:36 -07:00
parent 69f64899fe
commit f41c2b3c9f

View File

@@ -678,12 +678,15 @@ class DailyOutputTransport(BaseOutputTransport):
await self._client.send_message(frame)
async def send_metrics(self, frame: MetricsFrame):
metrics = {}
if frame.ttfb:
metrics["ttfb"] = frame.ttfb
if frame.processing:
metrics["processing"] = frame.processing
message = DailyTransportMessageFrame(message={
"type": "pipecat-metrics",
"metrics": {
"ttfb": frame.ttfb or [],
"processing": frame.processing or [],
},
"metrics": metrics
})
await self._client.send_message(message)