Repository navigation
feat(uniffi): expose the telemetry core - #1396
Conversation
a951a3b to
6f17b80
Compare
6aba1b6 to
a9ec8d5
Compare
a9ec8d5 to
3d50ec6
Compare
Owning #1396 wrapper migration in the cumulative review tree. Keep native SID and SpanTrack APIs unchanged; Kotlin generation/compilation remains an explicit gate. Co-authored-by: omnigent <noreply@omnigent.ai>
|
In response to your review: The documentation states that Off disables console forwarding but keeps telemetry copying enabled (89f67a5b, c66d3b29). Credential masking covers log bodies, not event bodies or attributes. |
…ipeline-tests Integrates blaze/telemetry-stack/5-pipeline at 57b54a9 so this stage contains its base by ordinary ancestry. Semantic conflict, no textual one: the base stage changed Telemetry::record_stats_in to take one report's samples as a Vec (vote D07); this stage's test-only helper Telemetry::record_stats still passed a single sample, so the test build failed. The helper now passes vec![sample], as published #1396 already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
xianshijing-lk
left a comment
There was a problem hiding this comment.
Review findings for the current PR head.
| /// Hand `queued` out, unless the queue is finished or its exporter gave up on it. | ||
| fn serve(&self, queued: QueuedExport) -> Option<PendingExport> { | ||
| let mut inflight = self.inflight.lock().unwrap_or_else(|e| e.into_inner()); | ||
| let opted_out = self.process.load(Ordering::SeqCst) && global::is_disabled(); |
There was a problem hiding this comment.
P2 — Coordinate request handoff with opt-out. Could request handoff be ordered with telemetry_disable()? serve() checks the disabled flag, then records and returns the request while holding only the queue lock. Opt-out does not take that lock. I reproduced a schedule where telemetry_disable() returns after the check but before handoff, and serve() still returns the request. The host can then upload it after opt-out returns. Please add a regression test and define how opt-out handles a request already handed to the host. A host-side telemetry_is_disabled() check is useful, but it needs to be coordinated with the send; checking and then posting still leaves a race.
There was a problem hiding this comment.
Reproduced for a hand-out whose check ran before the opt-out, and a hand-out that starts after the opt-out returns nothing. d913d8a3 documents both cases and the host rule, because the core has no way to recall a request that the host holds.
| ) -> Result<(), TelemetryError> { | ||
| let transport: Arc<dyn TelemetryTransport> = match transport { | ||
| Some(transport) => transport, | ||
| None => Arc::new(NetTransport::from_registry().ok_or(TelemetryError::NoTransport)?), |
There was a problem hiding this comment.
P2 — Check opt-out before resolving the transport. When transport is None, this resolves the registered HTTP client before checking whether telemetry is disabled. In core-modules builds without livekit-net/native, that lookup returns None if the host has not registered a client. A configure after opt-out then returns NoTransport without running refusal cleanup, contrary to the documented Ok behavior, and can leave the supplied storage directory uncleared. Please handle the disabled case before resolving the optional transport.
| pub fn telemetry_disable() { | ||
| // The revocation holds on return; the purge then runs on the lifecycle, in turn. | ||
| let purge = global::disable(); | ||
| LIFECYCLE.send(Command::Purge(Box::pin(async move { |
There was a problem hiding this comment.
P3 — Avoid starting the runtime when there is nothing to purge. LIFECYCLE.send() starts the lifecycle when none exists. So opting out before any telemetry is configured can create the process runtime and two long-lived tasks, even when there is nothing to purge. Could the opt-out path avoid starting them when there are no live generations or stored directories? Preserve the purge path when a direct telemetry pipeline does exist.
There was a problem hiding this comment.
Reproduced: an opt-out before any configure starts the lifecycle, and a later shutdown ends it. We keep one ordered cleanup path for now, because the purge must also cover pipelines that the FFI did not install.
| //! | ||
| //! What a platform calls, and when: | ||
| //! | ||
| //! - SDK init: [`telemetry_configure`] (or [`telemetry_configure_pulled`] where foreign callbacks |
There was a problem hiding this comment.
P3 — Add logger setup to the platform checklist. The integration checklist does not mention log_forward_bootstrap(). Without it, the Rust logger is not installed and core warnings and errors will not be copied into telemetry, even though configure succeeds. Please add logger setup to the “What a platform calls, and when” list.
There was a problem hiding this comment.
Added in d913d8a3: the checklist now starts with log_forward_bootstrap and says what is missing without it.
| Future<void> serve(TelemetryExportQueue queue, List<ExportRequest> sink, int count) async { | ||
| for (var i = 0; i < count; i++) { | ||
| var pending = queue.tryNext(); | ||
| while (pending == null) { |
There was a problem hiding this comment.
P3 — Bound the Dart test's polling loop. If the expected request never arrives, serve() polls indefinitely and the test fails only when the test framework times out. Please add a deadline so the test fails promptly with a useful message.
There was a problem hiding this comment.
Done in d913d8a3: the poll has a deadline and names the missing request. A control with one absent request fails in about two seconds.
| set -e | ||
| # cargo-ndk 4.x requires Cargo's plugin context, including the CARGO variable. | ||
| if ! cargo ndk --help >/dev/null 2>&1; then | ||
| cargo install --locked cargo-ndk |
There was a problem hiding this comment.
P3 — Pin the cargo-ndk version. cargo install --locked cargo-ndk locks cargo-ndk's dependencies, but installs whichever cargo-ndk version is current. The existing cargo ndk --help check also accepts any version already installed. Please pin the version and check that an existing installation matches it, so Android builds use a predictable toolchain.
There was a problem hiding this comment.
Done in d913d8a3: the task pins cargo-ndk 4.1.2, and a different installed version is replaced. That version built the Android package with NDK 29.
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Checks `generate_proto.sh` in a scratch copy, never in `src/`: |
There was a problem hiding this comment.
P3 — Run the protocol generator check in CI. This script checks generator failures and output reproducibility, but no workflow runs it. Please add it to CI so these checks run automatically, or label it clearly as a manual check in the script header.
There was a problem hiding this comment.
No workflow runs that script, so d913d8a3 labels it as a manual step in its header. We did not add a CI step in this round.
| async fn main() { | ||
| env_logger::init(); | ||
| let url = env::var("LK_URL").unwrap_or_else(|_| "ws://localhost:7880".to_owned()); | ||
| let token = env::var("LK_TOKEN").unwrap_or_default(); |
There was a problem hiding this comment.
Nit — Check for a token in the cloud example. When LK_URL is set without LK_TOKEN, the example continues with an empty token and will not have the observability grant. Please fail with a clear message for that cloud configuration. The local collector path can continue to work without a token.
There was a problem hiding this comment.
Reproduced. With LK_URL set and no LK_TOKEN, d913d8a3 exits with a clear message, and the collector override path still needs no token.
xianshijing-lk
left a comment
There was a problem hiding this comment.
most of the comments not blocking, lgtm assuming you will address them
There was a problem hiding this comment.
Devin Review found 2 new potential issues.
⚠️ 1 issue in files not directly in the diff
⚠️ New grant APIs lack documentation
AgentDatabaseGrants and its methods lack doc comments, as do can_sql and with_agent_database_grants. Repository rules require descriptions for new public types and functions.
There was a problem hiding this comment.
🔴 Shutdown loses records captured during encoding
If a scope captures records during enqueue, its entry-time counts leave those records queued. The shutdown drain runs one encoding turn, then exits; the remaining records disappear with the pipeline.
(Refers to this code)
Learn more
The exporter keeps records and finished spans in memory until enqueue encodes them into the write-ahead cache. Its new entry-time counts prevent a busy producer from prolonging one encoding turn. During shutdown, drain calls export_pending once and then stops the exporter. A room can emit while that turn writes a batch, leaving records outside the snapshot unencoded when the exporter exits. This also affects spans finished during encoding.
Example: A shutdown starts with one queued event. While its cache write runs, a room emits another event. The first enters the cache, but the second stays in the store; shutdown returns and dropping the pipeline loses it.
Recommended fix: Make Exporter::drain repeat bounded encoding turns until the in-memory store and finished spans are empty, within its shutdown bound. Keep normal upload cadence and the bounded per-turn behavior unchanged.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
…(from #1396's 3032ffa, owning stage) The core half of 3032ffa: `global::log_with` runs its builder only when a pipeline is installed, after the registry read guard is released, and files the record under that snapshot. The FFI caller stays in #1396 (reminder 4467541536). Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…(from #1396's 3032ffa, owning stage) The core half of 3032ffa: `global::log_with` runs its builder only when a pipeline is installed, after the registry read guard is released, and files the record under that snapshot. The FFI caller stays in #1396 (reminder 4467541536). Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
## Summary `global`, the process-wide pipeline, and the opt-out. From here #1396 adds only `global::uninstall` and a `Severity` conversion to `livekit-telemetry`, besides the README and `SPEC.md`. Every link below points at the stage that adds the test (the UniFFI ones at #1396). ## Changes - `global`: one pipeline per process, installed once and reachable from anywhere, with the platform's instruments started on it - `global::disable`: the opt-out, in effect before it returns - `device_tests.rs`: the device contract, one test per row - The last temporary `dead_code` expectation removed - A repeated `global::disable` resolves only once the cache is deleted, also while the first call is still purging - `install` and `uninstall` stop the outgoing instruments while their pipeline is still installed, so a last record from `stop` reaches it - The opt-out cancels and awaits every live generation's exporter, running or draining, and no request starts once it returned - The opt-out erases the storage directory of every generation, live or gone, and keeps it on record until it is known to hold nothing; a directory it cannot read is logged and makes the opt-out report the erase incomplete - A configure refused after the opt-out erases its storage directory too, and a `with_cache` pipeline never records the `storage_dir` it ignores - The device tests build on Windows again <details><summary><b>Device contract</b>: every failure scenario → behaviour → max lost → why → test (32 rows)</summary> What can go wrong on a device, and the most it can cost. OTel specifies no client persistence or device policy, so **every row is custom**. **U** = records not yet committed (≤ one flush interval, ≤ 2 048 queued) + open spans (≤ 256) + open RTC windows; **B** = one batch (≤ 512 records); **E** = records evicted or expired, always counted. **N** = records committed to the cache and not yet sent (≤ 4 MiB compressed, ≤ 512 batches, ≤ 24 h old). A batch is committed when the cache's `push` returns (file `fsync`ed, renamed, directory `fsync`ed on Unix); crash points are driven deterministically by test-only fault hooks around every write, fsync, rename, delete and publish. **Max lost:** **0** = nothing; **0 until limits** = nothing until the cache's bounds (4 MiB, 512 files, 24 h) evict, then **E**; **U**, **B**, **E**, **N** as defined above. Every row is **custom** (no OTel spec covers client persistence or device policy); *Why* names the platform behaviour, spec or reason behind the row. | Scenario | Behaviour | Max lost | Why | Test | |---|---|---|---|---| | App to background | RTC windows close, everything committed and the whole cache flushed at once, whatever is left of the interval's allowance | 0 once committed | iOS suspends a backgrounded app within seconds (background execution limits); Android may freeze or kill a cached process | [`background_transition_flushes_while_foreground_waits_for_the_tick`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L2108)<br>[`entering_the_background_flushes_even_with_the_allowance_spent`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1429) | | Killed / crashed (no callback) | nothing waits for a termination callback; committed batches replay next launch | **U** | neither OS guarantees a termination callback (memory-pressure kills, crashes, force-quit) | [`a_crash_loses_only_what_was_not_yet_cached`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L88)<br>[`batch_is_written_before_upload_and_replayed_on_next_start`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1490)<br>[`pre_connect_records_replay_after_a_restart`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/backend_tests.rs#L811) | | Killed after an answer, before the delete | the batch is sent again at the next launch | 0 lost; that batch duplicated | an answer and a file delete cannot be atomic: at-least-once over at-most-once | [`a_crash_between_the_answer_and_the_delete_resends_the_batch_once`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L998) | | Killed while a request is out | the batch is sent again at the next launch | 0 lost; ≤ 1 batch duplicated | a request whose answer never arrived may have been ingested: at-least-once | [`a_batch_in_flight_at_a_crash_is_sent_again_once`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L109) | | Killed mid-write | `.tmp` + `fsync` + rename; a torn `.tmp` removed at open | the uncommitted batch | POSIX `rename(2)` is atomic; `fsync(2)` first, so a crash never exposes a torn file | [`a_write_killed_half_way_leaves_no_partial_batch`](https://github.com/livekit/rust-sdks/blob/1371f6c69159d663092ed2834a385a9a20749c27/livekit-telemetry/src/cache.rs#L1269)<br>[`file_cache_evicts_oldest_beyond_max_bytes_and_drops_stray_tmp`](https://github.com/livekit/rust-sdks/blob/1371f6c69159d663092ed2834a385a9a20749c27/livekit-telemetry/src/cache.rs#L1037) | | Killed at any step of a split (413) | journaled; finished or rolled back at open, before any eviction, at the byte and at the file-count limit; a failure after the commit point is a success (halves published by the next listing); a reconfigure's second cache on the directory never breaks a split in progress (one process-wide split lock); binding a pre-connect batch to its project is the same journaled replace, rolled forward at open once its bound copy is journaled (only that copy names the project) | 0 lost, 0 duplicated | RFC 9110 §15.5.14: the body must shrink; journaling keeps the replace as crash-safe as a push | [`a_split_crashed_at_every_step_loses_and_duplicates_nothing`](https://github.com/livekit/rust-sdks/blob/1371f6c69159d663092ed2834a385a9a20749c27/livekit-telemetry/src/cache.rs#L1102)<br>[`a_split_failing_after_its_commit_point_is_kept_and_purgeable`](https://github.com/livekit/rust-sdks/blob/1371f6c69159d663092ed2834a385a9a20749c27/livekit-telemetry/src/cache.rs#L1154)<br>[`a_second_cache_on_the_directory_never_breaks_a_split_in_progress`](https://github.com/livekit/rust-sdks/blob/1371f6c69159d663092ed2834a385a9a20749c27/livekit-telemetry/src/cache.rs#L1211)<br>[`a_stuck_journal_is_retried_after_a_write_not_every_listing`](https://github.com/livekit/rust-sdks/blob/1371f6c69159d663092ed2834a385a9a20749c27/livekit-telemetry/src/cache.rs#L1245)<br>[`a_crash_while_binding_still_replays_to_the_rooms_project`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/backend_tests.rs#L859) | | Corrupt / truncated cache file | full gzip + CRC check before sending; dropped, counted `corrupt` | that batch (≤ **B**) | storage can truncate or damage files; the gzip CRC-32 (RFC 1952) detects it before upload | [`corrupt_and_stray_cache_files_are_dropped_and_counted`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L181) | | File there but unreadable (file protection, permissions) | kept, retried later; not corrupt | 0 | iOS Data Protection makes files unreadable while the device is locked: not corruption | [`an_inaccessible_batch_is_kept_not_counted_corrupt`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L653) | | Delete fails after acceptance | pending deletion: not sent again this launch (never rebound to a new id either), deleted when possible | 0 lost; each such batch sent once more after a restart | a delete that did not happen must not look like one that did; no resend within the launch | [`a_failed_delete_after_acceptance_is_not_sent_again`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L630)<br>[`an_accepted_batch_awaiting_its_delete_is_not_rebound_and_resent`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/backend_tests.rs#L913) | | Disk full, directory gone, fsync fails | never claimed committed: the file is removed and the batch kept in memory (bounded by `max_cache_bytes`, oldest evicted and counted), still uploaded; `cache.write_errors`; a split that cannot commit keeps the parent | spill evictions (**E**) while alive; the spill on a crash | `ENOSPC` is ordinary on phones, iOS may purge Caches while the app runs, a failed `fsync(2)` leaves durability unknown | [`a_full_disk_keeps_batches_in_memory_and_says_so`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L142)<br>[`a_failed_directory_sync_keeps_the_batch_in_memory_not_half_on_disk`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1029)<br>[`durability_failures_are_errors_not_silent_successes`](https://github.com/livekit/rust-sdks/blob/1371f6c69159d663092ed2834a385a9a20749c27/livekit-telemetry/src/cache.rs#L1296) | | Several processes sharing one storage dir | not supported: each platform passes its own per-app dir; there is no cross-process lock (the split lock is per process) | not tested; ≤ **B** per split in progress, uncounted (another process's recovery can delete its journal); each cached batch may be sent once per process | app sandboxes give each app its own container, and an app's extensions must be given a directory of their own | not tested | | Cache full (4 MiB / 512 files) | oldest evicted, counted (`throttled` during a server pause) | **E** | a bounded on-device footprint; the OS may purge cache directories anyway | [`cache_eviction_is_counted_as_a_drop`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1782)<br>[`file_cache_caps_the_number_of_batches`](https://github.com/livekit/rust-sdks/blob/1371f6c69159d663092ed2834a385a9a20749c27/livekit-telemetry/src/cache.rs#L1059)<br>[`a_hold_longer_than_the_cache_reports_what_it_cost`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1540) | | 24 h age | expired at start and while running | **E** | stale telemetry loses its value; bounds how long a user's data stays on the device | [`batches_older_than_a_day_are_dropped_and_counted_at_start`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L208)<br>[`batches_expire_while_the_app_runs`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L390) | | Clock jump | this launch's batches need the monotonic clock to agree | 0 | users and networks change the wall clock; the monotonic clock cannot jump | [`a_clock_jump_does_not_expire_a_fresh_backlog`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L374) | | Offline | hard hold: nothing attempted, no failure counted; checked before every request, also mid-pass; the soft cap is not scheduled meanwhile | 0 until limits | attempts while offline only cost battery and radio; the OS reports reachability | [`device_holds_record_without_attempting`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L224)<br>[`a_device_change_during_a_pass_stops_its_remaining_requests`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L825)<br>[`a_soft_hold_turning_hard_does_not_spin`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L846) | | Low Data Mode, battery ≤ 10 % unplugged | soft hold; one batch per 60 s on its own clock | 0 until limits | the user asked for less traffic (Low Data Mode, Data Saver); a nearly empty battery | [`device_holds_record_without_attempting`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L224)<br>[`the_soft_hold_cap_is_scheduled_and_splits_count_against_it`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L553) | | Thermal, memory, low power, background, CPU-limited encoder | cadence ×2 … ×4; relief brings the pending tick forward at once; an unknown thermal / low-power reading is neutral and makes no change event | 0 | the OS asks apps to do less under thermal, memory and power pressure; WebRTC reports a CPU-limited encoder | [`device_state_emits_change_events_and_stretches_cadence`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1594)<br>[`cpu_limitation_counter_drives_cadence_pressure`](https://github.com/livekit/rust-sdks/blob/4c3e79da7c2628472629035e2a10aac8b2afdc90/livekit-telemetry/src/rtc.rs#L968)<br>[`relief_brings_the_pending_tick_forward`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1457)<br>[`unknown_thermal_and_low_power_are_silent_and_neutral`](https://github.com/livekit/rust-sdks/blob/4c3e79da7c2628472629035e2a10aac8b2afdc90/livekit-telemetry/src/device.rs#L535) | | Connect / reconnect | soft hold | 0 | signaling and ICE/DTLS own the uplink while a call is set up: telemetry never competes with media | [`uploads_hold_while_connecting_but_never_beyond_the_cap`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1641)<br>[`typed_spans_hold_uploads_while_connecting_and_export_when_ended`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1029) | | A slow collector | the exporter stays responsive (deadlines, commands) while a request is out | 0 | an actor blocked on I/O would miss its deadlines and commands | [`deadlines_are_served_while_a_request_is_out`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L493) | | Shutdown | drains within `export_timeout_ms`, then cancels the request on the wire and stops; the rest stays committed; the device state pushed at install always ships by `flush` + `shutdown` | 0 committed | an SDK must never hold up the app's teardown; bounded by `export_timeout_ms` | [`the_initial_device_state_always_ships_by_flush_and_shutdown`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1211)<br>[`shutdown_during_a_slow_backlog_is_bounded_and_joins_the_exporter`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L533)<br>[`shutdown_drains_every_finished_span_batch`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L2147)<br>[`shutdown_leaves_a_session_summary`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1764) | | Queue overflow, event flood | drop-oldest (2 048), 300 events / 10 min; counted | exactly the dropped | bounded memory, like the OTel batch processor's `maxQueueSize`; drop-oldest keeps the freshest context | [`in_memory_bounds_count_every_drop`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L310)<br>[`queue_overflow_is_counted_by_reason`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1465)<br>[`flood_guard_caps_events_but_not_stats_windows`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1921) | | Notification storm (subscribes, device changes, tokens) | wake-ups only re-evaluate; a new batch only at the tick, the queue threshold or backgrounding; exactly one request allowance per interval while a Room is in a call | 0 | the collector's per-project quota is shared by the fleet: wake-ups must not multiply requests | [`notifications_within_an_interval_never_exceed_one_allowance`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1365) | | Backlog with no call | not metered: once no Room is in a call (none connected, or all disconnected) each pass sends the whole cache | 0 | no media to protect: drain while the app is running | [`the_allowance_applies_only_while_a_room_is_in_a_call`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1445) | | The core's own warnings and errors | copied by the log forwarder (`livekit*` targets, never `livekit_telemetry*`) wherever the platform calls `log_forward_bootstrap` (Swift's default `OSLogger` with `ffi: true` does), whatever level it passes — that level filters only the console forwarding; platforms must not feed forwarded Rust entries to `telemetry_log`; any compact JWT (three base64url segments decoding to JSON, whatever the header's encoding, also inside punctuation such as `(...<jwt>)`) masked as `<jwt>`, bearer and `token` credential values (`token=`, `"token": "…"`, quoted or spaced) as `<redacted>`; console entry unchanged | — | the core's own failures are otherwise invisible; Rust allows one global logger per process | `only_the_cores_own_warnings_and_errors_are_copied` (added in #1396)<br>`the_platforms_level_filters_the_console_not_the_telemetry_copy` (added in #1396)<br>`tokens_in_copied_records_are_masked` (added in #1396)<br>`the_console_entry_is_what_it_always_was` (added in #1396) _(lands in #1396)_ | | Server-requested delay across a restart | a `Retry-After` / `RetryInfo` pause is held in memory only: after a relaunch each project gets one request (once its token is handed over) before a new 429/503 pauses it again | 0 lost (the throttled batch stays cached); ≤ 1 early request per project per relaunch; not tested | RFC 9110 §10.2.3 and RFC 6585 §4 ask the client to wait; one probe per relaunch is the cost of not persisting the deadline | not tested | | Retries exhausted | pause, never delete | 0 until limits | OTLP/HTTP: retryable failures are retried with backoff; giving up would lose data silently | [`a_failing_server_never_costs_a_batch`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/backend_tests.rs#L346) | | Opt-out (also mid-upload, racing a capture or a configure) | in effect when `telemetry_disable()` returns (no scope, no capture), the purge then runs on the core's runtime (a repeated opt-out joins the one already running); `telemetry_is_disabled()` is `true` process-wide before the call returns, so a platform with per-isolate state checks it before each `getStats` or submit; lifecycle serialized with instruments; every generation revoked under the locks that commit data, its exporter cancelled and awaited (draining ones too), queue/spans/windows/cache purged; then the `storage_dir` of every generation, live or gone, erased, so an earlier launch's batches are deleted even when this launch could not open that directory and cached in memory; a later configure is refused: it clears its own cache, erases its `storage_dir` (also one it could not open) and starts no exporter, and a directory that stays unreadable waits for the next configure; a `with_cache` pipeline's cache is purged while the pipeline lives, the caller owns it afterwards, and the `storage_dir` that pipeline ignores is never touched; only actual deletions counted; a purge whose retry deletes everything reports success; incomplete deletes logged, and the opt-out reports them | **N + U** by design; ≤ **B** per generation already on the wire or handed to a pull-queue host | withdrawing consent must take effect at once and erase unsent data (GDPR Art. 7(3), Art. 17) | [`the_opt_out_is_in_effect_before_its_purge_runs`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1248)<br>[`an_opt_out_counts_the_halves_of_an_unpublished_split`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1473)<br>[`opting_out_stops_collection_and_purges_everything`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L249)<br>[`opting_out_during_an_upload_resurrects_nothing`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L336)<br>[`a_capture_racing_the_opt_out_leaves_nothing_behind`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1273)<br>[`an_instrument_never_starts_after_the_opt_out_stopped_it`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1072)<br>[`the_opt_out_cancels_a_draining_generation_before_returning`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1162)<br>`the_opt_out_withdraws_a_replaced_generations_pulled_request` (added in #1396)<br>`a_repeated_opt_out_waits_for_the_first_purge` (added in #1396)<br>[`after_the_opt_out_nothing_is_captured`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L581)<br>[`an_incomplete_purge_is_reported`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L678)<br>[`purges_count_only_actual_deletions_once`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1051)<br>[`the_opt_out_deletes_an_earlier_launchs_batches_after_a_fallback_start`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1734)<br>[`a_refused_configure_deletes_an_earlier_launchs_batches`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1765)<br>[`the_opt_out_leaves_the_storage_dir_of_a_caller_provided_cache`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1693)<br>[`the_opt_out_keeps_an_unreadable_gone_disk_until_it_is_erased`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1658)<br>[`a_purge_whose_retry_deletes_everything_reports_success`](https://github.com/livekit/rust-sdks/blob/58f3a6e5d8c389d6cf1f8c85734c16dcda3ae059/livekit-telemetry/src/exporter.rs#L1724)<br>[`clearing_an_unreadable_directory_fails`](https://github.com/livekit/rust-sdks/blob/1371f6c69159d663092ed2834a385a9a20749c27/livekit-telemetry/src/cache.rs#L1320)<br>[`the_process_pipeline_no_ops_until_installed`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/telemetry.rs#L1038) _(lands in #1396)_ | | Dart host stops serving the pull queue | ≤ 1 request queued; a request nobody polls for times out as usual; requests the exporter gave up on, or pulled after the opt-out, are never served, by `next()` or `try_next()`; unknown ids ignored | 0 served stale | Dart FFI callbacks are bound to their isolate: Rust must never call into, or wake, a dead one | `try_next_serves_without_waiting_and_never_a_stale_request` (added in #1396)<br>`a_suspended_host_is_never_served_stale_requests` (added in #1396)<br>`a_cancelled_request_is_never_served` (added in #1396)<br>`finishing_discards_what_is_queued` (added in #1396) _(lands in #1396)_ | | Invalid app input | rejected, never truncated; counted `invalid` | exactly the rejected | a truncated id collides; attribute limits as in the OTel attribute-limits spec | [`custom_data_is_room_scoped_validated_and_snapshotted`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L411) | | Correlation attributes or project change mid-window | windows capture owner + attributes at open; a change closes them first, under the lock readings record under | 0 | a window describes one owner and one set of attributes; emitted records are immutable | [`rtc_windows_carry_the_attributes_of_their_readings`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L786)<br>[`a_window_closed_before_a_change_keeps_its_snapshot_whenever_it_is_queued`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L933)<br>[`a_project_change_splits_the_rtc_windows_by_project`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L959) | | Subscribe never gets media | `timed_out` on the core's clock, whoever looks first, kept through disconnect | 0 | no first media is the failure to measure: nothing else reports it | [`the_subscribe_span_is_owned_by_the_core`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1063)<br>[`late_first_media_is_timed_out_whoever_looks_first`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L509)<br>[`a_subscribe_past_its_deadline_stays_timed_out_through_disconnect`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L276) | | Long-lived process | spans hold the pipeline weakly; per-track state retired; span state ≤ 128 steps / attributes; retained caller strings bounded (an oversized span name is kept only as `invalid`, detached spans included) | 0 | apps run for days across many Rooms and tracks: nothing may grow without bound | [`a_pending_subscribe_never_keeps_the_pipeline_alive`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L602)<br>[`per_track_state_is_retired_with_the_track`](https://github.com/livekit/rust-sdks/blob/4c3e79da7c2628472629035e2a10aac8b2afdc90/livekit-telemetry/src/rtc.rs#L1232)<br>[`the_same_track_in_two_sessions_never_merges`](https://github.com/livekit/rust-sdks/blob/4c3e79da7c2628472629035e2a10aac8b2afdc90/livekit-telemetry/src/rtc.rs#L1209)<br>[`retained_span_state_is_bounded`](https://github.com/livekit/rust-sdks/blob/58f3a6e5d8c389d6cf1f8c85734c16dcda3ae059/livekit-telemetry/src/trace.rs#L656)<br>[`final_limits_hold_after_decoration_and_caller_strings_are_bounded`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L876) | Uninstall or an OS cache purge is beyond the SDK's reach (**N + U**). Defaults, polling (fast after a subscribe or a publish) and explicit flush (drains without the per-pass budget, within holds and pauses): [`defaults_export_and_window_once_a_minute`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L69)<br>[`the_core_paces_stats_polling`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L458)<br>[`publishing_polls_fast_until_the_first_outbound_reading`](https://github.com/livekit/rust-sdks/blob/5e17e859e1163d441e19de32d0ab375faa6b4274/livekit-telemetry/src/device_tests.rs#L1324)<br>[`device_holds_uploads_and_a_backlog_replays_within_the_budget`](https://github.com/livekit/rust-sdks/blob/42a5dd17a7926f8470bd3da21b9e140b7d4176f8/livekit-telemetry/src/telemetry.rs#L1680). </details> <details><summary><b>Verification</b></summary> At `5e17e859`, from a clean checkout (CI's test workflow runs only for PRs into `main`, so these were run locally; there is no clippy job in CI): - `cargo fmt --check` - `cargo clippy -p livekit-telemetry --all-targets -- -D warnings`, also with `--all-features` and as a `cargo hack --feature-powerset --depth 2` run - `cargo test -p livekit-telemetry`: 275 unit, 2 doc - `RUSTDOCFLAGS="-D warnings" cargo doc -p livekit-telemetry --no-deps` </details> --------- Co-authored-by: omnigent <noreply@omnigent.ai> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
`livekit_protocol::semconv` holds the telemetry names and enum values that Weaver generates in livekit/protocol. The module reads `protocol/otel/gen/rust/semconv.rs` from the submodule, so the submodule pointer is the version. The two changesets record the breaking protocol upgrade for the crates that expose protocol types (the generated code itself is already on main). Co-authored-by: Codex <codex@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
`set -eu` stops the script when protoc fails, so it cannot leave stale output. A perl pass strips the trailing spaces that protoc-gen-prost-serde writes, and it runs only after a successful protoc. This regenerates one doc line in `livekit.rs` without its trailing space. `generate_proto_check.sh` pins the behavior: a failed protoc exits 47, a failed normalizer exits 3, and a regeneration is byte-identical. Co-authored-by: Codex <codex@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…gistry The core takes event, span and attribute names, and the enum values, from `livekit_protocol::semconv` instead of string literals. The wire spelling changes with it, for example `lk.room_id`, `lk.participant_id`, `lk.track_id`, `lk.pii.room_name`, `lk.disconnect_reason` with the protobuf `DisconnectReason` names, and `lk.track_source` with the RTC FFI names. `wire_tests.rs` pins every name and value that the core sends to the registry. SPEC.md lists the new names and the four values that stay literals until the registry defines them. Co-authored-by: Codex <codex@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
- `From<log::Level> for Severity`. - `global::uninstall` is public: it removes the process pipeline without draining it. - `global::uninstall_if_current` removes only the given pipeline, after a failed delivery. - `global::refuse_configuration` handles a configure after the opt-out without building a pipeline, and erases the storage directory. - The instruments that `uninstall` and `disable` remove are freed outside the installed-pipeline lock, so an instrument destructor can log. A test pins that a record built by `log_with` during an uninstall or an opt-out goes only to the pipeline that it read. Co-authored-by: Codex <codex@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…dings livekit-ffi also exports the signaling `ReconnectReason`. The telemetry enum keeps its Rust name and variants, and UniFFI exports it as `TelemetryReconnectReason` so the two do not collide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
The core-modules UniFFI surface gets `telemetry_configure`, `telemetry_configure_pulled`, `telemetry_scope`, spans, stats, typed app attributes and `telemetry_disable`. - Admission: at most three telemetry generations are admitted, and a rejected replacement returns `AtCapacity` before it is built. - The opt-out takes precedence over a missing transport: a configure with no transport after `telemetry_disable` returns `Ok` and erases storage. - `log_forward_bootstrap` copies the core's own warnings and errors into telemetry with credentials masked, and keeps the Rust log level at `warn` or looser. The copy is built only while telemetry runs. - The opt-out admission boundary tests (`telemetry_admission_tests.rs`) are ignored by default, because each case needs a fresh process. Co-authored-by: Codex <codex@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
The opt-out is one-way for a process. The Test job runs each ignored boundary case, and the disabled-configure-without-transport case, in a process of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
`telemetry_test.dart` calls the generated telemetry API. The live collector test is skipped unless `LK_TELEMETRY_ENDPOINT`, or `LK_TELEMETRY_URL` with `LK_TELEMETRY_TOKEN`, names a collector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
duckscript `exec` ignores a non-zero exit. A failed native build or uniffi-bindgen run could then leave an older library or binding behind for packaging. `exec --fail-on-error` on the four native build lines and on both bindgen lines stops the task instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
cargo-ndk 4.x needs Cargo's plugin context, so the old `--help` probe did not find an installed 4.x tool. The Android build now runs under `set -e`, asks `cargo ndk --version`, and installs 4.1.2 when that version is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
New baselines with signaling and telemetry in core-modules: ios-arm64 2,483,344 bytes and Android arm64-v8a 2,493,056 bytes. Each limit is the baseline plus 10%, rounded up to 64 KiB: 2,752,512 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
Flutter's native-assets step rewrites the install name of the cdylib with install_name_tool, which fails without header padding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…uide `telemetry_ping` records a small session and prints its trace id. The README explains how to send it to a local OpenTelemetry backend with `LK_TELEMETRY_ENDPOINT`, and how to watch cached batches replay. Co-authored-by: Codex <codex@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
livekit-ffi core-modules depends on livekit-telemetry and exports its API to Dart, so a change to that crate alone can break the Dart bindings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
2fac8d4 to
52e0c70
Compare
…dows The opt-out erase treated `Path::try_exists` returning `Ok(false)` as nothing to delete. For a path whose ancestor is a file, Unix reports `ENOTDIR`, which keeps the directory pending, but Windows reports `STATUS_OBJECT_PATH_NOT_FOUND`, which std maps to `NotFound` and so to `Ok(false)`. The refused configuration then counted as erased and a later opt-out never returned to it. That is the Windows failure of `refused_erase_is_retried_by_later_opt_out` on main and on #1396. `erase` now checks the nearest existing ancestor on `Ok(false)`, and a non-directory there is an error, the same as Unix reports. A path under a missing directory still counts as absent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
Summary
livekit-telemetry— the shared client-telemetry core — and its UniFFI surface for the Swift, Kotlin and Dart SDKs. Wire spec (events, attributes, cadence, upload policy):livekit-telemetry/SPEC.md.#1566 stacks on this PR: it takes every telemetry name from the protocol registry.
Changes
livekit-ffi/src/core_modules/telemetry.rs: configure and configure-pulled, scopes, spans, stats, the app API, the opt-out, device statelog_forward.rs: the core's own warnings and errors copied into telemetrytelemetry_pingexample and the README's local testing guidetelemetry_configurewaits until its pipeline is installedtelemetry_shutdownreturns once every exporter queued before it stopped, and a shutdown that resumes late never ends a newer lifecyclefinishreturned, and a pulled configure refused after the opt-out finishes its queuetelemetry_logorTelemetryScope.logget the same credential masking as the core's own copied linesWhat a platform calls, and when
telemetry_configure(config, transport, instruments)— storage and tuning only; Dart:telemetry_configure_pulled(config, [])+queue.try_next()telemetry_scope()scope.set_server(url, token)— cheap, idempotentscope.start(SpanName, parent)→step/set_track/end;subscribe_started/subscribed(tracks already in the room at join:subscribe_startedat connect, solk.subscribemeasures from join; a lonesubscribedstill opens the span as a fallback) /subscribe_failed;track_ended(sid);set_room;disconnected(reason)scope.stats_poll_interval_ms():scope.record_peer_stats(report, {trackId → sid}, ts)per peer connectiontelemetry_set_device_state(thermalUnknown/ low powerNonewithout a source),telemetry_device_event,telemetry_logscope.emit_custom(name, {k: v}),scope.set_attribute(key, value?),telemetry_disable()— synchronous, in effect when it returns (TODO on platforms: token discussion);telemetry_is_disabled()reads that opt-out process-wide (every thread and Dart isolate), for platforms to check right before eachgetStatsor submitNo endpoint, header or sink exists in any client-language API. Local end-to-end tests set
LK_TELEMETRY_ENDPOINT(read by the core; see the README).Local testing against a local OpenTelemetry backend (LGTM)
Everything can be tried against a local OpenTelemetry backend (LGTM) in a couple of minutes; no LiveKit server is needed for the Rust example.
Then open http://localhost:3000 → Explore: Loki
{service_name="telemetry_ping"}for the log records (otel.event.name:custom.ping,lk.rtc.stats.sample,lk.telemetry.report), Tempo with the printed trace id for the spans (lk.connect,lk.publish,lk.subscribe). Platform e2e tests setLK_TELEMETRY_ENDPOINTthe same way (withlivekit-server --devfor a real Room).Verification
At
a2558a40, from a clean checkout:cargo fmt --checkcargo clippy -p livekit-telemetry --all-targets -- -D warnings, also with--all-featuresand as acargo hack --feature-powerset --depth 2runcargo test -p livekit-telemetry: 275 unit, 2 docRUSTDOCFLAGS="-D warnings" cargo doc -p livekit-telemetry --no-depscargo test -p livekit-ffi --no-default-features --features core-modules: 34cargo clippy -p livekit-ffi --no-default-features --features core-modules --all-targets: only the 7 warnings thatmain(6473ec17) hascargo clippy -p telemetry_ping --all-targets -- -D warningscargo make --profile release android-packageinlivekit-ffigenerates the bindings andassembleReleasesucceeds, and a fresh./gradlew compileReleaseKotlin --rerun-taskspasses.android-check-sizefails: the arm64 library is 2,298,256 bytes against a limit of 1,769,472 bytes (main: 1,593,408 bytes)cargo make dart-package,dart pub get,dart test: 7 pass, 1 skip. The skipped live collector test passes against a local collectorStages 2–7 pass the same
livekit-telemetrygates on their own tips (see each PR).Generated API:
TelemetryReconnectReasonlivekit-fficore-modules now exportslivekit-telemetrynext to the signaling module, and both declare an enum namedReconnectReason. UniFFI rejects two exported types with one name, so the telemetry enum is exported to Swift, Kotlin, Python and Dart asTelemetryReconnectReason(ba09132). The Rust name, the variants and thetelemetry_reconnect_reasonfunction are unchanged. The released signalingReconnectReasonis unchanged.Consumers that name the telemetry enum must rename it. In Kotlin,
uniffi.livekit_telemetry.ReconnectReasonbecomesuniffi.livekit_telemetry.TelemetryReconnectReason.The package tasks now fail when native compilation or a bindings generator fails (cfc2c1f9, c6234eda). This prevents a failed build from appearing successful by reusing stale native output or compiling no generated Kotlin.
The Android size budget is rebaselined for the combined signaling and telemetry library (e33167a). The release arm64-v8a library measures 2493056 bytes. The new limit is 2752512 bytes, which is the measured size plus 10% headroom rounded up to 64 KiB, as before. The Swift budget is rebaselined the same way (aea874b): the release ios-arm64 framework measures 2483344 bytes, and the new limit is 2752512 bytes.
Linear: CLT-3331