OpenProgram Docs

OpenTelemetry export

The worker can send one trace per turn, with token, cost and tool metrics, to a collector the user names. The code is openprogram/operations/telemetry/; the user page is OpenTelemetry export.

From events to spans

Event bus turn.start / end / failed model.response_* tool.before / after Usage hook one UsageEvent per model call: tokens, cost, model Recorder spans and metrics OTLP Collector
  1. Event bus and usage hookturn, model response and tool events; one UsageEvent per model call
  2. Recorderspans and metrics
  3. Collectorover OTLP
SpanOpens onCloses onParent
invoke_agent openprogramturn.startturn.end or turn.failedRoot
chat <model>model.response_started; renamed and filled by the usage hookmodel.response_completedThe turn in the event's turn metadata, else the session's open turn
chat <model>, outside the loopOne usage event whose call kind is not the loop's (title, compaction, memory, a model asked from a tool)The session's open turn, else root
execute_tool <tool>tool.beforetool.afterThe turn

Event timestamps become span times, so a span measures what the runtime saw. The usage hook runs inside the provider request's context, which is how it finds the open chat span: the current turn ContextVar, then the session. turn.failed was added to the registry for this: the loop's error path had no event.

Decisions

DecisionFollowsWhy
Off by default; nothing has a default destinationClaude Code (CLAUDE_CODE_ENABLE_TELEMETRY), Cline, Hermes (no default endpoint ships)Codex ships a built-in metrics destination on by default; a local single-user tool has no business sending anything unasked
A setting and an environment variable turn it on; the standard OTEL_* variables keep workingCodex ([otel] in config), Claude Code (environment)The App starts the worker without the user's shell environment, so a setting is needed; collectors are documented in OTEL_* terms, so those must work too. OTEL_SDK_DISABLED wins over both
OTLP over HTTP/protobuf by default; gRPC as a separate extraClaude Code (defaults to http/protobuf); Codex and Cline support bothEvery common collector listens on 4318; grpcio is a large native wheel for five platforms. The Python SDK has no OTLP JSON exporter, so http/json falls back to protobuf
Traces and metrics; no logs signalCodex (trace and metrics exporters)Claude Code sends its events as logs. A turn, its model calls and its tool calls are a tree, and spans carry the same attributes with the parent link; a logs copy would duplicate them
Span names and gen_ai.* attributes from the GenAI semantic conventionsOpenTelemetry GenAI conventions; no peerPeers use their own names; the conventions make collectors' GenAI views (Langfuse, Phoenix, Datadog) read the trace as it is
token.usage with a type label, cost.usage in USDClaude Code (claude_code.token.usage, claude_code.cost.usage)Counters sum directly in dashboards; one metric with a type label keeps cache tokens beside input and output. Every metric name starts with openprogram.
tool.call.count and .duration by tool and outcomeCodex (codex.tool.call, codex.tool.call.duration_ms)The two questions asked of tools: how often, how slow, how often failing
No content by default; one opt-in for prompts, one for tool arguments and resultsClaude Code (OTEL_LOG_USER_PROMPTS, OTEL_LOG_TOOL_DETAILS), Codex (log_user_prompt)Not Gemini CLI, which logs prompts unless told not to. The variables are OPENPROGRAM_OTEL_LOG_*, so a Claude Code variable in the shell does not opt OpenProgram in
Opted-in text loses secrets and is cut at 64 KiBCodex (64 KiB cap on exported text), Hermes (redact_bounded)Reuses state/secret_removal: field names, bearer tokens, sk- keys, URL credentials, private keys, password assignments
A subscriber on the bus and the usage hook, not calls in the loopHermes (a fail-isolated subscriber on its monitoring events)Codex threads a telemetry object through the session; here the bus and the ledger already carry every fact, so the loop stays free of OpenTelemetry and the recorder sits in operations, above everything it reads
SDK in the optional telemetry extra, imported only when on; the App carries it through allHermes (hermes-agent[otlp], lazy import)A worker with export off never imports it; a missing package logs one line and export stays off
Providers of its own, not the global onesHermesA library that calls opentelemetry.trace does not start exporting through ours
Fail open everywhereAll peersHandlers catch everything; at most 512 open spans per kind, the oldest ended as abandoned; at stop, open spans end as abandoned and the flush waits at most 1.5 s of the 5 s stop budget
A collector on this computer is reached without the user's proxyClaude Code (fixed export to localhost:4318 going through a proxy)A corporate HTTPS_PROXY cannot reach the user's loopback collector
Resource: service.name=openprogram and the version; no host attributesClaude Code (OTEL_RESOURCE_INCLUDE_HOST off by default)OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES still apply

Implementation status

  • Prompt text comes from chat.before_send, which only OpenProgram's own windows emit; a channel turn carries its prompt length only.
  • Settings apply at the next worker start.
  • The App gets the SDK packages with the next feature release, since they change the runtime layer.
Last updated · 2026-11-30