Skip to content

feat: add opt-in OpenTelemetry to chat turns and transcript loading#998

Draft
calebeden wants to merge 2 commits into
openclaw:mainfrom
calebeden:calebeden-chat-telemetry
Draft

feat: add opt-in OpenTelemetry to chat turns and transcript loading#998
calebeden wants to merge 2 commits into
openclaw:mainfrom
calebeden:calebeden-chat-telemetry

Conversation

@calebeden

@calebeden calebeden commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
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.

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.

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, abort/reset/disconnect cleanup, bounded attributes, and privacy.

Screenshots

Screenshot 2026-07-15 163720 Screenshot 2026-07-15 163805 Screenshot 2026-07-15 163826 Screenshot 2026-07-15 163847

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Validation

  • .\build.ps1 - passed; all five projects built successfully.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore
    • 2,788 passed, 31 skipped, 0 failed.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore
    • 1,737 passed, 0 skipped, 0 failed.
  • Focused ChatTelemetryTrackerTests and OpenClawChatDataProviderTests
    • 245 passed, 0 skipped, 0 failed.
  • Final code review reported no significant issues.

Real Behavior Proof

  • Environment tested: Windows ARM64 tray with an OpenTelemetry endpoint viewed
    through an Aspire dashboard.
  • PR head or commit tested: def4fe81
  • Exact steps or command run: launched the current tray build, sent a native chat
    message, and inspected the exported trace in Aspire.
  • Evidence after fix: openclaw.chat.turn, openclaw.chat.send,
    openclaw.chat.response.wait, and openclaw.chat.response.receive were
    exported.
  • Observed result: the tray trace decomposes admission, first-response wait, and
    response receive time without exported chat content or identifiers.
  • Screenshot or artifact links verified? (Yes/No/N/A): Yes - screenshots included above
  • Not verified or blocked: gateway openclaw.message.processed remains a separate
    trace because the current gateway protocol does not accept propagated W3C trace
    context.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No
  • New or changed network calls? (Yes/No): No
  • Command or tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

calebeden and others added 2 commits July 15, 2026 12:21
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c22819d0-eb50-4f50-9a60-c76ff17856af
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c22819d0-eb50-4f50-9a60-c76ff17856af
@calebeden calebeden changed the title feat: expose native chat timing in OpenTelemetry feat: add opt-in OpenTelemetry to chat turns Jul 15, 2026
@calebeden calebeden changed the title feat: add opt-in OpenTelemetry to chat turns feat: add opt-in OpenTelemetry to chat turns and transcript loading Jul 15, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat: add opt-in OpenTelemetry to chat turns and transcript loading This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant