Repository navigation
feat: add opt-in telemetry for native chat lifecycle - #998
Conversation
Co-authored-by: Copilot App <[email protected]> Copilot-Session: c22819d0-eb50-4f50-9a60-c76ff17856af
Co-authored-by: Copilot App <[email protected]> Copilot-Session: c22819d0-eb50-4f50-9a60-c76ff17856af
|
Codex review: needs real behavior proof before merge. Reviewed July 16, 2026, 11:58 PM ET / July 17, 2026, 03:58 UTC. Summary Reproducibility: yes. from the proposed source path and review discussion: deliver a missing-run-ID or mismatched-run-ID terminal without a later exact terminal, then observe that the turn remains active until reset, disconnect, or disposal. A live current-head reproduction has not been shown. Review metrics: 2 noteworthy metrics.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Add race-safe grace-period cleanup that never closes a different active run, then capture current-head collector and queued-follow-up recovery proof before accepting the exported telemetry contract. Do we have a high-confidence way to reproduce the issue? Yes from the proposed source path and review discussion: deliver a missing-run-ID or mismatched-run-ID terminal without a later exact terminal, then observe that the turn remains active until reset, disconnect, or disposal. A live current-head reproduction has not been shown. Is this the best way to solve the issue? No. Exact-run ownership avoids premature completion, but the maintainable solution also needs bounded orphan cleanup so malformed terminal events cannot indefinitely strand state or queued sends. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4706ca7ff876. Label changesLabel changes:
Label justifications:
Evidence reviewedAcceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (7 earlier review cycles)
|
Co-authored-by: Copilot App <[email protected]> Copilot-Session: c22819d0-eb50-4f50-9a60-c76ff17856af
Co-authored-by: Copilot App <[email protected]> Copilot-Session: c22819d0-eb50-4f50-9a60-c76ff17856af
The overall implementation is strong: the telemetry remains opt-in, exported attributes are low-cardinality, prompts/messages/run IDs/thread IDs are not exported, exception messages are excluded, and the focused concurrency/privacy coverage is unusually thorough. Thank you for taking the telemetry boundary seriously. The remaining concern from the adversarial pass is lifecycle cleanup after an uncorrelatable terminal event. When a terminal event is dropped as Please add a bounded orphan-cleanup path rather than immediately guessing which turn completed. A good shape would be:
Focused tests that would close this concern:
There is also a small non-telemetry behavior change in After that, please rerun the required build/shared/tray suites plus the focused tracker/provider tests and retain the current-head collector proof. This should be a narrow follow-up; no broad telemetry redesign is being requested. |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: c22819d0-eb50-4f50-9a60-c76ff17856af
|
Caleb Eden + GitHub Copilot pair-programming follow-up @shanselman Thanks for flagging this. We checked how the existing gateway clients handle the same case before choosing a cleanup policy for the Windows port. Both the web dashboard and macOS client retain an identified active run when a terminal event is missing its run ID or names a different run, and the canonical gateway schema requires a nonempty run ID for these terminal events. To preserve parity, we avoided introducing a Windows-specific grace period. Windows now rejects missing, empty, and mismatched terminal IDs before they mutate provider, queue, rendering, or telemetry state. A later exact terminal completes normally, while disconnect/reset/disposal remain authoritative cleanup boundaries. This also resolves the Provider regression tests cover mismatched IDs, runless lifecycle and legacy-job terminals, late exact completion, queued follow-ups, and disconnect cleanup. The PR description now calls out this parity fix separately from the telemetry feature. |
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Native tray chat previously provided no OpenTelemetry visibility into a turn's
queueing, gateway admission, first-response latency, streaming duration, or
terminal outcome. Operators could see gateway diagnostics but could not explain
where time was spent from the Windows tray user's perspective.
Why This Change Was Made
This adds privacy-preserving chat lifecycle instrumentation with an explicit root
span per turn and sibling spans for send, response wait, and response receive.
Correlation identifiers remain process-local, exported values are finite and
low-cardinality, and prompts, responses, IDs, attachments, provider details, and
error messages are not exported.
In addition to the telemetry feature, this PR aligns Windows chat run resolution
with the web dashboard and macOS implementations. Agent lifecycle and legacy job
terminal events now own a run only when they provide the exact active run ID.
Missing, empty, or mismatched IDs are diagnosed and ignored rather than clearing
the active run, releasing queued follow-ups, or ending its telemetry. A later
exact terminal event still completes normally, while disconnect remains an
authoritative cleanup boundary.
Cross-process trace-context propagation into the gateway is intentionally left
for a separate coordinated gateway protocol change.
User Impact
Users who opt in to OpenTelemetry export can diagnose native chat latency and
outcomes in their existing collector without exposing conversation content.
Telemetry remains disabled when no endpoint is configured.
All users also benefit from consistent run ownership across Windows, web, and
macOS: malformed or stale terminal events can no longer prematurely resolve the
current chat run.
Evidence
The new tray spans and metrics were exercised through tracker and provider tests
covering local and remote turns, queueing and retries, first output, terminal
races, exact run ownership, malformed and stale terminal events, queued follow-up
progression, abort/reset/disconnect cleanup, bounded attributes, and privacy.
Screenshots
Change Type
Scope
winnodeValidation
.\build.ps1- passed; all five projects built successfully.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restoredotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restoreChatTelemetryTrackerTestsandOpenClawChatDataProviderTestsReal Behavior Proof
through an Aspire dashboard.
run-resolution follow-up; the follow-up was covered by automated provider tests.
message, and inspected the exported trace in Aspire.
openclaw.chat.turn,openclaw.chat.send,openclaw.chat.response.wait, andopenclaw.chat.response.receivewereexported.
response receive time without exported chat content or identifiers.
Yes/No/N/A): Yes - screenshotsare included above.
openclaw.message.processedremains a separatetrace because the current gateway protocol does not accept propagated W3C trace
context.
Security Impact
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain the risk and mitigation: N/ACompatibility and Migration
Yes/No): YesYes/No): NoYes/No): NoReview Conversations