diffox
Blog

OpenTelemetry for coding agents: how to monitor what they do

Claude Code, Codex, Copilot and Cursor export telemetry with OpenTelemetry. What does each send, how do you turn it on, and does the prompt leave the machine?

ShareXLinkedIn

Summary. OpenTelemetry (OTel for short) is an open source project that lets an application export its metrics, logs and traces in one common, vendor-neutral format. On 4 November 2026 we read the telemetry documentation of Claude Code, OpenAI’s Codex, GitHub Copilot (the CLI, VS Code and the app), Cursor and Google’s Antigravity CLI, the Gemini CLI page and OpenTelemetry’s own documentation.

  • Four of the five tools export OpenTelemetry, each with its own setting. In Claude Code it is turned on with an environment variable, in Codex with the [otel] block in ~/.codex/config.toml, and in Copilot with an environment variable, a VS Code setting or an enterprise setting. Cursor leaves it to an admin on the Enterprise plan; Antigravity CLI’s documentation doesn’t mention OpenTelemetry.
  • They all speak OTLP, so one collector is enough. But the same data arrives under a different name in each tool: the token count is claude_code.token.usage in Claude Code, codex.turn.token_usage in Codex, gen_ai.client.token.usage in Copilot and cursor.token.usage in Cursor.
  • None of the four sends the prompt by default, but other things do go out. Codex writes the first 2,048 bytes of every tool output to its logs, and Claude Code adds your email address when you sign in with an account. In Gemini CLI, though, turning telemetry on sends the prompt too.
  • If you are writing your own agent, OpenTelemetry’s GenAI names are the shared vocabulary. Their status is still “Development”. Copilot and Gemini CLI use these names; Claude Code uses its own and explains in its documentation how they map.

What does it mean to monitor a coding agent?

4 / 5tools with OpenTelemetry export in their documentation
28event types in Claude Code’s documentation, besides 8 metrics
5content classes in Copilot, all off by default
2,048bytes of each tool output go to Codex’s log by default

We covered the arithmetic of tokens and the cache in the prompt caching post, and who approves an agent’s commands in the auto mode and sandbox post. This post looks at the record the agents keep themselves: what OpenTelemetry is, which agent sends what and with which setting, how one collector reads them all, what is worth monitoring, and which data should not leave the machine. The last section is for people writing their own agent.

If your team uses two or three coding agents, three questions come up sooner or later: how much are the agents spending, what are they doing, and what are they sending out? Monitoring a coding agent means answering those questions from a record rather than a guess. The agents already produce most of that record; Claude Code, Codex, GitHub Copilot and Cursor can send it with OpenTelemetry to a system you choose.

The agents’ telemetry documentation changes often. GitHub brought OpenTelemetry support to the Copilot app on 22 September 2026, through enterprise settings, and on 12 October 2026 it split the content it records into five classes: prompts, responses, tool arguments, tool output and policy details. Each one is turned on and off separately. And on 15 October 2026 Claude Code added the auto mode classifier’s verdict to the event that records tool permissions. That is why every fact below comes with the day we read it.

What is OpenTelemetry, and what is it for?

OpenTelemetry, OTel for short, is an open source framework and toolkit for generating, exporting and collecting telemetry data; it also defines a common protocol and common names. It is not a monitoring tool itself: it leaves storing and showing the data to other tools, the backends. For a coding agent, this means the agent hands over its data once, in the OTel format, and you can send it to any tool that reads OTel.

Coding agents use three of the signals OpenTelemetry supports:

3 signals, one protocol. The three signals agents use; all of them travel over OTLP. 1. Metrics. Numbers: tokens, cost, sessions, lines changed. 2. Events (logs). A single moment: a prompt sent, a tool approved, an API error. 3. Traces. A prompt’s path: model calls and tools, in order.
Source: OpenTelemetry’s documentation on signals; the examples come from the tools’ documentation, 4 November 2026.

The agents use the three to different degrees. Claude Code sends events through the logs protocol and turns on traces, as a beta, with a separate setting. Copilot CLI sends traces and metrics; its events arrive attached to the steps of a trace, the spans. Cursor sends no traces at all. Don’t let the split confuse you: according to OpenTelemetry, an event is a special type of log.

The data travels over OTLP (the OpenTelemetry Protocol). OTLP is “Stable” for traces, metrics and logs; it runs over gRPC and HTTP, and its default ports are 4317 for gRPC and 4318 for HTTP. The OpenTelemetry Collector is an intermediary that receives this data, processes it and passes it on wherever you want. OpenTelemetry generally recommends running a collector alongside your application, because it takes retries, batching, encryption and the filtering of sensitive data off the application’s hands. With coding agents the last of these matters in particular; we come back to it below.

Which agent sends what?

On 4 November 2026 we read the documentation of the five tools and of Gemini CLI, which people still use on its own. The table shows how each tool turns telemetry on, what it sends, whether it sends the prompt by default, and where the setting lives. The exporter is the part of the agent that sends the data out; it is chosen separately for each signal:

How coding agents turn on OpenTelemetry, what they send, whether they send the prompt by default, and where the setting lives
ToolHow to turn it onWhat it sendsPrompt by defaultWhere the setting lives
Claude CodeCLAUDE_CODE_ENABLE_TELEMETRY=1, then an exporter for each signalMetrics and events; traces in beta, with a separate settingNot sent, only its length. Turned on with OTEL_LOG_USER_PROMPTS=1The shell, ~/.claude/settings.json or managed settings; a repository’s settings file can’t turn it on
CodexAn [otel] block in ~/.codex/config.tomlLogs and traces; metrics with a separate exporterNot sent, only its length. Turned on with log_user_prompt = trueThe user’s config.toml or the admin’s requirements.toml; otel in a project’s config file is ignored
GitHub CopilotIn the CLI, COPILOT_OTEL_ENABLED=true or OTEL_EXPORTER_OTLP_ENDPOINT; in VS Code, github.copilot.chat.otel.enabledTraces and metrics; Copilot Chat in VS Code sends events tooNot sent; content is turned on with a separate settingAn environment variable, a VS Code setting or the enterprise managed-settings.json; in the Copilot app, an enterprise setting
CursorAn admin turns on OpenTelemetry Export in Team Settings; on the Enterprise planMetrics and logs; no tracesNot sent; conversation content is turned on with a separate team opt-inCursor sends from its own servers; the collector must be reachable from the internet
Antigravity CLINot stated in the documentationNot stated in the documentationNot stated in the documentationNot stated in the documentation
Gemini CLItelemetry.enabled or GEMINI_TELEMETRY_ENABLEDLogs, metrics and tracesSent: logPrompts defaults to true.gemini/settings.json or an environment variable; the target is local or Google Cloud

Source: the tools’ documentation and GitHub’s changelog, 4 November 2026. “Not stated in the documentation”: in the pages we read that day, we found no sentence that describes this; Antigravity’s enterprise documentation only says that, under an enterprise licence, telemetry and model interactions are logged to the Google Cloud project of the licence you select. OpenCode’s documentation doesn’t mention OpenTelemetry either. Google stopped serving Gemini CLI to Google AI Pro, Ultra and free users on 18 June 2026; Gemini CLI can still be used with a paid API key and with an enterprise licence.

Two differences come out of the table. The first is who can turn telemetry on. In Claude Code, Codex and Copilot CLI, developers can switch it on from their own machines; in Cursor, only an admin can. Organisations have a central route as well: managed settings in Claude Code, requirements.toml in Codex, enterprise settings in Copilot; in Cursor, the setting already lives in the admin dashboard. As for the repository: according to Claude Code’s documentation, a repository can’t use its own settings file to turn telemetry on, choose where the data goes or turn on content capture; Codex, too, ignores the otel key in a project’s config file and prints a warning. We covered what else a repository can make an agent do in the workspace trust post.

The second is where the data leaves from. Claude Code, Codex and Copilot CLI send it from the machine the agent runs on. According to Cursor’s documentation, Cursor runs the export from its own servers instead, so your collector has to sit at an HTTPS address that can be reached from the internet. Tools that send from the machine have a catch of their own: according to Codex’s documentation, if the CLI runs with network access turned off, telemetry can’t reach the collector; you have to allow the collector’s address separately.

How do you collect them all in one collector?

Since all the agents speak OTLP, one collector is enough. The thing to watch is the protocol: Copilot CLI sends only OTLP/HTTP, and Cursor sends only protobuf over HTTP; Claude Code, Codex and Gemini CLI can also send over gRPC. If the collector listens on both ports, they can all write to the same place. The configuration below is an example for trying this on one machine; it follows the structure in OpenTelemetry’s configuration documentation and prints everything it receives to the collector’s own output:

otel-collector.yaml
# Example: for trying it out on one machine
receivers:
  otlp:
    protocols:
      grpc:
        endpoint: localhost:4317
      http:
        endpoint: localhost:4318

exporters:
  debug:
    verbosity: detailed

service:
  pipelines:
    metrics:
      receivers: [otlp]
      exporters: [debug]
    logs:
      receivers: [otlp]
      exporters: [debug]
    traces:
      receivers: [otlp]
      exporters: [debug]

Claude Code and Copilot CLI read the same environment variables. If you put these in your shell, both send to the collector’s HTTP port:

bash
# Claude Code and Copilot CLI: the same collector, HTTP port
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf

# Claude Code: turn telemetry on, send metrics and events
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_METRICS_EXPORTER=otlp
export OTEL_LOGS_EXPORTER=otlp

According to Copilot CLI’s documentation, Copilot CLI turns telemetry on by itself when OTEL_EXPORTER_OTLP_ENDPOINT is set, so a Copilot CLI you start in this shell writes to the collector too. Claude Code has no default protocol, which is why the OTEL_EXPORTER_OTLP_PROTOCOL line is required. Codex’s setting lives in ~/.codex/config.toml; in the gRPC example, the address is just the host and the port:

~/.codex/config.toml
[otel]
exporter = { otlp-grpc = { endpoint = "http://localhost:4317" } }
trace_exporter = { otlp-grpc = { endpoint = "http://localhost:4317" } }

Codex’s metrics live in a separate setting, metrics_exporter; its default is Codex’s own usage data, which goes to OpenAI (statsig), so you have to point it at OTLP separately. In Cursor, the setting is in the admin dashboard: you enter the collector’s HTTPS address and a token in Team Settings and test the connection. Because Cursor sends the data from its own servers, it can’t reach this local example; for Cursor you have to put the collector at an address that can be reached from the internet. In Gemini CLI, when you turn telemetry on with GEMINI_TELEMETRY_ENABLED=true, the default address is already http://localhost:4317.

When they all write to the same place, service.name tells them apart: Claude Code arrives as claude-code, Copilot CLI as github-copilot, Copilot Chat in VS Code as copilot-chat and Cursor as cursor; Codex tags its events with this field too. The quickest way to see that the setup works is to do what Claude Code suggests: start a session and look for the claude_code.session.count metric. The debug output also shows, line by line, what each agent actually sends; that is where you see what goes out before you connect a backend.

One collector doesn’t mean one shared dashboard: the same data arrives under a different name from each agent, and even the token count has four names in four tools. For a shared dashboard, you have to map the names in the collector or in the backend. For a shared set of names, see the GenAI names in the last section.

What is worth monitoring?

The agents send dozens of fields, but their documentation puts a few questions first. Each of the ones below comes from a tool’s own documentation. The agent doesn’t set up alerts: according to Claude Code’s documentation, the agent sends only the raw event stream; finding anomalies, comparing sessions and alerting are the backend’s job.

Four questions worth watching. Each one from a tool’s own documentation. How much was spent?: Tokens and cost per session and team. An estimate, not a bill. Are edits being accepted?: Accepts and rejects, and how much accepted code stays. Who approved the commands?: A rule, a hook, the user or the classifier. What went wrong?: Retries that ran out, tool calls that failed.
Source: the Claude Code, Codex, Copilot and Cursor documentation, 4 November 2026.
  • Tokens and cost. Claude Code counts tokens by type (input, output, cache read, cache write) and cost in dollars; its documentation suggests tracking usage by team and by person, finding the sessions that spend the most, and attributing cost to a skill, a plugin or a subagent. These numbers are not a bill: Claude Code says its cost metrics are approximations, and Cursor says its own is an estimate. Copilot’s github.copilot.cost field is not money but a multiplier used in billing; you have to read the AI units spent from the root invoke_agent span only, or you count them twice. Codex’s metric list has tokens but no cost.
  • Accepted and rejected edits. Claude Code’s claude_code.code_edit_tool.decision counts each time a developer accepts or rejects a file edit. Copilot Chat in VS Code counts the same thing with copilot_chat.edit.acceptance.count, and separately measures how much of the accepted code stays in place afterwards.
  • Who approved the commands? Claude Code’s tool_decision event says whether the decision came from a rule, a hook or the user; since version 2.1.301 it also carries the auto mode classifier’s verdict. Codex’s codex.tool_decision event records whether the decision came from the config or from the user. Codex’s security documentation recommends reviewing the events regularly for changes to approval and sandbox settings and for unexpected tool runs.
  • Errors. Claude Code retries a failed API request internally and sends the api_error event only when it gives up; with the default settings, the event’s attempt is at most 11. Its documentation suggests checking whether a new api_request arrives after the error, to tell a session that recovered from one that stalled. On the tool side, the same documentation also suggests looking at the most used tools, their success rates, their durations and the error types per tool.

There is also a counting trap. Cursor sends logs at least once, so the same record can arrive twice; its documentation asks you to deduplicate on cursor.event.id before counting. It also sends metrics as deltas: you get the total by adding up the deltas yourself.

What should not leave the machine?

The 2026 list from the OWASP Foundation, a nonprofit that works on software security, is clear about this. As we described in the OWASP LLM Top 10 post, LLM02 Sensitive Information Disclosure counts logs and telemetry among the channels that can leak data, and OWASP asks you to apply to each of them the classification and redaction rules you apply to the final answer. The same section says that observability platforms (Langfuse, LangSmith, Datadog LLM Observability) record prompts, responses and traces in full by default.

In a coding agent, three things are truly sensitive: the prompt and the model’s response, file contents, and tool output. As GitHub warns, this content can carry source code, file contents, commands and user directory paths. File contents mostly enter telemetry as tool output, because a file the agent reads is a tool result: in Claude Code, the setting that turns on tool output adds to traces the raw contents of the files read, Bash output, and what MCP tools and web searches return. The good news is that the tools’ documented defaults keep most of this out. OpenTelemetry’s GenAI conventions also say that system instructions, user messages and model output should not be recorded by default. But most is not all:

What goes out by default once telemetry is on?. Without touching any content setting. Claude Code Your email address: On every record when signed in. Only the prompt’s length. Codex First 2,048 bytes of tool output: In every tool_result event. Only the prompt’s length. Copilot · Cursor No content: Prompt, response and tool data need a separate setting. Gemini CLI The prompt itself: logPrompts defaults to true. Set it to false to stop it.
Source: the tools’ telemetry documentation, 4 November 2026. OpenTelemetry export is off by default in all of these tools; the cards apply once you turn it on.

The settings that turn content on differ from tool to tool, too. In Claude Code, the prompt, tool details and tool output are three separate settings. A fourth, OTEL_LOG_RAW_API_BODIES, sends the whole API request and response, meaning the entire conversation history; according to its documentation, turning it on counts as consenting to everything the other three settings reveal. In Copilot, since 12 October 2026, the five content classes are turned on one by one; GitHub recommends turning on only the classes an audit needs and sending them to an approved endpoint. Gemini CLI needs a setting in the opposite direction: its enterprise documentation asks you to set logPrompts to false.

Check the examples you copy, too. The Aspire and Langfuse examples in VS Code’s documentation set captureContent to true; that can be handy for a trial, but if the setting finds its way into the team’s configuration, the prompts go out as well. Langfuse’s Claude Code integration doesn’t use Claude Code’s OpenTelemetry output at all: a Stop hook that runs after every response reads the conversation transcript and sends the prompts, the responses, and the tools’ inputs and outputs to Langfuse. Because this path sits outside Claude Code’s telemetry settings, the prompt setting doesn’t touch it; installing the hook means choosing to send the content. We covered hooks in the hooks post.

The last line of defence is the collector. Claude Code’s documentation gives a ready-made rule for deleting the prompt in the collector. Because the prompt arrives in two separate fields (prompt and prompt_text), the rule has to delete both by name:

otel-collector.yaml
processors:
  attributes/drop-prompt-text:
    actions:
      - key: prompt
        action: delete
      - key: prompt_text
        action: delete

This processor runs only in the pipelines that list it; defining it isn’t enough, you also have to add it to the processors list of the logs pipeline. OWASP, too, asks you to scrub logs and traces before they enter a monitoring tool, and to encrypt them in transit and at rest. Codex’s documentation likewise recommends treating tool arguments and outputs as sensitive, and redacting them in the collector where possible, or in the system that collects your security events (SIEM).

Then there is identity. When you sign in with an account, Claude Code adds your email address to every record and sends it only to your collector; its documentation says that if this is a problem, you should filter the field out in the backend. In Copilot, identity capture is a separate setting and off by default. VS Code’s documentation recommends turning it on only if your organisation has a purpose for it, access controls and a retention policy.

Which names should you use if you write your own agent?

If you are writing your own agent or harness, you choose the names. OpenTelemetry’s answer is the GenAI semantic conventions: common names for model calls, agents and tools. These conventions are kept in a separate OpenTelemetry repository, and their status, in the page’s own words, is “Development”: not stable yet.

A few examples: a model call’s tokens go in gen_ai.usage.input_tokens and gen_ai.usage.output_tokens; an agent run is an invoke_agent span, and a tool run an execute_tool span. Copilot CLI and VS Code use these names, and Gemini CLI’s token metrics follow these conventions too. Claude Code uses its own names and explains in its documentation how they map: according to the GenAI conventions, gen_ai.usage.input_tokens should include the tokens read from and written to the cache; Claude Code’s input_tokens field doesn’t, so for the total you have to add the three together.

In practice, “Development” means the names can change. The field for tokens written to the cache is gen_ai.usage.cache_write.input_tokens in the new version of the conventions and gen_ai.usage.cache_creation.input_tokens in older ones. On 4 November 2026, Copilot CLI’s documentation listed the older one, and Claude Code’s documentation says to use whichever your backend expects.

For content, the rule is clear: according to the GenAI conventions, system instructions, user messages and model output should not be recorded by default. The recommended way in production is to put the content not inside the telemetry but in separate storage, and to write only its address on the span; that way you can give the content access rules of its own.

One more lesson from a system running in production: “nothing was found” and “that step never ran” must not look the same in the record. Both leave an empty result; if the record doesn’t tell them apart, a run that looks clean may be a run in which nothing was looked at. A zero says nothing on its own either: according to Claude Code’s documentation, cache_creation_5m_tokens and cache_creation_1h_tokens come in as zero when the API response doesn’t report them, even when the total written to the cache is above zero.

In diffox, our AI code review tool, the record is kept so that it makes this distinction. Each review’s record gets stage-by-stage counts: how many findings each step received and how many it passed on to the next. If a step never ran, its value is written as empty (None), not as zero; zero means “it ran and found nothing”. If the model returns no review, the result is not reported as “no findings”; the review stops with an error. That way, a clean pull request and a pull request nobody looked at don’t look the same in the record.

Frequently asked questions

What is OpenTelemetry?

It is an open source standard and toolkit for applications to generate, export and collect telemetry data (metrics, logs and traces); OTel for short. It is not a monitoring tool itself: it sends the data over the OTLP protocol to a backend that reads OTel, or to a collector you put in between. Among coding agents, Claude Code, Codex, GitHub Copilot and Cursor can export data with this standard.

What is an OpenTelemetry collector?

The OpenTelemetry Collector is an intermediary that receives telemetry data, processes it and passes it on to one or more backends. OpenTelemetry generally recommends running a collector alongside your application, because it takes retries, batching, encryption and the filtering of sensitive data off the application’s hands. With coding agents, the last of these is where it really helps: you can delete fields such as the prompt or the user’s identity before they reach the backend. The default OTLP ports are 4317 for gRPC and 4318 for HTTP.

How do you turn on OpenTelemetry in Claude Code?

With CLAUDE_CODE_ENABLE_TELEMETRY=1. Then set OTEL_METRICS_EXPORTER=otlp for metrics, OTEL_LOGS_EXPORTER=otlp for events, a protocol (OTEL_EXPORTER_OTLP_PROTOCOL; Claude Code has no default) and the collector’s address (OTEL_EXPORTER_OTLP_ENDPOINT). You can put these in your shell, in ~/.claude/settings.json, or in managed settings for an organisation; a repository’s settings file can’t turn telemetry on. Traces are in beta and need CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1 and OTEL_TRACES_EXPORTER. You can check the setup with the claude_code.session.count metric.

How do you turn off Claude Code telemetry?

There are two separate kinds of telemetry. The data you send to your own system with OpenTelemetry is off unless you turn it on; if you did, remove CLAUDE_CODE_ENABLE_TELEMETRY or set the signal’s exporter to none. Anthropic’s own operational telemetry is on by default when you use Claude Code with the Claude API; according to its documentation, it doesn’t include your code, your prompts or your file paths, and DISABLE_TELEMETRY=1 turns it off. For error reports there is DISABLE_ERROR_REPORTING=1, and for all non-essential traffic CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC.

Does Codex export OpenTelemetry data?

Yes, but it is off by default. You add an [otel] block to ~/.codex/config.toml and choose exporter for logs and trace_exporter for traces (otlp-http or otlp-grpc); metrics are routed separately with metrics_exporter. The prompt isn’t sent by default (log_user_prompt = false), but the first 2,048 bytes of every tool result are written to the logs. An otel setting in a project’s .codex/config.toml is ignored; admins can enforce the setting with requirements.toml.

Do prompts end up in telemetry?

Not by default in Claude Code, Codex, GitHub Copilot and Cursor; Claude Code and Codex record only the prompt’s length. Turning it on takes a separate setting: OTEL_LOG_USER_PROMPTS=1 in Claude Code, log_user_prompt = true in Codex, content capture in Copilot, and, in Cursor, conversation content with a team opt-in. In Gemini CLI, though, turning telemetry on sends the prompt too, because logPrompts defaults to true. Integrations that work through a hook, such as Langfuse’s, read the conversation transcript directly and send it; Claude Code’s prompt setting doesn’t close that path.

Which tool can you use to monitor a coding agent?

Any backend that reads OTLP. Examples from the vendors’ own pages: Grafana Cloud’s Claude Code integration takes metrics and logs over OTLP and sets up ready-made dashboards; Datadog’s Agent Console, in preview, connects Claude Code over OTLP and Codex, Copilot and Cursor through its own integrations; Langfuse monitors Claude Code with a hook. To try it locally, running the OpenTelemetry Collector with debug output is enough. Whichever you choose, check where the prompt and identity fields go: OWASP notes that observability platforms record the full prompt by default.