Skip to navigation

Claude Code OpenTelemetry: Semantic Conventions for Agents

In short: Define consistent resource and event attributes for Claude Code sessions without turning semantic conventions into transcript capture.

Published 20 min read
On this page

Direct answer

OpenTelemetry semantic conventions are the shared attribute names that make telemetry from different sources comparable, and applying them to Claude Code means choosing resource attributes that describe the agent deployment, session fields that tie events to one working session, and request fields that tie an API call to the prompt that triggered it. The official conventions define common attributes for traces, metrics, logs and resources. Claude Code exports named usage metrics and correlation attributes such as prompt.id and request_id that a team schema can build on. The concrete win is that an on-call engineer can answer “which session touched this service and which request failed” without opening a transcript. The concrete loss is that conventions do not guarantee correlation on their own, because correlation depends on configuration, retained event data and the fields the exporter actually sends. Treat semantic conventions as a naming discipline, not as a transcript capture mandate.

The practical verdict: standardize the metadata that describes the agent, its environment and its decisions. Leave prompt bodies and tool payloads out of telemetry by default, and only add content fields after an approved review.

Why telemetry conventions cost time when they are missing

An agent that changes infrastructure leaves traces in several systems. The Claude Code exporter emits usage metrics and event attributes. The cloud provider emits audit records. The Kubernetes API server emits its own audit stream. When those streams use different names for the same idea, every incident begins with a translation exercise.

Three costs show up repeatedly. The first is search cost. An engineer who wants every session that touched a namespace has to remember whether the field was called session_id, sessionId or claude.session.id. The second is dashboard cost. A panel built on one attribute name breaks silently when a second exporter uses a synonym. The third is review cost. A postmortem that mixes naming conventions spends its first hour reconciling fields instead of reconstructing decisions.

There is also a failure mode on the other side. Teams that try to solve search by logging everything capture prompt bodies, tool arguments and file contents into telemetry backends. That converts an observability pipeline into a transcript archive with different retention, different access controls and different legal exposure. The conventions exist so that metadata is enough. Use them that way.

Consider a concrete morning. A load balancer change goes out at 09:14 and error rates rise at 09:21. Two engineers open two systems. One searches the cloud audit log for the change and finds an identity. The other searches the agent telemetry for the same window and finds a session. Without a shared attribute naming the deployment and the session, the two records stay separate until someone reads both by hand. With a schema that puts service.name, deployment.environment and session.id on the agent side and a stable request identifier on the cloud side, the join is one query and the conversation moves from “who did this” to “what did the change touch”.

Without conventions, that same morning looks different. An audit record names an identity that does not appear in the agent telemetry. The agent telemetry names a session that does not appear in the audit record. Someone suggests checking the working transcript, which requires a different access path and a different approval. Twenty minutes later the timeline is still two disconnected lists, and the incident channel has started guessing.

Evidence and its limits

Official, F073: OpenTelemetry semantic conventions define common attributes that give meaning to collected telemetry. The specification index and the conceptual overview describe the purpose of the conventions. Conventions do not automatically make custom Claude Code fields standard or correctly populated.

Official, F074: An OpenTelemetry resource represents the entity producing telemetry and is described with resource attributes. The resources concept page documents that role. Resource design should reflect the actual service, environment and deployment model, not a template copied from another team.

Official, F075: Claude Code exports named usage metrics and correlation attributes that can inform a team-specific telemetry schema. The monitoring and usage documentation describes cost.usage, token.usage and correlation fields including prompt.id and request_id. These are product telemetry fields, not an OpenTelemetry standard written for coding agents.

Official, security context: The Claude Code security documentation describes permission modes, sandboxing, managed settings and OpenTelemetry metrics as organizational safeguards. That documentation describes available controls, not proof that a particular team has enabled them.

Derived, schema design: Mapping agent telemetry onto OpenTelemetry attribute names is an editorial recommendation built on the two official sources. It is not a claim that OpenTelemetry publishes a coding-agent semantic convention, because no such dedicated convention was found during research.

No measurement of card overhead, ingestion volume or query latency is reported here, because none was collected.

Evidence map of OpenTelemetry semantic conventions, resource attributes, Claude Code telemetry fields and a team schema that links sessions to services.
Editorial evidence map based on F073, F074 and F075. Official sources cover the convention purpose, the resource model and the Claude Code fields; the team schema that joins them is derived.

Telemetry signals

A useful schema answers operational questions. Start from the question and work backward to the attribute.

Telemetry signal Operational question it answers Candidate attribute
Resource attributes Which agent deployment produced this event service.name, service.version, deployment.environment
Span or log timestamp When did the agent act relative to the cloud change Instrumentation timestamp, normalized to UTC
prompt.id Which prompt started this chain of work Claude Code correlation attribute
request_id Which API request carries this record Claude Code correlation attribute
Tool decision event Did the agent request a protected action and what decided it Tool decision event with outcome and source
cost.usage and token.usage What did the session consume Claude Code usage metrics
Session identifier Which events belong to one working session Team-defined session.id attribute

Read the table as a requirements list, not as a copy template. Every attribute you add should trace back to a question someone actually asks during an incident or a review.

Resource attributes

The resource describes the producer of telemetry. For a Claude Code deployment the producer is the agent runtime, and the useful resource attributes are the ones that let a reader distinguish one deployment from another.

Attribute Data type Cardinality risk Suggested owner
service.name string, low cardinality Low if the name comes from a fixed list Platform team
service.version string, controlled Medium if builds are frequent Release owner
deployment.environment string, low cardinality Low if limited to prod, staging, dev Platform team
Host or container identifier string, high cardinality High on ephemeral infrastructure Platform team
Team or owning group string, low cardinality Low if mapped to a directory Governance owner
Model identifier in use string, controlled Low if the model list is short Platform team

Two rules keep this table healthy. Fixed vocabularies beat free text, because a typo in a service name creates a second service in every dashboard. High-cardinality identifiers belong on individual spans or log records, not on resource attributes that get attached to every point a producer emits.

A resource attribute is also the wrong place for anything that describes one interaction. Session identity and request identity change per event. Putting them on the resource would multiply time series and break aggregation.

Session and request fields

Claude Code documents prompt.id and request_id as correlation attributes that link API requests to the prompts that caused them. Those two fields are the backbone of agent correlation.

Field What it links Where it is read Caveat
prompt.id One working prompt to the requests it generated Claude Code telemetry events Present only when telemetry is configured
request_id One API request to its prompt Claude Code telemetry events Retention windows limit how long it can be joined
Team session identifier All activity in one working session Set by the invoking harness or wrapper Must be propagated to every span to be useful
Cloud request identifier One control-plane write to its audit record Cloud audit log Different namespace from the agent identifier

A session identifier is worth standardizing even though Claude Code does not mandate one. When the wrapper that launches the agent assigns a session identifier and propagates it onto every span and log record, the whole working session becomes one searchable unit. Without it, correlation depends entirely on the product attributes, and any activity outside the exporter becomes invisible.

Event naming

Events should have stable, lowercase, dot-separated names that describe what happened. The Claude Code exporter already publishes names for user prompt, assistant response, tool result, API request, API error and tool decision events. Build on those names rather than inventing parallel ones.

Three naming rules are enough for most teams. Use the verb that describes the observable action, such as tool.decision or api.error. Keep the outcome in an attribute rather than encoding it into the event name, so tool.decision with an outcome attribute covers both allow and deny. Reserve a team prefix for events that your wrapper adds, so a reviewer can tell product events from wrapper events at a glance.

Convention decision Validation check Schema version action
Event name uses a fixed verb list Grep exporter config for unlisted verbs Bump minor version when a verb is added
Outcome carried as an attribute Sample events and confirm outcome field present Bump patch version for attribute additions
Team prefix on wrapper events Search for events without the prefix Document prefix in the schema README
No content fields by default Query backend for oversized attribute values Reject in schema review if found

Cardinality review

Cardinality is the operational cost of an attribute. Every unique value of a metric label creates a new time series, and unbounded identifiers make dashboards expensive and slow.

The safe pattern is to keep identifiers on traces and logs, where they are stored per event, and keep metrics limited to attributes with a small, controlled value set. service.name and deployment.environment work as metric labels. Session and request identifiers do not.

A practical review is to export one hour of metrics and count distinct values per label. Any label whose distinct count approaches the number of events is a label that should be moved off metrics. Teams that skip this review usually discover the problem from a backend bill rather than from a query.

Content boundaries

Raw prompts and tool payloads do not belong in telemetry by default. Three reasons make this a hard boundary rather than a preference.

First, content is unbounded. A single large file read can produce a tool result larger than the rest of the session combined, and attribute size limits vary by backend. Second, content is sensitive. Prompts can contain credentials pasted by mistake, customer data under investigation or proprietary source. Telemetry backends usually have broader read access than the working session. Third, content is rarely needed for operations. The metadata answers which session, which request and which decision; the working transcript remains available through the session record for the cases that need the text.

The Claude Code security documentation treats managed settings and telemetry as administrator controls, which is the right place to enforce a content boundary. An approved exception, reviewed by the platform owner, can add a truncated content field for a specific investigation. That exception should have an owner and an expiry, the same discipline used for security exceptions in general.

Validation queries

A schema is only real if someone checks it. Three queries catch the common failures.

Count events per session identifier. A session with one event is usually a wrapper that failed to propagate the identifier. Count events with a missing request_id. A high proportion means the correlation attributes are not flowing through. Count the largest attribute values in the backend. Outliers here are content fields that should not exist.

bash
  # Example shape only; adapt field names to your backend query language
SELECT session_id, count(*) AS events
FROM agent_events
GROUP BY session_id
ORDER BY events ASC
LIMIT 20

The query above is an example of the check, not a tested query against a specific backend. Run it against your own store with your own field names.

A second useful check compares event counts before and after a schema change. If a rename drops event volume, the old field is still in use somewhere. If it raises volume, the new field is being attached to records that previously had none.

Schema maintenance

Conventions decay without an owner. A short maintenance routine keeps the schema honest.

Step Frequency Owner
Review new attributes against the question list Monthly Platform team
Re-run the cardinality count on metrics Monthly Platform team
Re-check exporter configuration against the schema document Quarterly Platform team
Retire attributes that no question depends on Quarterly Governance owner
Verify correlation attributes still reach the backend After each exporter upgrade Platform team

Tie the schema version to the review. A minor version bump for added attributes, a patch bump for corrected descriptions, and a note in the README for anything a downstream consumer needs to know. This is the same ownership discipline described for runbook maintenance, applied to telemetry instead of procedures.

Exporter configuration review

A schema on paper is not a schema in production. The exporter configuration is where the schema becomes real, and it is the first place to look when fields go missing.

Three checks belong in the review. Confirm the exporter points at the intended backend and that administrative locking is in place where the platform team requires it. Confirm the attribute set enabled on the exporter matches the schema document, so an attribute that was added on paper is actually flowing. Confirm the sampling or redaction behavior, because a sampling rule can silently drop the events that carry correlation fields.

Administrative locking matters for governance as well as for operations. If an individual developer can change the exporter endpoint on a managed device, the organization cannot rely on the telemetry destination. The platform team should own the locked configuration, and a reviewer should verify the lock rather than assume it. This is the same distinction between a product safeguard and a team-owned control that the vendor security review checklist covers.

Sampling deserves a specific callout. A sampling decision that keeps one span in ten will also keep one correlation chain in ten, which makes incident reconstruction harder at exactly the moment it matters. If sampling is required for cost reasons, keep the events that carry prompt.id and request_id on a separate, unsampled path. Correlation fields are small and cheap compared with payload capture, and losing them costs more in investigation time than they save in storage.

The audit evidence integrity checks post covers completeness assessment for evidence more broadly. The exporter review here is the narrow slice that applies to agent telemetry.

Common mistakes and how to catch them

Four mistakes appear often enough to name.

Inventing attribute names and calling them standard comes first. A team that writes claude.agent.session and describes it as an OpenTelemetry convention creates confusion for the next reader, who may search the conventions for a name that does not exist. Mark team-defined attributes clearly in the schema document and reserve the unprefixed names for attributes that come from the conventions.

Adding unbounded identifiers to metric labels comes second. Session and request identifiers feel natural as labels because they are on every event, and the cost only becomes visible when the backend bill arrives. A cardinality review catches this early.

Treating the schema as a transcript mandate comes third. A schema that requires content capture to be useful has been designed backwards. Operations needs metadata; investigation needs the transcript; those are different access paths with different controls.

Assuming the conventions guarantee correlation comes fourth. A naming convention is a shared vocabulary. Whether two records can actually be joined depends on configuration, retention and sampling, which is why log pipeline health checks belong in the same runbook as the schema.

Each of these has a cheap check. The naming mistake is caught by reviewing the schema document against the conventions. The label mistake is caught by the cardinality count. The content mistake is caught by the largest-attribute query. The correlation mistake is caught by running a known session through the pipeline and confirming the join works end to end.

Working with Claude Code on schema work

The agent can help draft and audit the schema. Give it three inputs: the exporter configuration, the current attribute list and the question list from the operations team. Ask for a mapping table that shows which question each attribute answers, and ask it to flag any attribute that answers nothing.

Reviewing that mapping is a human job. The agent can read configuration and produce a table, but deciding which fields may carry content and which may not is a governance decision. The Claude Code verification guide covers the review questions that apply here: what changed, what proves it, and what was not checked.

Workflow from choosing resource attributes, adding session and request correlation fields, naming events, and validating cardinality and content boundaries.
Editorial workflow derived from F073 through F075. The sequence describes a reviewable routine; it is not an official OpenTelemetry rollout process.

Concrete win, concrete loss, practical implication

The concrete win is a searchable session. With resource attributes that name the deployment, a session identifier that ties events together and request_id that ties a request to its prompt, an engineer can answer “which agent work touched this service in the last hour” with one query instead of three systems and a guess.

The concrete loss is that conventions are not enforcement. A schema document does not stop an exporter from sending oversized content attributes, and correlation attributes do not guarantee that the backend retains them long enough to join with cloud audit records. Correlation is a property of the configured pipeline, not of the convention.

The practical implication is sequencing. Define resource attributes and correlation fields first, because those make every later query possible. Add event names next, because those make incidents readable. Leave content fields for approved exceptions, because those are the fields that turn telemetry into a liability.

Tradeoffs worth naming

Approach What it buys What it costs
Metadata-only schema Low cardinality, low sensitivity, cheap queries Some investigations need the transcript anyway
Content-inclusive schema Richer single-system search Larger storage, broader access risk, harder retention
Per-team custom attributes Fast to invent locally Broken joins across teams, duplicated dashboards
Shared schema with a review process Comparable telemetry across teams Slower to add a field, needs an owner

The tradeoff table is derived from the convention design in F073 and the resource model in F074. It is not a measurement of any specific backend.

Tradeoff between a metadata-only agent telemetry schema that is cheap and safe and a content-inclusive schema that is richer but riskier to retain.
Editorial tradeoff diagram based on F073 and F075. Metadata-first schemas keep agent telemetry searchable and cheap; content capture moves the risk to the backend.

Checklist before you publish the schema

Item Expected evidence Failure interpretation
Resource attributes reflect the real deployment model Sample resource matches a known environment Schema copied from another team
Session identifier propagates to every event Session event counts are consistent Wrapper drops the identifier on some paths
prompt.id and request_id present on API events Sample API event shows both fields Correlation attributes not configured
Metric labels have bounded value sets One-hour cardinality count is small High-cardinality label on a metric
No content fields by default Largest attribute values are small Content captured without an approved exception
Event names come from the agreed verb list Exporter config matches the list Ad hoc event names in use
Schema has a version and an owner README names both Unowned schema, likely to decay

Passing the checklist shows the schema was reviewed honestly. It does not prove the pipeline is complete, which is the subject of log pipeline health checks before triage.

Control checklist covering resource attributes, correlation fields, event naming, cardinality limits, content boundaries and schema ownership.
Editorial control checklist derived from F073 through F075. Passing the checklist shows the schema was reviewed; it does not certify the pipeline.

Data gap and future update

No dedicated OpenTelemetry semantic convention for coding agents was found during research. The conventions documents describe general attribute families, and Claude Code documents product-specific fields. A future update should check whether OpenTelemetry publishes an agent-specific convention, and revise the mapping if it does.

The Claude Code monitoring documentation was fetched during research, but exact field behavior can change with product updates. Confirm the current attribute names against the monitoring and usage documentation before finalizing a schema.

No cardinality measurement, ingestion cost or query latency number is reported here, because none was measured on a live backend.

One AI API Key option for OpenAI-format agents

Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The packet records Claude IDs as unavailable on 2026-11-27.

OpenAI-format agents have a separate route: One AI API Key offers https://api.oneaiapikey.com/v1, one key and 46 live free IDs. It is a different client and request format, not a workaround for Claude Code authentication. Check the free model list and eligibility notes before choosing an agent route, or read the quickstart for the request shape. The cost calculator is the fastest way to compare it against a paid route.

FAQ

Do OpenTelemetry semantic conventions cover coding agents specifically?

No dedicated coding-agent convention was found during research. The semantic conventions specification covers general attribute families for services, HTTP, cloud providers and similar domains. Applying those names to Claude Code telemetry is a team mapping, not a published agent standard.

Can I put the session identifier on the resource?

It is technically possible and operationally unwise. A resource attribute is attached to every point the producer emits, so a per-session value multiplies time series by the number of sessions. Keep session identity on spans and log records, where it is stored per event.

Does request_id prove the agent caused a cloud change?

No. The attribute links records. Proving that one caused the other requires the cloud audit record, the change ticket and the decision evidence, which is the workflow described in incident timeline reconstruction.

How do I handle a one-off investigation that needs prompt text?

Treat it as an approved exception. Name the owner, the retention period and the expiry, and prefer a truncated or hashed field over raw text. The same expiry discipline used for security exceptions applies here.

Who owns the schema after the first rollout?

A named owner on the platform team. The maintenance table above gives a monthly and quarterly cadence. An unowned schema decays into a naming free-for-all within a few quarters.

This post is part of a six-post observability and governance lane. Continue with incident timeline reconstruction with request IDs, SLO burn rate alerts during changes, error budget release policy, blameless postmortem evidence, and log pipeline health checks before triage.

Verdict that a metadata-first agent telemetry schema makes sessions searchable while keeping raw content out of the observability backend.
Editorial verdict based on F073 through F075. Standardize the metadata that describes the agent, and keep content fields behind an approved exception.

More Claude Code platform and governance reading

More Claude Code platform and governance reading

The wider batch covers cloud, security and governance boundaries that sit around agent telemetry:

More Claude Code troubleshooting

Sources

More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
Claim $10 credit →