Repository navigation
Conversation
|
|
Introduce telemetry infrastructure built on livekit-telemetry Rust crate. Add Telemetry singleton managing OTLP export pipeline, opt-out control, and tracing context helpers. Pipeline ships spans to configured collector; defaults to no-op when unconfigured. Rename UniFFI error field from message to reason to avoid Kotlin bindgen conflict. Forward SDK warnings and errors to telemetry core.
Add tracing spans for connect, publish, subscribe and reconnect, and record disconnect events with their mapped reason. Connect span wraps full connection setup; publish and subscribe spans track track operations; reconnect spans measure recovery time. Add SDK-internal observer support to MulticastDelegate.
Report device thermal state, power state, memory warnings, network reachability changes, battery level and state, audio route changes, and app foreground/background transitions as telemetry events. Bounded stream prevents unbounded memory growth from rapid device changes.
Poll getStats() on each peer connection; submit codecs, inbound/outbound RTP streams, ICE candidates, and connection quality metrics. Respects opt-out; keeps an idle timer while disconnected, without reading stats.
Add disableTelemetry() for opt-out, emitTelemetryEvent() for custom events, and setTelemetryAttribute() for context propagation. Opt-out stops collection when the call returns.
Cover connect, publish, subscribe, reconnect, late join, device state, RTC stats, and opt-out. Include local OTLP collector config; tests skip when collector unavailable.
Update CI workflow for telemetry tests and benchmark support.
e4acf0e to
96be295
Compare
There was a problem hiding this comment.
Note
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
Devin Review found 5 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
There was a problem hiding this comment.
🟡 Room moves lose subscription start times
When a room moves with existing remote tracks, joined never reports their subscription intent. The move rebuilds participants without publishing callbacks, so their subscribe spans start only when media arrives.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
For a move while connected, rebuilding participants emits the publish callbacks that restart subscription intent (callback path). This source check contradicts the missing-callback premise; it is not a runtime test of every reconnect overlap.
| let next = DispatchTime.now().uptimeNanoseconds + wait | ||
| self?.polling.mutate { if !Task.isCancelled { $0.next = next } } |
There was a problem hiding this comment.
There was a problem hiding this comment.
Already guarded in 8bf7fadb: replacing the poll loop cancels the old task, and the cancellation check and deadline update share the polling lock. The old update either runs before replacement or sees cancellation, so it cannot overwrite the replacement deadline.
Brings in main up to 406af9e (v2.20.0 and the Opus NACK fix). The tree is the pull request's eight commits replayed on that main, with the same conflict resolutions as the reviewed local rebase. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
URLSession.data(for:) buffered a collector answer of any size before the core could apply its 64 KiB limit. Stream the body and stop one byte past 65,536 decoded bytes, cancelling the request; the core then classifies the overflow as retryable and honours Retry-After. Before iOS 15 / macOS 12 there is no streaming read and the previous buffered path remains. The regression test serves an answer that never finishes: only a read-time bound returns (verified: the buffered path hits the 60 s time limit). Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Answers of 0, 65,535 and 65,536 decoded bytes come back whole; 65,537 and 200,000 bytes, delivered in 1,000-byte chunks, are cut at 65,537 with the status and Retry-After kept, which the core classifies as a retryable overflow (D03/P01). Exclude the e2e collector's otelcol.yaml from the test target so SwiftPM stops warning about an unhandled file. The opt-out doc now says that an upload already in progress can still reach the server. Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a README section that lists the recorded data, including room names, local and remote participant identities, room, participant, track and session IDs, quality and device diagnostics and app-supplied custom data. It states where and when data is uploaded, that credential masking covers log text only, that the 24-hour cache limit is not server retention, and what LiveKitSDK.disableTelemetry() does and does not do. Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LiveKitSDK.disableTelemetry() returns before the background purge runs and gives no result, so the doc comment and README no longer read as a completed deletion. Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ry OS On iOS 13-14, macOS 10.15-11 and Mac Catalyst 14 the transport still called URLSession.data(for:), which buffers the whole answer before the core can apply D03/P01. Read every answer through one URLSessionDataDelegate instead: keep at most 65,536 + 1 decoded bytes, append only the remaining prefix of a chunk, cancel the task on overflow, and resume each read exactly once, including a caller cancellation before the task is registered. The same-origin redirect rule, status and headers are unchanged. The transport owns its session and the session its reader, and the session is invalidated when the transport goes. Tests cover the limit, chunk prefixes, an endless answer, no answer, cancellation before and during the read, reader release, and, against a loopback server when LK_TELEMETRY_LOOPBACK is set, gzip decoding and redirects. Reverting to data(for:) or appending whole chunks fails them. Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LiveKitSDK.disableTelemetry() called the refused configure synchronously, and the core blocks that call until its purge and the refusal's cache erasure finish. Revocation stays synchronous; the refused configure now runs once per process on a dedicated serial queue, and a Room created after the opt-out schedules nothing more. Telemetry.cleanUpFinished() awaits it. The core creates the cache directory but not its parent, so without Caches/livekit-telemetry it silently cached in memory only. Create the parent before installing, as the core's TelemetryConfig contract requires. TelemetryOptOutProcessTests runs one case per process (selected by LK_TELEMETRY_OPT_OUT_CASE, skipped otherwise) through the released core against a local recorder: capture, a cache seeded by an unreachable collector, the opt-out before any Room with the clean-up held, and the opt-out while a stats request or submit is held. Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion The README now separates the default Cloud, HTTPS and token path from the LK_TELEMETRY_ENDPOINT override, which release builds also honor and which sends to any HTTP or HTTPS URL without a token. Cache expiry happens when the SDK processes the cache, not at a fixed time. The opt-out starts a deletion that can fail; the doc comment says the same. Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cleanUp() marked the clean-up under its lock and queued it after letting go, so a concurrent disableTelemetry() could find it marked, return, and see cleanUpFinished() return before the clean-up was even queued. Mark and queue now happen in one locked step (queueing never blocks; the configure still runs later on the queue, outside the lock), and cleanUpFinished() queues its barrier under the same lock. The concurrentDisable process case holds the first caller right after it scheduled the clean-up, overlaps a second opt-out and the await, then runs eight more concurrent opt-outs; the clean-up runs exactly once. With the previous order it fails at the first await. Co-authored-by: omnigent <noreply@omnigent.ai> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…an-up The first Room installs the pipeline. When that install passed its opt-out check and disableTelemetry() then revoked, the core received the configure after the opt-out, refused it, and made it wait for the purge: the Room being created waited with it. An install now holds a lock from its opt-out check to the end of the core's configure, and the opt-out takes that lock before it revokes. No configure reaches the core after the opt-out any more, except the clean-up's own, on its queue. The opt-out waits instead, for an install in flight, which is local work with nothing to purge ahead of it. A configure that finds the opt-out does nothing: disable() owns the clean-up, so it is no longer queued before the core is revoked. The roomDuringOptOut process case holds the first Room's install right after its check and overlaps an opt-out. The opt-out stays behind the install, the core is not yet opted out when the install reaches it, both that Room and a later one are created while the clean-up is held, and the clean-up then deletes the earlier launch's cache. Without the ordering the case fails at the first two checks. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
disableTelemetry() keeps its shape: a process-wide call that returns nothing. Its doc comment replaces the TODO with the contract: collection stops when it returns, the deletion is best effort and is not awaited or reported, an upload in progress can still arrive, and the choice is not remembered. It recommends the call at every launch before any Room, like the logger setters, says that a later call still stops existing Rooms, and that creating a Room never waits for the deletion. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
The process cases could hang or pass for the wrong reason: - A test hook held its thread until the case let it go, so a case that failed early left it held for good. Each hook now lets go after 30 s, each case removes its hooks and releases them on every way out, the held stats reading is resumed on every way out, and the suite has a time limit. - The cache count read a directory that could not be listed as empty. It now tells an absent directory from an empty one and throws on any other error. - roomDuringOptOut asserted that the opt-out had not returned within one second, which is the chosen lock order and can also be a late thread. The opt-out worker now signals that it runs, the second is only its chance to overtake the held install, and the case checks the invariant itself: the Room's install reaches a core that is not opted out. Waiting on a call no longer consumes its completion, so a later check cannot fail as a side effect of an earlier one. The released core gives its host no way to hold its purge, so no case measures a Room waiting behind a held purge. The installOrder comment no longer calls the opt-out's wait bounded and says that it covers the SDK's installs only. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
TelemetryTransportCapTests and TelemetryOptOutProcessTests used .timeLimit directly. TimeLimitTrait needs iOS 16 and the package deploys to iOS 13, so the iOS job on Xcode 26.6 stopped at "'timeLimit' is only available in iOS 16.0 or newer". Both suites now take TestLimits.unit, which resolves the trait at run time, as the other suites do. The cap suite gets the limit for every test instead of for one. The opt-out suite's comment no longer says that the limit ends a case that stalls: it cancels the case, which cannot stop a synchronous call into the core. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
ConnectOptions.reconnectAttempts is a plain Int. With a negative count the retry helper skips its loop and runs the final attempt with that count as the attempt number. The reconnect span converted the number with UInt32(_:), which traps on a negative value, so a reconnect crashed the app whenever telemetry was on. On main the same options make one attempt. The span now clamps the number. aNegativeRetryCountStillReconnects reconnects a Room with a count of -1. Without the clamp the test process ends with "Negative value is not representable". The suite runs on request (LK_TELEMETRY_LIFECYCLE): it needs telemetry on, and a full test run shares its process with tests that opt out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
lk.subscribe opens in the core at the intent: a remote publish under autoSubscribe, or set(subscribed: true). A later set(subscribed: false) reported nothing when no track was attached yet: the unsubscribe reaches telemetry through didUnsubscribe, which only fires for an attached track. The core then kept the subscribe pending, polled at its fast interval, and ended the span as timed_out after 30 s, although the app had chosen to stop. The publication now tells the Room's RTC instrument when it takes back a subscribe with no track attached. The attached case still goes through the delegate. aSubscribeTakenBackBeforeItAttachesIsNotLeftPending watches the core's poll interval, which is fast only while a subscribe is pending: it takes a manual subscribe back before the track attaches, and subscribes again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
The telemetry end-to-end test reads back what an OpenTelemetry Collector wrote. CI starts the collector in the background, with no health check, and uploaded neither its log nor its output file. A failed run then gave no evidence that the collector was up or of what the core sent to it. The test-log artifact, which is uploaded only for a failed job, now also holds the collector's log and /tmp/livekit-telemetry-otlp.jsonl. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…'s intent A subscribe intent reaches the core from two threads. The automatic one starts on the Room's delegate queue, when the remote publish is delivered. The app takes a subscription back, or asks for it again, on its own thread. So the reports could arrive in the wrong order: - The app unsubscribed a new publication before the delegate queue had delivered its publish. The cancellation found nothing to end, and the late publish then opened lk.subscribe, which stayed pending and ended as timed_out after 30 s. - The report of an unsubscribe could arrive after a later subscribe and end the new span. The RTC instrument now makes each report in one locked step that reads what the publication wants at that moment: a start reports only a wanted subscription, a cancellation only an unwanted one. A subscribe after an unsubscribe is wanted again, so it still opens a span. The attached case is unchanged and still ends through didUnsubscribe. The tests use a subscriber without the subscribe permission, so the track never attaches and the order is not a race with the media. One holds the Room's delegate queue, unsubscribes, and lets the publish through afterwards. One covers the delivered intent, a new subscribe and a late cancellation report. Both check that the Room and its instrument are released. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
TelemetryLifecycleTests needs telemetry on from start to end, so it only runs with LK_TELEMETRY_LIFECYCLE set: the main test run is one process, and an opt-out in it lasts for that process. Until now nothing in CI set the variable, so CI never ran the suite. Each Build & Test job now has a second step that runs only this suite, in its own xcodebuild process, with the variable set and a ten-minute limit. It reuses the build of the main step and also runs when a test of the main step failed. The step fails unless every test function of the suite reports that it passed, so a run that skips them cannot pass for one that ran them. Its log and result bundle join the artifact of a failed job. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…tches A failed job uploaded the file that the collector wrote. Those batches hold room and participant values and log text of the tests. The question a failed run has to answer needs none of them: did the collector get data, and under which names did the core send it. A new step writes the number of batches and the span, event and attribute names, without values, and the artifact holds that summary and the collector's own log. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
Brings in main up to 3829dfa. One conflict, in Room+Engine.swift: main now resumes only on the first of several reconnect attempts. That rule is kept as main has it, inside the reconnect telemetry span of this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…ey are known startReconnect took a telemetryReason parameter and cleanUp a disconnect reason parameter, only to forward them to the core. Both are gone: - The reconnect span takes its reason from StartReconnectReason. A failed transport is transport_failed. The transport delegate used to report publisher_failed or subscriber_failed by the failing transport's target, which in single peer connection mode named the one connection that carries both directions publisher_failed. - A server LeaveRequest and a reconnect cycle that gives up report their disconnect reason to the core before the Room cleans up. The core keeps the first report of a session, so the generic report in cleanUp is a no-op after them. The leave reason is mapped by a DisconnectReason initializer next to the other telemetry mappings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…vekit The device instrument turned on UIDevice.isBatteryMonitoringEnabled for the whole process and left it on, also after the opt-out. That is an app setting: the SDK no longer touches it, and battery level and charging state are no longer reported. The README list of device data drops them. The two telemetry queues use the io.livekit label prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…core A Loggable warning or error was described twice: the app's logger (the default OSLogger among them) asked the message for its description, and the telemetry record asked again. A non-String CustomStringConvertible then ran a costly or stateful description twice. The message is now described once on that path, and both receive the same text. Messages below the telemetry level reach the app's logger as before. The level itself is named LogLevel.telemetry, used where the scope is chosen and where the record is made. aWarningIsDescribedOnce counts the descriptions of one warning: one with the fix, two without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…tory The lifecycle cases ran in a suite of their own, behind LK_TELEMETRY_LIFECYCLE, and CI gave them a separate xcodebuild step: the end-to-end story ends with the opt-out, which lasts for the process. They now sit in TelemetryTests, declared before the story. A serialized suite runs its tests in declaration order (3 of 3 runs with swift test and 3 of 3 with the CI scheme, whose random order setting does not reorder it). Should that change, they fail on a precondition instead of passing vacuously. The variable, the CI step and its artifacts are gone. Also in the suite: - theDefaultStatsWindowIsOneMinute: the installed pipeline polls a Room with nothing pending every 30 s, half of a one-minute window. - TestLimits.e2e at suite level. transportStopsReadingAnOversizedAnswer is removed: TelemetryTransportCapTests covers the same reads at, below and past the limit, and its direct .timeLimit did not compile for iOS below 16. The story failed in every CI job, for reasons in the test: - The released core names the attributes lk.track_id and lk.disconnect_reason, and the reason value CLIENT_INITIATED. - It expected exactly two reconnect spans. A quick reconnect after an unpublish starts a second reconnect, on main 3829dfa too. The story now checks its two debug cycles by reason and mode, and that every reconnect span ends ok. - It expected the unpublished test microphone to end a subscribe before first media, which holds only while that track sends nothing. A third participant without the subscribe permission now waits for it, so the subscribe ends before first media whatever the media does. The collector configuration moves to .github/otelcol.yaml, next to the workflow that runs it; the package exclude for it is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
The README listed the identifiers that telemetry carries and said that credential masking is not personal-data redaction. It now also says that telemetry is not anonymous, that SDK warning and error logs can contain room names and participant identities, and that the masking does not change identifiers. The advice to keep secrets and unnecessary personal data out of names, identities, custom events and attributes stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…story The story recorded only the device state at its start. It now feeds a second device instrument a memory pressure warning cycle (critical, then normal) and an app background and foreground, and expects the core's records for those transitions. These are injected signals through the adapter's path into the core, not the OS: real memory pressure, thermal changes and backgrounding stay device cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
URLSessionTelemetryTransport took a URLSession only to read its configuration, and its default was a static session with a redirect delegate that never ran a request: the transport always makes its own session, with the bounded reader as delegate, which already applies the same-origin rule to redirects. The initializer now takes the configuration (ephemeral by default), the static session is gone, and SameOriginRedirects is only the rule itself. The redirect test checks the reader that the transport actually uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…ibution Co-authored-by: omnigent <noreply@omnigent.ai>
|
BTW there's already livekit/livekit-ffi-xcframework#30 |
| roomOptions: roomOptions ?? RoomOptions(), | ||
| stage: .idle(IdleDependencies(dataStreams: dataStreams)))) | ||
|
|
||
| telemetryScope = Telemetry.scope() |
There was a problem hiding this comment.
[P2] Keep telemetry cache initialization off the Room.init caller
The first Room() synchronously configures telemetry. The released core opens, recovers, and prunes its disk cache and waits for pipeline installation before returning. Apps commonly create their Room on the main thread during startup, so this adds filesystem work to the first-frame path, including for self-hosted or grant-less connections. Please initialize persistent storage off the caller’s thread while preserving early events, and validate startup with both empty and populated caches.
There was a problem hiding this comment.
Empty and populated caches were tested on iPhone and Mac; empty-cache startup added about 8–9 ms in these small samples. Setup stays synchronous here to preserve early events; async storage needs a separate core/FFI change.
|
|
||
| // Telemetry uploads with this Room's latest token: at connect and on every refresh. | ||
| if let url = newState.providedUrl, let token = newState.token, token != oldState.token || url != oldState.providedUrl { | ||
| telemetryScope?.setServer(url: url.absoluteString, token: token) |
There was a problem hiding this comment.
[P2] Open the connect span before making cached uploads eligible
Assigning the URL/token invokes setServer, which wakes the exporter and can release cached batches. The lk.connect span is opened afterward at line 499. This leaves a scheduling window where an upload can start before the core applies its connection-sensitive hold. Please open the span before publishing the destination, and end it if staging the connection throws. A cached-backlog test should verify that no upload starts during this transition.
There was a problem hiding this comment.
Fixed in deafdd3c: the connect span opens before uploads become eligible and closes on failure or cancellation. The regression test fails with the old ordering and passes with the fix.
| // Described once for the app's logger and the core: a description can be costly or have effects. | ||
| let body = message?.description ?? "" | ||
| sharedLogger.log(body, level, file: file, type: Self.self, function: function, line: line) | ||
| Telemetry.log(LogRecord(severity: level.severity, source: .sdk, body: body, |
There was a problem hiding this comment.
[P2] Audit unstructured SDK log content before exporting it by default
This captures warning/error descriptions from existing SDK call sites, including queued signaling requests and application RPC-handler errors. Those descriptions can contain caller-controlled content beyond the explicitly documented identity fields, and credential-pattern masking does not generally sanitize that content. Please audit these paths, prefer stable error codes and allowlisted telemetry fields where possible, and add regression tests showing what survives masking. The normal application logger can retain its existing diagnostic output.
There was a problem hiding this comment.
The audit confirms that handler errors can retain sensitive text after masking; Firebase Crashlytics also forwards NSError.userInfo without general PII filtering, while Sentry accepts full log messages and offers before-send filtering. A reduced telemetry-only message at affected call sites, like Datadog's internal error sanitization, could preserve full console diagnostics without changing OSLogger; this remains proposed, not implemented in this PR.
There was a problem hiding this comment.
P2 — Please resolve the acknowledged sensitive-log export path
The audit confirms that handler errors can retain sensitive text after credential masking, while the telemetry-only reduction remains proposed rather than implemented. The README disclosure clarifies the behavior, but does not reduce what those SDK-authored warning/error paths export.
Please apply reduced telemetry-only messages or stable error codes and allowlisted fields at the identified call sites, while preserving the full diagnostics for the application's normal logger. Add regression tests with representative sensitive handler-error content to show what reaches telemetry and what stays console-only. This follows up on the confirmed exposure rather than requesting another audit.
| return telemetryScope() | ||
| } | ||
|
|
||
| /// Opt-out, in effect when this returns: no scope, no capture, configures refused; the core |
There was a problem hiding this comment.
[P3] Correct the documented opt-out waiting behavior
The comment says disable() waits only for an installation in flight, but it also waits to acquire disabled while an ifCollecting body executes. Those bodies include native stats-request initiation and synchronous recordPeerStats submission. Please document these waits and prohibit reentrant lifecycle calls from the gated closure. Simply moving the work outside the lock would weaken the guarantee that no new requests/submissions start after opt-out returns.
There was a problem hiding this comment.
Corrected in deafdd3c: the docs list the additional waits and forbid lifecycle calls from inside the collection gate. Locking behavior is unchanged.
Assigning the URL and token runs setServer from the state observer, which makes cached batches routable. lk.connect, which holds uploads, opened only after that mutation, so an exporter turn in between could upload. Start the span first and end it if staging the connection throws. TelemetryConnectOrderProcessTests holds the Room inside that observer through the public logger, forces an exporter turn, and expects no upload in the window and the backlog sent once the attempt ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
disable() also waits for a gated stats step (native stats request initiation, recordPeerStats submission) through ifCollecting, not only an install in flight. Document both waits, that neither has a timeout of its own, that it never throws or waits for the purge, and that a gated body must not make a lifecycle call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
Start lk.connect in the same mutation that stages the connection, after stage.begin and before the observer hands the URL and token to setServer. A refused staging (invalidState) again emits no span, as before c4ec7fc, and the state transitions stay one mutation. The core call joins setServer and setRoom, which already run under that lock. Replace the process-gated test with a TelemetryTests case declared before the opt-out story: it wraps the Room's own observer and checks that the span is open when setServer runs, then lets the connect fail on a closed loopback port. No flag, log text, semaphore or network. Document in disableTelemetry() that the call can wait, without a time limit of its own, for telemetry work another thread already started. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
Swift Testing's .serialized does not promise declaration order, so the check moves from its own @test into an awaited helper that aCallFromConnectToOptOut calls with the other lifecycle helpers, before the opt-out. It also checks the cleanup of the failed loopback connect: the span it saw at setServer has ended and the Room is disconnected. Name the native start call that now runs under the Room state lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
…nnect The changeset now says only that the connect hold opens before the URL and token make cached telemetry eligible for export: in-flight uploads, other rooms' routes and the core's hold limits are outside that promise. The opt-out docs no longer read as a complete list of waits. The connect-order helper also runs with the connecting task cancelled at setServer, in an async let child so the story's task is untouched: the span must end and the Room must disconnect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: omnigent <noreply@omnigent.ai>
Co-authored-by: omnigent <noreply@omnigent.ai>
Longevity and telemetry checks
Tested on December 2 with SDK Test cases, baselines, and verdicts
No numerical startup, CPU or disk acceptance limits were set. Battery discharge, forced network outages, near-cap cache behavior, and real thermal escalation were not tested in this workload. Counts above describe the observed records and counters, not a guarantee that every raw RTC reading was captured. |
Co-authored-by: omnigent <noreply@omnigent.ai>
xianshijing-lk
left a comment
There was a problem hiding this comment.
Follow-up review of the latest patchset: two reproduced telemetry/lifecycle test issues and one lower-priority CI integrity improvement. The existing log-content concern is followed up in its original thread.
| } | ||
|
|
||
| func room(_: Room, participant _: RemoteParticipant, didUnsubscribeTrack publication: RemoteTrackPublication) { | ||
| scope.trackEnded(sid: publication.sid.stringValue) |
There was a problem hiding this comment.
P2 — Prevent a delayed unsubscribe callback from retiring a newer intent
The pending-cancellation path checks the current intent, but this attached-track callback unconditionally retires everything for the SID. If the app unsubscribes and immediately subscribes again before the delegate queue delivers the old callback, this ends the current subscribe intent.
I reproduced this against the released FFI core by holding the Room delegate queue across an attached unsubscribe/resubscribe sequence, then letting the queued callback run. publication.isDesired remains true, but scope.statsPollIntervalMs() changes from 1000 to 30000 after delivery: the old callback has retired the current intent. This corrupts subscription telemetry, not the media subscription itself.
Please associate retirement with the subscription generation, or order it at the state-change source so an old callback cannot retire a newer intent. Add coverage for the attached-track sequence; the existing ordering tests cover cancellation before attachment. Preserve retirement for genuine network-driven detachments as well.
| debug.map({ $0.attributes["lk.reconnect.mode"] }) == ["quick", "full"], | ||
| ordered.allSatisfy({ span in | ||
| guard let mode = span.attributes["lk.reconnect.mode"] else { return false } | ||
| return span.attributes["lk.outcome"] == "ok" && span.events == ["attempt 1 \(mode)"] && span.attributes["lk.reconnect.attempts"] == "1" |
There was a problem hiding this comment.
P2 — Make the collector story independent of incidental timing
The current collector-backed run failed two assertions and then passed unchanged on rerun:
- The requested quick reconnect successfully fell back to full, producing
attempt 1 quickandattempt 2 full,lk.reconnect.attempts = 2, final modefull, and outcomeok. Those fields are consistent, but this validator requires exactly one attempt and a final quick mode for the first debug cycle. - The memory records were
["critical", "normal"], which includes the injected transition, but line 236 additionally requires a secondnormal. The initial device-state emission is not synchronized with the observation window, whose start is captured after pipeline configuration inTelemetryTests.swift.
Please either make the quick-only transport condition deterministic or validate the requested initial checkpoint, retry sequence, attempt count, and final mode consistently across fallback. Also synchronize the initial device-state baseline, or assert the injected critical-to-normal transition without depending on an asynchronously emitted initial sample. The existing checks against missing checkpoints and unbounded reconnect cycles can remain.
| - name: Run OpenTelemetry Collector | ||
| run: | | ||
| arch="$(uname -m | sed 's/x86_64/amd64/')" | ||
| curl -sSfL -o otelcol.tar.gz "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.160.0/otelcol-contrib_0.160.0_darwin_${arch}.tar.gz" |
There was a problem hiding this comment.
P3 — Verify the collector archive before extracting and executing it
This downloads a versioned archive and immediately executes its contents, without checking the bytes against an expected digest. The release publishes SHA-256 and signature artifacts for the platform archives.
Please pin the expected SHA-256 for each supported runner architecture in the repository and verify it (for example with shasum -a 256 -c) before extraction. That makes the executable input fixed along with the version, rather than relying on the release asset remaining unchanged.
xianshijing-lk
left a comment
There was a problem hiding this comment.
some more comments, please address them before merging the PR.
Adds Swift client telemetry through released LiveKitFFI 0.15.0 and the shared Rust telemetry core. Rooms report connection and track spans, RTC statistics, SDK/core warnings and errors, WebRTC errors, and device state to their authorized LiveKit Cloud project.
Public API
LiveKitSDK.disableTelemetry()stops collection for the process, including existing Rooms. Cleanup of unsent data is asynchronous and best effort; in-flight uploads may finish. The choice is not persisted across launches.Room.emitTelemetryEvent(_:attributes:)adds application events.Room.setTelemetryAttribute(_:value:)adds correlation attributes.Loggerimplementations receive a String at these levels instead of the original concreteCustomStringConvertiblevalue. This can affect loggers that inspect the original value's type.Internals
io.livekitconvention; the synchronous stop guard prevents late observer registration without blocking shutdown.transport_failedfor single-PC failures andpublisher_failed/subscriber_failedfor dual-PC failures. Disconnect reasons are reported at their source without telemetry parameters on cleanup/reconnect..github/otelcol.yaml. Lifecycle checks run explicitly in sequence before irreversible opt-out in the same test invocation, removing the separate lifecycle environment flag and CI step.README
The separate stacked logging audit PR #1243 covers log-noise reduction, metadata improvements, and logging-standard updates.
Linear: CLT-3333