Expand description
§LiveKit Telemetry
Important: This is an internal crate for client telemetry in LiveKit client SDKs and is not meant to be used directly.
It currently holds the shared data model and its encoding:
- Records.
TelemetryEvent,LogRecord,Attribute/AttributeValue,SeverityandSpanOutcome: the events, log lines and span outcomes a platform SDK hands over. - Buffers. Bounded, drop-oldest queues for records and spans, each filed under the session (trace) it belongs to; every drop is counted.
- Encoding. OTLP/HTTP protobuf logs and traces,
using the
opentelemetry-protomessage types only (no gRPC stack). - Transport and destinations.
TelemetryTransport, the seam that moves an encoded batch off the device (NetTransportoverlivekit-netwith thenetfeature), and the routing that turns a Room’s server URL and token into its LiveKit Cloud ingest URL and credential.
The pipeline that batches, caches and uploads records is not part of the crate yet.
Event names, attributes and span rules are defined in SPEC.md. It is the contract
for the whole crate, including the parts not implemented yet.
Collector responses are limited to 65,536 decoded body bytes. Overflow is retryable and preserves a valid Retry-After delay; no truncated body is used to classify acceptance or a project refusal. NetTransport uses livekit-net’s opt-in bounded client view. Its native backend stops during the read, including gzip decoding; ordinary HTTP requests remain uncapped. A host TelemetryTransport must enforce the same limit in its reader. The core also checks already-buffered custom/FFI/pulled responses, but this cannot bound allocation that already occurred in the host.
Structs§
- Attribute
- A key/value attribute on an event or on the resource.
- Device
State - What the host observes about the device; pushed with
Telemetry::set_device_statewhenever anything changes. - Export
Request - One fully composed OTLP/HTTP export request.
- Export
Response - What the collector answered. A transport moves bytes both ways and never interprets them:
status classification,
Retry-After, thegoogle.rpc.Statusbody and the Cloud “disabled” contract are read once, here, for every platform (Verdict::of). - File
Cache - On-disk
BatchCache: one file per encoded batch, so a crash or an offline shutdown loses nothing and the next launch replays what is left. - LogRecord
- A log line as the platform captured it, where it happened. The core turns it into a record:
semconv
code.*attributes,lk.log.source,lk.log.logger, filed under the span’s session. Stamptimestamp_nsat capture; the record may cross an executor hop before it gets here. - Memory
Cache - In-memory
BatchCache: batches that could not be uploaded wait for the next attempt, bounded bymax_bytesand 512 batches (MAX_BATCHES, oldest evicted). The newest batch always stays, even when it alone is larger thanmax_bytes. Lost with the process. - RtcStat
- One entry of a WebRTC
RTCStatsReport, as the platform got it: the entry’stype,idand its standard members (W3C webrtc-stats names; nested maps flattened with a dot, e.g.qualityLimitationDurations.cpu). Numbers may arrive asInt,Doubleor numericStr. - RtcStats
Sample - One reading of a track’s RTP statistics, as
getStats()reports them. - Telemetry
Event - A discrete telemetry event.
- Telemetry
Stats - Pipeline health as seen by the SDK:
Telemetry::stats.
Enums§
- AppState
- Whether the app is in front of the user.
- Attribute
Value - Attribute value: the scalar subset of OTLP
AnyValue. - Audio
Output - Where the audio goes, in platform-neutral terms (AVAudioSession port types, Android’s
AudioDevice; the web’sMediaDeviceInfo.kindonly ever givesother). - Audio
Route Reason - Why the audio route changed, in platform-neutral terms (AVAudioSession reasons; Android’s
device added/removed callbacks map to
NewDevice/OldDeviceUnavailable). - Capture
Device - Which capture device a failure is about.
- Capture
Failure - Why a capture device could not be used: the
getUserMediafailure taxonomy, which every platform maps onto (authorization status,onCameraDisconnected,NotReadableError, …). - Device
Event - Things that happen to the device mid-call and explain what the media did next. Not state
(see
DeviceState): each one is a record with a display body. - Export
Error - Why a transport could not get an answer. A 4xx/5xx is an answer, not an error: return it as an
ExportResponseand the core classifies it. - LogSource
- Where a log line came from. WebRTC is chatty at warn, so only its errors become records; the SDK and the core use the configured floor.
- Memory
Pressure - Memory pressure as the OS reports it (
DISPATCH_MEMORYPRESSURE_*,onTrimMemorylevels:RUNNING_LOW/BACKGROUND→ warning,RUNNING_CRITICAL/COMPLETE→ critical). - Network
Type - The active network path, in OTel
network.connection.typeterms. - Severity
- Event severity, mapped onto the OTel severity numbers (
TRACE=1 …ERROR=17). - Span
Outcome - How an attempt ended. OTel status knows only
Unset/Ok/Error, soCancelledtravels asstatus = Unsetplus thelk.outcomeattribute — every span carrieslk.outcomeso rollups never have to infer it (a user hanging up mid-connect is not a failure). - Stream
Direction - Received (inbound) or sent (outbound) media.
- Telemetry
Status - What the upload policy is doing right now.
- Thermal
State - Thermal pressure as the OS reports it (
ProcessInfo.thermalState,PowerManagerthermal status, the web Compute Pressure API — all four share this vocabulary). - Track
Kind - Audio or video.
Constants§
- ENDPOINT_
OVERRIDE_ ENV - The environment variable that points every upload at a collector of your own — a local
OpenTelemetry collector for end-to-end tests. Not part of any platform API: set it in the
test process’s environment before the pipeline starts. Either a URL with a
logspath segment (its traces URL replaces that segment withtraces) or a base URL (http://localhost:4318, OTLP paths/v1/logsand/v1/tracesare appended).
Traits§
- Batch
Cache - Queue of encoded OTLP batches between the exporter (
Exporter) and the transport. - Telemetry
Transport - Moves an encoded batch off the device and hands back whatever came back.