Repository navigation
telemetry: opt-in OpenTelemetry export (refs #26) - #46
Merged
Merged
Conversation
Item 1 of #26. Off unless INCODE_TELEMETRY=1 (or admin.json telemetry) and an OTLP endpoint are set. Exported by hand over the reqwest incode already has, so no OpenTelemetry crates and no gRPC stack: http/json only (another protocol is reported and nothing is sent), and only to https or this machine, since OTEL_EXPORTER_OTLP_HEADERS carries tokens. Metrics as delta sums: sessions, tokens by type and model, cost, tool calls by tool and outcome (allowed when the tool ran, denied when a gate refused it, counted around Toolbox::run_call), turns and their seconds. Events as log records: permission prompts, compactions, user prompts (length only; text only with OTEL_LOG_USER_PROMPTS=1). Exported after each turn on a thread of its own, and at the end of -t.
This was referenced Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#26 item 1.
Decisions
reqwestclient incode already has, throughruntime::http, so proxies, loopback andINCODE_CA_CERTSall apply. Noopentelemetrycrates, no gRPC.INCODE_TELEMETRY=1, or"telemetry": truein admin.json, andOTEL_EXPORTER_OTLP_ENDPOINT(or the per-signal endpoints).http/json;httpsnor this machine (the headers usually carry a token);OTEL_EXPORTER_OTLP_HEADERS;OTEL_LOG_USER_PROMPTS=1.What
incode.session.countmode: repl / acp / taskincode.token.usagetype,modelincode.cost.usage(USD)model, priced models onlyincode.tool.callstool,outcomeincode.turn.count,incode.turn.duration(s)modelTool outcomes.
allowedmeans every gate passed and the tool ran, however it then ended.deniedmeans a gate refused it. It's counted by a thin wrapper aroundToolbox::run_call, whose about 15 return points stay indecide_and_run. A thread-local flag set at the dispatch line tells the two apart, and it's saved and restored so a sub-agent's nested calls can't change the outer call's count.Events (log records):
incode.permission_prompt(fromconfirm_with_personandask_protected),incode.compaction(manual and automatic, API route),incode.user_prompt.When. After every turn, on its own thread, and at the end of
-t, before exit. Each export is bounded at 5 s; a failed one is traced and dropped.Where configured.
incode --adminshows whether it's on and where it sends. There's a newtelemetryfield in admin.json.Tests
telemetry::tests::recorded_usage_reaches_a_collector_as_otlp_json: a fake collector on loopback receives/v1/metricsand/v1/logswith the operator's header, delta temporality, and the right sums and events. No prompt text arrives, and nothing is sent twice.telemetry::tests::telemetry_is_off_unless_turned_on_and_refuses_what_it_cannot_do: every refusal case, plus header decoding.toolbox::tests::a_tool_call_is_counted_allowed_when_it_ran_and_denied_when_refused: a refusedWritecounts as denied; a read and a failed read count as allowed. Control: never setting the flag fails it.cli::agent_turn::tests::a_finished_turn_records_its_tokens_and_one_turn. Control: not recording fails it.Local Windows gate: fmt, clippy
-D warnings,cargo test(2229 lib passing; the one failure was the dead-capability check, now fixed and passing).Not covered
toolattribute.