pub struct TelemetryEvent {
pub name: String,
pub severity: Severity,
pub body: Option<String>,
pub attributes: Vec<Attribute>,
pub timestamp_ns: Option<u64>,
pub span_id: Option<u64>,
}Expand description
A discrete telemetry event.
Exported as one OTLP log record whose event_name is name, following the
OTel logs data model (events are log records with a top-level event name).
An unnamed Info record: a plain log record once it has a body (see SPEC.md).
Fields§
§name: StringEvent name. LiveKit-defined events use the lk. prefix (e.g. lk.ping); see SPEC.md.
severity: SeverityHow serious it is (OTLP severity number and text).
body: Option<String>Optional human-readable message (the OTLP log record body).
attributes: Vec<Attribute>The record’s own attributes; the session’s are added when it is captured.
timestamp_ns: Option<u64>Wall-clock time in nanoseconds since the Unix epoch. None is stamped when the record is
queued, never at export.
span_id: Option<u64>The in-flight span this record belongs to (a handle from begin_span), if any. The trace
id is always the session’s and is attached by the core.
Implementations§
Source§impl TelemetryEvent
impl TelemetryEvent
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
An Info event without attributes, stamped when emitted.
Sourcepub fn with_severity(self, severity: Severity) -> Self
pub fn with_severity(self, severity: Severity) -> Self
The same event with severity.
Sourcepub fn with_attribute(
self,
key: impl Into<String>,
value: impl Into<AttributeValue>,
) -> Self
pub fn with_attribute( self, key: impl Into<String>, value: impl Into<AttributeValue>, ) -> Self
The same event with one more attribute.
Sourcepub fn custom(name: &str, attributes: Vec<Attribute>) -> Self
pub fn custom(name: &str, attributes: Vec<Attribute>) -> Self
A consumer’s own event. Always namespaced under custom. so it can never be mistaken for
a LiveKit-defined lk.* event, and the backend can filter or quota it separately;
attributes keep the caller’s namespace (acme.checkout.step).
Sourcepub fn size_hint(&self) -> usize
pub fn size_hint(&self) -> usize
Rough encoded size in bytes — strings plus a fixed overhead per record and per attribute.
Drives the byte bounds on queue flushing and request size; cheaper than encoding and close
enough for both. The name is counted twice (event_name and otel.event.name), and again
when it doubles as the body.
Counts the attributes the record carries: once queued, that includes its session’s
(lk.room.*, lk.participant.*, session.id) and the app’s correlation attributes, all
taken at capture. Pipeline-wide attributes are added at export and are not counted.
Trait Implementations§
Source§impl Clone for TelemetryEvent
impl Clone for TelemetryEvent
Source§impl Debug for TelemetryEvent
impl Debug for TelemetryEvent
Source§impl Default for TelemetryEvent
impl Default for TelemetryEvent
Source§impl From<DeviceEvent> for TelemetryEvent
impl From<DeviceEvent> for TelemetryEvent
Source§fn from(event: DeviceEvent) -> Self
fn from(event: DeviceEvent) -> Self
The SPEC.md event for a device event, with its display body.