Skip to content

feat(telemetry): add analytics collection and runtime signals#95

Draft
Gucc111 wants to merge 9 commits into
OpenBMB:mainfrom
Gucc111:feat/analytics
Draft

feat(telemetry): add analytics collection and runtime signals#95
Gucc111 wants to merge 9 commits into
OpenBMB:mainfrom
Gucc111:feat/analytics

Conversation

@Gucc111
Copy link
Copy Markdown
Collaborator

@Gucc111 Gucc111 commented Jun 1, 2026

Summary

  • add telemetry collection, sending, runtime context, and receiver contract documentation
  • emit deployment, loop-stage, routing, model request, and runtime diagnostic signals across gateway and runtime flows
  • sanitize path-like values and restrict error properties to protect user privacy
  • add provider base URL normalization and telemetry-focused tests

Impact

This adds privacy-conscious analytics signals for deployment visibility and runtime diagnostics while preserving existing application behavior.

Validation

  • npm test
  • 21 tests passed

Gucc111 and others added 8 commits May 29, 2026 15:17
…signals

Refine telemetry semantics for multi-instance environments by adding deploymentMode and instanceId while removing projectCommitHash. Expand feature_used into module and loop-stage dimensions, including session loop instrumentation and receiver contract documentation for idempotent ingestion.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove projectPath from outbound events, hash sessionId, and limit
error_occurred to classification fields only.

Co-authored-by: Cursor <cursoragent@cursor.com>
Only feature_used and error_occurred are emitted; DAU uses any valid event.

Co-authored-by: Cursor <cursoragent@cursor.com>
Report normalized provider API base URL after routing on session
request_started and router success/error paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new telemetry/analytics subsystem (analytics.v2) and wires it through gateway, router, always-on, cron, model runtime, and memory flows to emit privacy-conscious runtime signals and diagnostics.

Changes:

  • Introduces a telemetry collector/sender with batching, retries, and on-disk queue persistence (src/telemetry/*).
  • Emits loop-stage and error signals across session gateway, router (judge/fallback), always-on phases, cron phases, and memory workflows.
  • Adds provider base URL normalization + new tests and receiver contract documentation.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 36 comments.

Show a summary per file
File Description
tests/telemetry/context.test.ts Tests runtime context fields (deploymentMode/instanceId/etc.).
tests/telemetry/collector.test.ts Tests sending, retries, privacy sanitization, and allowlisted error metadata.
tests/router/RouterRuntime.telemetry.test.ts Tests router telemetry behavior (judge participation, fallback preservation).
tests/model/normalizeProviderBaseUrl.test.ts Tests normalization rules for provider base URLs.
src/telemetry/types.ts Defines analytics schema + telemetry types/enums and client interface.
src/telemetry/sender.ts Implements batching sender, retries, and queue persistence/restore.
src/telemetry/index.ts Exports telemetry public API.
src/telemetry/context.ts Resolves runtime context (installation/instance ids, deployment mode, commit/version).
src/telemetry/collector.ts Implements telemetry client, sanitization, config/env parsing, and event building.
src/router/tokenSaver/classifyAndRoute.ts Adds telemetry emission for judge lifecycle and failures.
src/router/RouterRuntime.ts Threads telemetry through router runtime and emits fallback/retry signals.
src/model/streaming/streamModel.ts Emits providerBaseUrl on request_started model events (normalized).
src/model/protocol/canonical.ts Extends CanonicalModelEvent.request_started to include providerBaseUrl?.
src/model/normalizeProviderBaseUrl.ts Adds base URL sanitizer/normalizer helper.
src/model/ModelRuntime.ts Adds getProviderBaseUrl() to ModelRuntime and implements it.
src/model/index.ts Re-exports normalizeProviderBaseUrl.
src/gateway/protocol/types.ts Extends submitTurn input with optional telemetry attribution context.
src/gateway/client/InProcessGateway.ts Emits session loop telemetry based on agent events and submit context.
src/cron/runtime/CronRuntime.ts Adds cron telemetry signals for phases and failures.
src/context/memory/EdgeClawMemoryProvider.ts Adds telemetry around memory retrieve/capture (loop start/end + errors).
src/context/memory/edgeclaw-memory-core/src/core/skills/llm-extraction.ts Adds telemetry for memory LLM calls (request/response/errors).
src/context/memory/edgeclaw-memory-core/lib/core/skills/llm-extraction.js Same as above for compiled JS output.
src/context/memory/createEdgeClawMemoryProviderFromConfig.ts Wires telemetry into EdgeClaw runtime/provider creation.
src/cli/pilotdeck.ts Creates telemetry collector, passes it through subsystems, adds shutdown/error hooks.
src/cli/createLocalGateway.ts Creates/owns telemetry collector by default and passes it into project runtime registry + gateway.
src/always-on/runtime/DiscoveryFire.ts Emits always-on telemetry events and propagates attribution to gateway turns.
src/always-on/runtime/createApplyHandler.ts Threads telemetry into DiscoveryFire from apply handler.
src/always-on/runtime/AlwaysOnRuntime.ts Threads telemetry into DiscoveryFire via runtime options.
src/always-on/runtime/AlwaysOnManager.ts Threads telemetry into always-on runtime creation.
src/always-on/protocol/types.ts Adds additional always-on phases (workspace/report/apply started/completed).
docs/telemetry/receiver-contract.md Documents analytics.v2 receiver contract, schema, and privacy rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/telemetry/context.ts
Comment thread src/telemetry/collector.ts
Comment thread src/telemetry/collector.ts
Comment thread src/telemetry/collector.ts
Comment thread src/cli/pilotdeck.ts
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.

2 participants