feat(audio): add latency metrics collection for input and output

Add granular metrics collection for audio processing latency in both input and output paths. This enables better performance monitoring through histograms.

Also update build tags to include ARM platform and rename UI label for clarity.
This commit is contained in:
Alex P 2025-08-28 00:35:51 +00:00
parent 758bbbfff6
commit f9adb4382d
4 changed files with 25 additions and 3 deletions

View File

@ -110,6 +110,12 @@ func (aim *AudioInputManager) WriteOpusFrame(frame []byte) error {
atomic.AddInt64(&aim.framesSent, 1)
aim.recordFrameProcessed(len(frame))
aim.updateLatency(processingTime)
// Record latency to granular metrics collector for histogram
if granularCollector := GetGranularMetricsCollector(); granularCollector != nil {
granularCollector.RecordInputLatency(processingTime)
}
return nil
}
@ -145,6 +151,12 @@ func (aim *AudioInputManager) WriteOpusFrameZeroCopy(frame *ZeroCopyAudioFrame)
atomic.AddInt64(&aim.framesSent, 1)
aim.recordFrameProcessed(frame.Length())
aim.updateLatency(processingTime)
// Record latency to granular metrics collector for histogram
if granularCollector := GetGranularMetricsCollector(); granularCollector != nil {
granularCollector.RecordInputLatency(processingTime)
}
return nil
}

View File

@ -103,6 +103,11 @@ func (aom *AudioOutputIPCManager) WriteOpusFrame(frame *ZeroCopyAudioFrame) erro
aom.recordFrameProcessed(frame.Length())
aom.updateLatency(processingTime)
// Record latency to granular metrics collector for histogram
if granularCollector := GetGranularMetricsCollector(); granularCollector != nil {
granularCollector.RecordOutputLatency(processingTime)
}
return nil
}
@ -132,6 +137,11 @@ func (aom *AudioOutputIPCManager) WriteOpusFrameZeroCopy(frame *ZeroCopyAudioFra
aom.recordFrameProcessed(len(frameData))
aom.updateLatency(processingTime)
// Record latency to granular metrics collector for histogram
if granularCollector := GetGranularMetricsCollector(); granularCollector != nil {
granularCollector.RecordOutputLatency(processingTime)
}
return nil
}

View File

@ -1,5 +1,5 @@
//go:build cgo
// +build cgo
//go:build cgo || arm
// +build cgo arm
package audio

View File

@ -478,7 +478,7 @@ export default function AudioMetricsDashboard() {
<div className="mb-2 flex items-center gap-2">
<MdMic className="h-4 w-4 text-green-600 dark:text-green-400" />
<span className="font-medium text-slate-900 dark:text-slate-100">
Microphone Input Config
Audio Input Config
</span>
</div>
<div className="space-y-2 text-sm">