nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Feature] Opt-in OpenTelemetry export for metrics, traces and events

Open akramcodez opened this issue 2 weeks ago • 2 comments

Description

Nanocoder has no way to export telemetry in a standard format. Logs go through the internal logger, and usage lives in the local /stats ledger, but there is no OpenTelemetry (OTLP) output for traces, metrics or events. A search of source/ for OpenTelemetry finds nothing.

Use Case

Teams adopting a terminal agent want to answer basic operational questions: how many sessions run per day, token and cost totals per model, tool call failure rates, p95 latency per provider, approval prompt counts, and whether a model or provider change made things worse. Codex CLI and Gemini CLI both offer OpenTelemetry export for this. Without it, nanocoder usage inside a company is invisible and cannot be compared with other tools on the same dashboards.

Proposed Solution

An opt-in nanocoder.telemetry block (disabled by default, never enabled implicitly):

  • exporter: none (default), otlp-http, otlp-grpc or console; endpoint and headers with the existing $VAR substitution.
  • Metrics: token counts (input, output, cache), cost, request latency, tool call count and duration by tool name and outcome, compaction count.
  • Events or spans for: session start and end, model request, tool call, approval decision, hook run.
  • A logPrompts switch that defaults to false. Prompt text, file paths, command lines and tool arguments are never exported unless the user turns it on, and the existing prompt scrubbing applies when they do.

Alternatives Considered

  • Parse the local log and /stats files with a sidecar. Fragile and not real time.
  • Use /usage per session by hand. Does not aggregate across people or machines.

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] This feature aligns with the project's goals (local-first AI assistance)

Implementation Notes (optional)

Most of the data already flows through source/usage/, the stats recorder in source/stats/ and the tool runtime. An exporter can subscribe to those points and load the OpenTelemetry packages lazily, so the default start-up path and the --version/--help fast paths are unchanged.

akramcodez avatar Nov 17 '26 08:11 akramcodez

@akramcodez I’d like to take this. Could you assign it to me?

Ember452 avatar Nov 20 '26 13:11 Ember452

assigned @Ember452, go ahead 👍

akramcodez avatar Nov 21 '26 06:11 akramcodez