cold-soccer-35030
11/21/2025, 5:07 AMtall-airline-16756
11/21/2025, 5:07 AMtall-airline-16756
11/21/2025, 5:08 AMworker.active_jobs. You can implement a load_fnc in WorkerOptions that returns a scaled value based on len(worker.active_jobs) to track or enforce concurrency limits. Example concept:
◦ compute load as min(len(worker.active_jobs) / <max_concurrent>, 1.0) and set load_threshold.
• You can also inspect worker.active_jobs inside the job lifecycle to log or emit counts when jobs start/finish.
Built-in and session metrics you can collect
• LiveKit emits structured metrics for LLM, STT, TTS, and turn detection (e.g., duration, ttft, audio_duration, ttfb, end_of_utterance_delay). Subscribe to the session metrics event (metrics_collected) to capture these per-call metrics and include the worker id or room id when logging.
• Use UsageCollector to aggregate LLM/STT/TTS usage across sessions for cost and usage summaries.
How to surface metrics centrally
• Emit metrics from your agent when jobs start/end (concurrent count) and on metrics_collected events for per-call telemetry.
• Forward logs/metrics to an observability backend (Prometheus/Grafana, Datadog, CloudWatch, etc.) via your chosen exporters.
• Enable OpenTelemetry tracing if you need distributed traces for worker lifecycle and request flows.
LiveKit Cloud and CLI tools
• If you use LiveKit Cloud, view realtime session counts, worker load, running workers, and deployment metrics in the dashboard.
• Use lk agent logs to stream runtime logs from deployed agents for quick inspection.
Custom metrics
• Define and emit custom metrics (label them with worker id and room id) so you can chart concurrent calls per worker and any app-specific KPIs in your monitoring system.
If you want, I can:
• Show a small code snippet to emit concurrent-job counts to Prometheus or log them when jobs start/end.
• Suggest which labels/metrics to collect (examples: worker_id, room_id, active_jobs, call_duration, llm_tokens) for best observability.
Which follow-up would you like: a Prometheus example, a logging-only snippet, or recommended metric names/labels?
Sources: Worker options | LiveKit Docs | Job lifecycle | LiveKit Docs | Logs, metrics, and telemetry | LiveKit Docs | Deploying to production | LiveKit Docs | Log collection | LiveKit Docs