Repository navigation
Description
For the implementing agent:
- Work in this order: spec → attribute registry → runtime → unit tests → interoperability tests → docs.
- Line numbers are at
68df009. If they have moved, search for the quoted code.- Do not edit generated files by hand.
- Do not add runtime dependencies.
- Do not change any behaviour unless the change is listed under phase 1 or phase 2 below.
Reference implementation (evidence only, not for merge). This plan was implemented on
68df009in a fork to
test it: code, 29 files
and evidence
Unit tests 749 → 773 pass, wire test 10/10, conformance
3/3 with zero GenAI violations under the opt-in. A golden test (T-OT-020) shows the default output keeps all 428
pre-change facts: 0 removed, 0 changed. All pass rebased ona245939(evidence §4.2); D5's cache rule is in §4.3. The fork's corrections are folded in here; use it to check your work, not as the patch.
1. Summary
specs/otel-observability-spec.md cites
open-telemetry/semantic-conventions-genai, but both
the spec and the runtime follow an older version of those conventions. As a result, tools built on the current
conventions see no gh-aw agent runs and no token metrics.
Some spec rules now require names that the conventions removed:
- §10.3 makes
gen_ai.systemREQUIRED. - §11.2 requires
gen_ai.client.token.usagewithgen_ai.token.type.
This issue changes the spec first and then the runtime, in two phases:
- Phase 1, additive, on by default. Add the current standard names next to today's names. Nothing that ships
today is removed, renamed or changes meaning, so every existing dashboard and test keeps working. The spec already
allows this (§8.1, §9.5, §9.6, §17). - Phase 2, behind an opt-in. Renames, removals and meaning changes happen only when
OTEL_SEMCONV_STABILITY_OPT_INcontainsgen_ai_latest_experimental. This is the transition flag the OTel
instrumentation libraries use. - Today's names stay supported (D15). This issue does not deprecate them. They stay on by default for at least
three minor releases and six months; deprecating them, then switching the default, are later releases.
Why this matters for gh-aw specifically
- gh-aw is the only GenAI emitter in an agent job. With OTLP configured, the compiler removes the OTLP endpoint
and header variables from the agent sandbox (pkg/workflow/awf_command_builder.go:20-25, applied at:657-663),
so the engine CLI exports nothing.send_otlp_span.cjsandotlp_metrics.cjsare the only GenAI signal for the
agent run; with old names, every run is invisible to convention-based tooling. - The engines already speak the current conventions. The Copilot runtime documents
invoke_agent(INTERNAL),
gen_ai.provider.name(github,anthropic),gen_ai.client.inference.usage.*andgen_ai.invoke_agent.duration
(GitHub Docs: OpenTelemetry reference).
gh-aw propagatesTRACEPARENT(pkg/workflow/safe_outputs_env.go:21-40) andOTEL_RESOURCE_ATTRIBUTES
(pkg/workflow/observability_otlp.go:779-780) to engines, so engine or MCP spans in the trace use the new names and
gh-aw's the old. - This deliberately revisits [otel-advisor] add gen_ai.system attribute to agent span to comply with OTel GenAI semantic conventions #28803 and [otel-advisor] replace non-standard gen_ai.provider.name with gen_ai.system + engine-to-system mapping #29199. Those replaced
gen_ai.provider.namewithgen_ai.system,
citing semconv v1.27. v1.37.0
(August 2025) had already renamedgen_ai.systemtogen_ai.provider.name. This issue keepsgen_ai.system. - Related: OTLP metrics documentation gaps — built-in metrics, logMetric API, batching, security #79081 (metrics docs; overlaps Step 10) and Agent-side AI-credits calculator under-reports AIC for Anthropic (subtracts cache_read from input_tokens) #40205 (cache semantics; D5 reuses the AI-credits rule).
- The shape fits gh-aw. The agent job runs one LLM-driven agent whose control flow comes from tool calls, inside
the runner process that gh-aw instruments. That is exactly the conventions' in-processinvoke_agentcase
(§2.2), and the gh-aw workflow name is a meaningful, low-cardinalitygen_ai.agent.name.
What users get from adopting the conventions
- gh-aw runs appear in standard GenAI tooling. Agent views, token dashboards and alerts built on
invoke_agent,gen_ai.agent.name,gen_ai.provider.nameandgen_ai.client.inference.usage.*pick up gh-aw
runs with no gh-aw-specific queries. - Token counts mean what the conventions say. The new input counter includes cache tokens exactly once, so
usage views count cache-heavy runs correctly (G5, D5). - Failures are machine-readable.
error.typedrives generic error-rate views (spec §10.5 requires it). - CI context is standard.
cicd.*andvcs.*join gh-aw telemetry to CI/CD tools. - Conformance is testable. The SIG's checker turns "follows the conventions" into a CI check (T-OT-018).
Today's default output produces four kinds of GenAI finding; the opt-in output produces none.
2. Reference: the conventions this issue implements
Copied from semantic-conventions-genai e6658f1 and semantic-conventions v1.45.0. All GenAI items are Development.
Since v1.45.0 the core repository marks gen_ai.* as moved to semantic-conventions-genai, whose registry no longer
defines gen_ai.system, gen_ai.token.type, gen_ai.usage.total_tokens,
gen_ai.usage.cache_creation.input_tokens, gen_ai.workflow.name or gen_ai.client.token.usage.
Sources (pinned): agent spans,
agent metrics,
token metrics, registry,
v1.45.0 cicd and
vcs.
2.1 Attributes
| Attribute | Type | Meaning / values | Notes |
|---|---|---|---|
gen_ai.provider.name |
string | The GenAI provider as identified by the client. Well-known values include anthropic, openai, gcp.gen_ai; custom values are allowed. |
Replaces the deprecated gen_ai.system. |
gen_ai.operation.name |
string | chat, invoke_agent, create_agent, execute_tool, embeddings, generate_content, text_completion, … |
|
gen_ai.agent.name |
string | Human-readable agent name. | |
gen_ai.usage.input_tokens |
int | Input tokens. Includes cached tokens (cache read and cache write). | Meaning changed from older versions. |
gen_ai.usage.output_tokens |
int | Output tokens. | |
gen_ai.usage.cache_read.input_tokens |
int | Input tokens served from the provider cache. | |
gen_ai.usage.cache_write.input_tokens |
int | Input tokens written to the provider cache. | Renamed from gen_ai.usage.cache_creation.input_tokens. |
gen_ai.token.modality |
string | text, image, audio, video, unknown. unknown MUST be used when the modality cannot be determined. |
|
error.type |
string | Low-cardinality error class. Conditionally Required when the operation ended in error. |
2.2 Spans
- In-process agent (
gen_ai.invoke_agent.internal): the span name isinvoke_agent {gen_ai.agent.name}, or
invoke_agentwhen there is no name. The kind isINTERNALandgen_ai.operation.name = invoke_agent.
gen_ai.agent.nameis Conditionally Required when available, anderror.typeis Conditionally Required on error. - Remote agent (
gen_ai.client.invoke_agent): the same, except the kind isCLIENTandgen_ai.provider.name
is Required. Not used here (see D3). - Agent-span attributes:
gen_ai.request.modelis Recommended if the agent uses a single model; input tokens
SHOULD include cached tokens; content attributes (gen_ai.input.messagesand similar) are Opt-In.
2.3 Metrics
| Metric | Instrument | Unit | Required attributes | Conditionally required / recommended | Buckets |
|---|---|---|---|---|---|
gen_ai.client.inference.usage. + input_tokens, output_tokens, cache_read.input_tokens, cache_write.input_tokens (4 metrics) |
Counter | {token} |
gen_ai.operation.name, gen_ai.provider.name, gen_ai.token.modality |
gen_ai.request.model (when available), gen_ai.response.model, server.address, server.port |
— |
gen_ai.invoke_agent.duration |
Histogram | s |
gen_ai.operation.name |
error.type (on error), gen_ai.agent.name (when available and low-cardinality), gen_ai.request.model (when one model) |
[0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6, 51.2, 102.4, 204.8, 409.6, 900, 1800, 3600, 7200, 14400, 43200, 86400] |
Token counters: input includes cache read and write; values are provider-reported and MUST be > 0.
gen_ai.client.token.usage and its gen_ai.token.type attribute were removed. gen_ai.client.operation.duration
SHOULD NOT be used for inference or agent operations.
2.4 Shared resource conventions (v1.45.0)
cicd.pipeline.name, cicd.pipeline.run.id, cicd.pipeline.run.url.full, cicd.pipeline.task.name,
vcs.provider.name (github), vcs.repository.url.full, vcs.ref.head.name, vcs.ref.head.revision,
deployment.environment.name (deployment.environment is deprecated). Schema URL:
https://opentelemetry.io/schemas/1.45.0.
3. Current state at 68df009
| # | Priority | Gap | gh-aw today | Where |
|---|---|---|---|---|
| G1 | P1 | No gen_ai.provider.name |
Only gen_ai.system, from ENGINE_TO_SYSTEM_MAP: copilot→github_models, claude→anthropic, codex→openai, gemini→google_vertex_ai |
actions/setup/js/send_otlp_span.cjs:56-61; pushed at :1602-1606 (setup span) and :2487-2491 (conclusion and agent spans) |
| G2 | P1 | Agent run is not invoke_agent |
Dedicated span gh-aw.${jobName}.agent, kind SPAN_KIND_CLIENT, child of the conclusion span; gen_ai.operation.name = "chat" |
send_otlp_span.cjs:2547-2560, :2756-2791 |
| G3 | P1 | No gen_ai.agent.name |
gen_ai.workflow.name (removed from the conventions) |
send_otlp_span.cjs:2551 |
| G4 | P2 | Old cache attribute | gen_ai.usage.cache_creation.input_tokens only |
send_otlp_span.cjs:2740-2742 |
| G5 | P1 | input_tokens meaning varies |
Raw sum; cache included only for some sources | send_otlp_span.cjs:2731-2733 |
| G6 | P1 | Removed token metric | gen_ai.client.token.usage with gen_ai.token.type = input/output/input_cache_read/input_cache_write, plus gh_aw.tokens.* aliases; no operation or provider attribute |
actions/setup/js/otlp_metrics.cjs:435-449 |
| G7 | P2 | No agent duration metric | Only the whole-job gh_aw.job.duration / gh_aw.run.duration |
otlp_metrics.cjs:411-416 |
| G8 | P1 | No error.type on failed agent spans, although spec §10.5 says MUST |
Only exception events with exception.type = gh-aw.AgentFailed/AgentTimedOut/AgentCancelled |
send_otlp_span.cjs:2652-2663; failure flags at :2357-2360 |
| G9 | P3 | No CI/CD or VCS resource attributes; deprecated deployment.environment |
github.* only |
send_otlp_span.cjs:436-495 (buildGitHubActionsResourceAttributes) |
| G10 | P3 | No scope schemaUrl |
scope: { name: "gh-aw", version } |
send_otlp_span.cjs:609, otlp_metrics.cjs:169; the encoder already supports schemaUrl (otlp_protobuf.cjs:247-249, :282-284, :369-371) |
| G11 | P1 | Spec conflicts with the conventions | §10.3 gen_ai.system REQUIRED; §11.2 gen_ai.client.token.usage; §11.5 table; §17 GenAI row; T-OT-009 |
specs/otel-observability-spec.md:592-607, :675-681, :705-723, :1028, :1077 |
| G12 | P2 | Stale agent doc | .github/aw/otel.md says "No OTel metric emitter exists" and that metrics and gen_ai.provider.name are not emitted |
.github/aw/otel.md:102, :112, :115, :121, :125 |
| G13 | P2 | Successful spans set status OK |
buildOTLPSpan defaults status.code to 1 (OK); the conclusion span sets 1 on success. Spec §9.3, §10.5 and the Trace API say instrumentation SHOULD leave it UNSET |
send_otlp_span.cjs:352, :2362; otlp.cjs:148; specs/otel-observability-spec.md:507, :631 |
| G14 | P2 | No conformance test | Tests check gh-aw against itself (otel_contract.test.cjs:184-192 asserts gen_ai.system); the wire test checks encoding only, so G1–G13 went unnoticed |
actions/setup/js/otel_contract.test.cjs, actions/setup/js/scripts/test_otlp_protobuf.mjs |
Priority: P1 means generic GenAI tooling cannot see or count gh-aw agent runs, or the spec contradicts the
conventions or itself. P2 means a renamed or missing signal that has a usable workaround. P3 means shared
CI/CD conventions that improve correlation but are not GenAI-specific.
Evidence for G5:
- The AWF api-proxy marks each usage record with
input_tokens_include_cache(truefor OpenAI-style
prompt_tokens). The AI-credits spec prices cache with that flag, then a provider default
(model_costs.cjs:97-108,:196-212), butagent_usage.jsonsums rawinput_tokens, so its meaning varies. - Where input excludes cache, cache dominates:
actions/setup/js/fixtures/agy_ci_sessions.cjs:61has
input_tokens: 79491,cache_read_tokens: 298918; a convention-following consumer reports 79,491, not 378,409. - Where input already includes cache reads, always adding them double-counts (evidence §4.3).
4. Decisions (maintainers: confirm or override before implementing)
| ID | Decision | Reason |
|---|---|---|
| D1 | Two phases: additive changes on by default; breaking changes only with OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental. |
Spec §9.5, §9.6 and §17 forbid removing or renaming shipped names. T-OT-011 forbids changing built-in span names. |
| D2 | gen_ai.provider.name values: copilot→github, claude→anthropic, codex→openai, gemini→gcp.gen_ai. Any other engine ID is used as-is, just as gen_ai.system does today. |
The Copilot runtime's own spans use github, so gh-aw and engine spans agree. gcp.gen_ai is the conventions' value when the Google backend is unknown. |
| D3 | The agent span is the in-process form with operation invoke_agent (not invoke_workflow): kind INTERNAL, plus the gen_ai.invoke_agent.duration metric. |
In-process, LLM-driven (§2.2); spec §9.5 already says SHOULD be INTERNAL, as the Copilot runtime does. The remote form's buckets stop at 81.92 s. |
| D4 | gen_ai.agent.name = the workflow name, which is the same value as workflowName (now sent as gen_ai.workflow.name). |
Low cardinality; the direct replacement for the removed attribute. |
| D5 | Inclusive input counts cache once: normalize each usage record with the AI-credits rule (input_tokens_include_cache, else the provider default), sum into agent_usage.json input_tokens_inclusive, omit when unknown. The new counter uses it from phase 1; span gen_ai.usage.input_tokens only in phase 2. |
The counter is new; the span attribute is shipped. One rule for cost and tokens. |
| D6 | gen_ai.token.modality = "unknown". |
gh-aw only has per-run totals, and the conventions require unknown in that case. |
| D7 | error.type values: timeout (agent conclusion timed_out), cancelled (cancelled), agent_failed (failure). |
Low cardinality; one-to-one with the existing gh-aw.Agent* exception types. |
| D8 | The opt-in is read only from process.env.OTEL_SEMCONV_STABILITY_OPT_IN in the conclusion step. The compiler is not changed. Users set it through the workflow frontmatter env:. Verified: frontmatter env: reaches every job's conclusion step. |
Keeps this change JavaScript-only, with no golden-file churn. |
| D9 | gen_ai.conversation.id, gen_ai.agent.id, gen_ai.agent.version and gen_ai.agent.description are not emitted. |
No real conversation ID (run IDs must not be used); the others are not available in the conclusion step without a compiler change. |
| D10 | gen_ai.invoke_agent.inference_calls and gen_ai.invoke_agent.tool_calls are not emitted. |
gh-aw's counts do not match: gh-aw.turns is not set for every engine (send_otlp_span.cjs:2154-2155), and gh_aw.tool_calls counts only MCP-gateway calls (otlp_metrics.cjs:453-461). |
| D11 | gh-aw stays the single emitter of standard GenAI token counters for the agent job. If engine OTLP export is ever enabled inside the sandbox, gh-aw MUST NOT also emit gen_ai.client.inference.usage.* for that run. Record this in the §11.2 text. |
Two emitters of the same counter double-count. Today the engine cannot export, because of the sandbox exclusion described in §1. |
| D12 | With the opt-in, built-in spans leave status UNSET (code: 0) on success. ERROR handling is unchanged. Without the opt-in nothing changes. |
Spec §9.3/§10.5, the Trace API and the conformance policy span_status_ok_set_by_instrumentation. Opt-in because queries may filter on OK. |
| D13 | Interoperability tests use the GenAI SIG's semantic-conventions-conformance runner with Weaver live-check, installed only in CI in an isolated directory like the reference-SDK job. Pins: Weaver v0.28.0, conformance a432190, registry semantic-conventions-genai@e6658f1. No dependency changes. |
The SIG's own harness. Its default registry pin (9ffc7e0) still has gen_ai.workflow.name, so override it to the §18.1 commit. |
| D14 | The opt-in changes only gen_ai.* names, the agent span's name, kind and parent (D3), and span status (D12). Every gh-aw.* attribute and gh_aw.* metric keep their names, values and spans in both modes; only the gh_aw.tokens.* aliases drop gen_ai.token.type with the opt-in (Step 7.3). |
gh-aw's own names, which the conventions allow; spec §9.6/§17 forbid removing shipped names. |
| D15 | Staged retirement of today's gen_ai.* names: (1) this issue: fully supported, on by default, not deprecated; (2) after at least three minor releases and six months, a later release marks them deprecated in the spec and release notes; (3) only a release after that may switch the default and stop emitting them. Maintainers may lengthen stages. |
Users need time to migrate queries. OTel's HTTP migration keeps old conventions as default for six months or more. gh-aw is pre-1.0, so a release count stands in. |
5. Implementation plan
Do the steps in order and keep everything in one pull request.
Step 1: Change the spec (specs/otel-observability-spec.md)
Make each change below exactly as written. Text in "Replace" must match the file. Add entries to the change log under
## 19. Change Log → ### Unreleased, and set last_updated in the front matter to the day you implement this.
Leave version to the maintainers.
1a. §6, new subsection ### 6.7 Semantic Convention Stability Opt-in. Insert it after §6.6 (before ## 7.). The table of contents lists only top-level sections:
### 6.7 Semantic Convention Stability Opt-in
`OTEL_SEMCONV_STABILITY_OPT_IN` is a comma-separated list. Entries MUST be compared after trimming whitespace.
When the list contains `gen_ai_latest_experimental`, the runtime MUST emit the current GenAI names and meanings
defined in §9.5, §10.3 and §11.2, and MUST NOT emit the names those sections mark "compatibility only". This mode
follows OpenTelemetry semantic-conventions-genai, which has no stable release; its output can change when those
conventions change.
When the list does not contain `gen_ai_latest_experimental`, the runtime MUST emit both the compatibility names and
the additive standard names. Attributes and metrics marked "additive" MUST be emitted in both modes.
The opt-in MUST NOT remove, rename or change the value of any gh-aw-defined `gh-aw.*` attribute or `gh_aw.*`
metric.
Other values in the list MUST be ignored by gh-aw.
Compatibility-only names remain supported and are not deprecated by this version. They MUST stay emitted by default
for at least three minor releases and six months after the release that adds this section. Only after that may a
later spec version deprecate them; making the opt-in behaviour the default, which stops them, is a breaking change
in a release after the deprecation and after semantic-conventions-genai publishes a release.
Without `gen_ai_latest_experimental`, the default export MUST be a superset of the export before this section was
added: every span (name, kind, parent, status), attribute, resource attribute, metric and data point keeps its value;
only clock-dependent values may differ (T-OT-020).1b. §8.1. Replace
Additive standard aliases MAY include `cicd.pipeline.name`, `cicd.pipeline.run.id`, `cicd.pipeline.run.url.full`, `vcs.repository.url.full`, and `deployment.environment.name`.with
The following standard resource attributes are additive and RECOMMENDED. They MUST NOT replace a value already
supplied through `OTEL_RESOURCE_ATTRIBUTES`. §8.3 still removes them from metrics.
| Attribute | Value |
|---|---|
| `cicd.pipeline.name` | GitHub Actions workflow name (`GITHUB_WORKFLOW`). |
| `cicd.pipeline.run.id` | Same value as `github.run_id`. |
| `cicd.pipeline.run.url.full` | Same value as the run URL attribute. |
| `cicd.pipeline.task.name` | Same value as `github.job`. |
| `vcs.provider.name` | `github`. |
| `vcs.repository.url.full` | `${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}`. |
| `vcs.ref.head.name` | Same value as `github.ref_name`. |
| `vcs.ref.head.revision` | Same value as `github.sha`. |
| `deployment.environment.name` | Same value as `deployment.environment`. Without the §6.7 opt-in both are emitted; with it only `deployment.environment.name` is emitted. |1c. §8.4. Append
With the §6.7 opt-in, the core runtime SHOULD set the instrumentation scope `schemaUrl` to
`https://opentelemetry.io/schemas/1.45.0` on trace and metric payloads.1d. §9.5. Replace the paragraph that begins "Existing gh-aw built-in agent spans MAY continue to use
gen_ai.operation.name = "chat"" with
The built-in agent span (`hasDedicatedAgentSpan`) MUST set `gen_ai.agent.name` to the workflow name and
`gen_ai.provider.name` (§10.3), and MUST set `error.type` (§10.3) when the agent failed, timed out or was cancelled.
Without the §6.7 opt-in, the built-in agent span keeps its shipped shape for compatibility: name `gh-aw.<job>.agent`,
kind `CLIENT`, parent the job conclusion span, and `gen_ai.operation.name = "chat"`.
With the §6.7 opt-in, the built-in agent span MUST be named `invoke_agent <gen_ai.agent.name>` (or `invoke_agent`
when no name is known), MUST use kind `INTERNAL` and `gen_ai.operation.name = "invoke_agent"`, and MUST have the
same parent as the job conclusion span. The job conclusion span MUST NOT then carry `gen_ai.operation.name`,
`gen_ai.response.finish_reasons` or token usage. When no dedicated agent span is emitted, the agent job conclusion
span carries those attributes and uses `gen_ai.operation.name = "invoke_agent"`.1e. §9.6. Replace
For compatibility, built-in gh-aw spans MAY continue to emit `gen_ai.system` and `gen_ai.usage.total_tokens`. New standard aliases such as `gen_ai.provider.name` MAY be emitted in addition to, not instead of, the compatibility attributes.with
Built-in gh-aw spans that carry `gen_ai.system` MUST also carry `gen_ai.provider.name`. `gen_ai.system` and
`gen_ai.usage.total_tokens` are compatibility only: they MUST be emitted without the §6.7 opt-in and MUST NOT be
emitted with it.1f. §10.3. Replace the whole table with
| Attribute | Type | Requirement |
|---|---|---|
| `gen_ai.operation.name` | string | REQUIRED. |
| `gen_ai.provider.name` | string | REQUIRED when the engine is known. Values: `copilot` → `github`, `claude` → `anthropic`, `codex` → `openai`, `gemini` → `gcp.gen_ai`; any other engine ID is used unchanged. |
| `gen_ai.system` | string | Compatibility only (§6.7). Without the opt-in, REQUIRED on built-in agent spans when the engine mapping is known. Deprecated by OpenTelemetry. |
| `gen_ai.agent.name` | string | REQUIRED on the built-in agent span (§9.5); the workflow name. |
| `gen_ai.request.model` | string | CONDITIONALLY REQUIRED when available. |
| `gen_ai.response.model` | string | RECOMMENDED when returned. |
| `gen_ai.response.finish_reasons` | string[] | RECOMMENDED when returned. |
| `gen_ai.usage.input_tokens` | int | RECOMMENDED when returned. Without the opt-in, the raw sum the source reports (shipped meaning). With the opt-in it MUST include cache-read and cache-write tokens once (§11.2), and MUST be omitted when that is unknown. |
| `gen_ai.usage.output_tokens` | int | RECOMMENDED when returned. |
| `gen_ai.usage.cache_read.input_tokens` | int | RECOMMENDED when applicable. |
| `gen_ai.usage.cache_write.input_tokens` | int | RECOMMENDED when applicable. Additive. |
| `gen_ai.usage.cache_creation.input_tokens` | int | Compatibility only (§6.7); same value as `gen_ai.usage.cache_write.input_tokens`. |
| `gen_ai.usage.total_tokens` | int | Compatibility only (§6.7); input plus output, excluding cache. |
| `gen_ai.usage.reasoning.output_tokens` | int | RECOMMENDED when applicable. |
| `gen_ai.workflow.name` | string | Compatibility only (§6.7); replaced by `gen_ai.agent.name`. |
| `error.type` | string | CONDITIONALLY REQUIRED on the agent span and agent conclusion span when the agent did not succeed: `timeout`, `cancelled` or `agent_failed`. |1g. §11.2. Replace the two sentences that start "A Level 3 implementation SHOULD emit
gen_ai.client.operation.duration" and "A Level 3 implementation SHOULD emit gen_ai.client.token.usage" with
A Level 3 implementation SHOULD emit `gen_ai.client.operation.duration` only for instrumented model-client
operations other than inference and agent invocation, as the GenAI conventions require.
A Level 3 implementation SHOULD emit the delta counters `gen_ai.client.inference.usage.input_tokens`,
`gen_ai.client.inference.usage.output_tokens`, `gen_ai.client.inference.usage.cache_read.input_tokens` and
`gen_ai.client.inference.usage.cache_write.input_tokens` (unit `{token}`) when the corresponding counts are
available. Each data point MUST carry `gen_ai.operation.name = "chat"`, `gen_ai.provider.name` and
`gen_ai.token.modality` (`unknown` when the modality cannot be determined), and SHOULD carry `gen_ai.request.model`
when known. The input counter MUST include cache-read and cache-write tokens exactly once, using each usage
record's `input_tokens_include_cache` or else the AI-credits provider default; when unknown it MUST be omitted. A zero or unavailable value MUST NOT be
recorded.
A Level 3 implementation SHOULD emit `gen_ai.invoke_agent.duration` (histogram, unit `s`) for each built-in agent
span, with explicit bucket boundaries `[0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6, 51.2, 102.4, 204.8, 409.6,
900, 1800, 3600, 7200, 14400, 43200, 86400]`. Each data point MUST carry `gen_ai.operation.name = "invoke_agent"`
and SHOULD carry `gen_ai.agent.name`, `gen_ai.request.model` when known, and `error.type` when the agent did not
succeed.
`gen_ai.client.token.usage` with `gen_ai.token.type` is compatibility only (§6.7). It has been removed from the
OpenTelemetry GenAI conventions.
If an engine exports its own `gen_ai.client.inference.usage.*` for the agent job, the runtime MUST NOT also emit
them for that run (D11).1h. §11.5. In the table:
- Change the first cell of the
gen_ai.client.token.usagerow to`gen_ai.client.token.usage` (compatibility only, §6.7; the `gh_aw.tokens.*` aliases are kept in both modes and omit `gen_ai.token.type` with the opt-in). - Insert these rows after it:
| `gen_ai.client.inference.usage.input_tokens` | Counter | `{token}` | `gen_ai.operation.name`, `gen_ai.provider.name`, `gen_ai.token.modality`, `gen_ai.request.model` when available, `gh-aw.job.name`, `gh-aw.workflow.name` | Input tokens **including** cache read and write, once (`agent_usage.json` `input_tokens_inclusive`). Additive. |
| `gen_ai.client.inference.usage.output_tokens` | Counter | `{token}` | same as above | Output tokens. Additive. |
| `gen_ai.client.inference.usage.cache_read.input_tokens` | Counter | `{token}` | same as above | Cache-read input tokens. Additive. |
| `gen_ai.client.inference.usage.cache_write.input_tokens` | Counter | `{token}` | same as above | Cache-write input tokens. Additive. |
| `gen_ai.invoke_agent.duration` | Histogram | `s` | `gen_ai.operation.name`, `gen_ai.agent.name`, `gen_ai.request.model` when available, `error.type` on failure, `gh-aw.job.name`, `gh-aw.workflow.name` | Duration of the built-in agent span; §11.2 buckets. Additive. |Then replace "The token metric uses the existing gen_ai.client.token.usage name, and safe-output items use the
existing gh_aw.workflow.output.items name." with "The gen_ai.client.inference.usage.* counters are the standard
token metrics; gen_ai.client.token.usage is kept without the §6.7 opt-in for deployed dashboards. Dashboards MUST
NOT sum the two, because gen_ai.client.inference.usage.input_tokens includes cache tokens and
gen_ai.client.token.usage{gen_ai.token.type=input} does not. Safe-output items use the existing
gh_aw.workflow.output.items name."
1i. §17.1. Replace the GenAI compatibility row with
| GenAI compatibility | Without the §6.7 opt-in, built-in gh-aw spans continue to emit `gen_ai.system`, `gen_ai.usage.total_tokens`, `gen_ai.usage.cache_creation.input_tokens` and `gen_ai.workflow.name`, and the built-in agent span keeps its shipped name, kind and parent. They also emit the additive standard names. |
| GenAI opt-in | With `OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental`, compatibility-only names are absent and the agent span follows §9.5. |1j. §17.1.2.
- Change T-OT-009 to: "§10.3
gen_ai.provider.name(and, without the opt-in,gen_ai.system) on built-in agent
spans | A known engine emits the §10.3 provider value | … assertgen_ai.provider.nameequals the mapped value
and, without the opt-in,gen_ai.systemis also present". - Add to the T-OT-011 expected value: "This test applies to exports without the §6.7 opt-in."
- Add these rows:
| **T-OT-014** | §9.5 agent identity | The built-in agent span has `gen_ai.agent.name` = workflow name and, on failure, `error.type` ∈ {`timeout`,`cancelled`,`agent_failed`} | `send_otlp_span.test.cjs` |
| **T-OT-015** | §11.2 standard GenAI metrics | `gen_ai.client.inference.usage.*` carry the required attributes, input includes cache tokens, zero values are not recorded, and `gen_ai.invoke_agent.duration` uses the §11.2 buckets | `otlp_metrics.test.cjs` |
| **T-OT-016** | §6.7 opt-in | With `gen_ai_latest_experimental`, the agent span is `invoke_agent <name>`, `INTERNAL`, a sibling of the conclusion span; compatibility-only names and metrics are absent; scope `schemaUrl` is set | `send_otlp_span.test.cjs`, `otlp_metrics.test.cjs` |
| **T-OT-017** | §8.1 standard resource attributes | `cicd.*`, `vcs.*` and `deployment.environment.name` are present and do not override `OTEL_RESOURCE_ATTRIBUTES`; §8.3 drops them from metrics | `send_otlp_span.test.cjs`, `otlp_metrics.test.cjs` |
| **T-OT-018** | §6.7, §9.5, §10.5, §11.2 conformance | Built-in telemetry exported over OTLP to Weaver live-check with semantic-conventions-genai at the §18.1 commit has no undeclared violations with the opt-in; without it, every finding is declared with a reason | `actions/setup/js/conformance/` (CI) |
| **T-OT-019** | §11.2 wire format | Opt-in GenAI spans and metrics (kind, scope `schemaUrl`, monotonic sums, 20-bound histogram) encode byte-for-byte like the reference SDK protocol types | `scripts/test_otlp_protobuf.mjs` |
| **T-OT-020** | §6.7 backward compatibility | Without `gen_ai_latest_experimental` (unset or another value), a success and a failure agent job export every fact of a golden export captured before §6.7; with it, every `gh-aw.*` and `github.*` attribute is kept | `send_otlp_span_legacy_contract.test.cjs` |1k. §18.1. Add:
**[GenAI Agent Metrics]** OpenTelemetry GenAI SIG. *Semantic conventions for GenAI metrics: agent metrics*. https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-metrics.md#generative-ai-agent-metrics**[GenAI Token Metrics]** … https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-token-metrics.md
Below the GenAI references, add: "This version follows semantic-conventions-genai at commit e6658f1 (2026-11-06),
which has no release tag, and semantic-conventions v1.45.0."
1l. §19 Unreleased. Add:
- Added: the §6.7 opt-in; the §8.1 standard resource attributes;
gen_ai.provider.name,gen_ai.agent.name,
gen_ai.usage.cache_write.input_tokensanderror.typeon built-in spans; thegen_ai.client.inference.usage.*
andgen_ai.invoke_agent.durationmetrics. - Changed:
gen_ai.system,gen_ai.usage.total_tokens,gen_ai.usage.cache_creation.input_tokens,
gen_ai.workflow.nameandgen_ai.client.token.usageare compatibility names, still supported and on by default
(not deprecated, §6.7); with the opt-in, the agent span
isinvoke_agent(INTERNAL) andgen_ai.usage.input_tokensincludes cache tokens.
Step 2: Register the attribute names (specs/otel/attributes.tsp)
Add entries in the same style as genAiSystem: "gen_ai.system"; (around :68-81), next to related entries (the file is not alphabetical):
cicdPipelineName: "cicd.pipeline.name";
cicdPipelineRunId: "cicd.pipeline.run.id";
cicdPipelineRunUrlFull: "cicd.pipeline.run.url.full";
cicdPipelineTaskName: "cicd.pipeline.task.name";
deploymentEnvironmentName: "deployment.environment.name";
errorType: "error.type";
genAiAgentName: "gen_ai.agent.name";
genAiProviderName: "gen_ai.provider.name";
genAiTokenModality: "gen_ai.token.modality";
genAiUsageCacheWriteInputTokens: "gen_ai.usage.cache_write.input_tokens";
vcsProviderName: "vcs.provider.name";
vcsRefHeadName: "vcs.ref.head.name";
vcsRefHeadRevision: "vcs.ref.head.revision";
vcsRepositoryUrlFull: "vcs.repository.url.full";
Skip any that already exist; cicd.pipeline.task.run.result is already used in metrics, so check first. Then run
make generate-otel-attributes. This regenerates actions/setup/js/otel_attributes_generated.cjs and
pkg/workflow/otel_attributes_generated.go, which must never be edited by hand. Then run
make check-otel-attributes. Use the generated OTEL_ATTR_* constants in the code below where the file already does
so for neighbouring attributes, for example OTEL_ATTR_ENGINE_ID at send_otlp_span.cjs:23.
Step 3: Add the opt-in helper and provider map (actions/setup/js/send_otlp_span.cjs)
-
After
ENGINE_TO_SYSTEM_MAP(:56-61), add:/** @type {Record<string, string>} gen_ai.provider.name per engine. */ const ENGINE_TO_PROVIDER_MAP = Object.assign(Object.create(null), { copilot: "github", claude: "anthropic", codex: "openai", gemini: "gcp.gen_ai", }); /** @param {string} engineId */ function resolveGenAiProvider(engineId) { return ENGINE_TO_PROVIDER_MAP[engineId] || engineId; } /** True when OTEL_SEMCONV_STABILITY_OPT_IN contains gen_ai_latest_experimental (spec §6.7). */ function isGenAiLatestExperimental() { return (process.env.OTEL_SEMCONV_STABILITY_OPT_IN || "") .split(",") .map(s => s.trim()) .includes("gen_ai_latest_experimental"); } const GEN_AI_SCHEMA_URL = "https://opentelemetry.io/schemas/1.45.0";
-
Export
resolveGenAiProvider,isGenAiLatestExperimentalandGEN_AI_SCHEMA_URLfrommodule.exports
(around:2900), becauseotlp_metrics.cjsalreadyrequires this module lazily.
Step 4: Phase 1 span attributes (send_otlp_span.cjs)
-
Provider on the setup span (
:1602-1606) and the conclusion span (:2487-2491). Replaceconst genAiSystem = ENGINE_TO_SYSTEM_MAP[engineId] || engineId; attributes.push(buildAttr("gen_ai.system", genAiSystem));
with
if (!isGenAiLatestExperimental()) { attributes.push(buildAttr("gen_ai.system", ENGINE_TO_SYSTEM_MAP[engineId] || engineId)); } attributes.push(buildAttr("gen_ai.provider.name", resolveGenAiProvider(engineId)));
Keep the
OTEL_ATTR_ENGINE_IDpush unchanged. -
Agent attributes (
:2547-2560). Split the block so the agent-specific GenAI attributes are collected in a new
array instead of the sharedattributes:const optIn = isGenAiLatestExperimental(); /** GenAI attributes that describe the agent invocation (spec §9.5). */ const agentGenAiAttrs = []; let agentErrorType = ""; if (jobName === "agent") { agentGenAiAttrs.push(buildAttr("gen_ai.operation.name", optIn ? "invoke_agent" : "chat")); if (workflowName) { agentGenAiAttrs.push(buildAttr("gen_ai.agent.name", workflowName)); if (!optIn) agentGenAiAttrs.push(buildAttr("gen_ai.workflow.name", workflowName)); } if (runtimeMetrics.resolvedModel) agentGenAiAttrs.push(buildAttr("gen_ai.response.model", runtimeMetrics.resolvedModel)); const effectiveStopReason = runtimeMetrics.stopReason || (isAgentTimedOut ? "timeout" : "unknown"); agentGenAiAttrs.push(buildArrayAttr("gen_ai.response.finish_reasons", [effectiveStopReason])); agentErrorType = isAgentTimedOut ? "timeout" : isAgentCancelled ? "cancelled" : isAgentFailure ? "agent_failed" : ""; if (agentErrorType) agentGenAiAttrs.push(buildAttr("error.type", agentErrorType)); }
Keep the existing comments. Placement, once
hasDedicatedAgentSpan(:2757) is known (compute it earlier from
jobName,agentStartMs,agentEndMsat:2693-2714, or add the array when building payloads):- Without the opt-in (shipped): push
...agentGenAiAttrsontoattributes, so they stay on both the
conclusion and agent spans. The agent span's attributes must stay a superset of today's. - With the opt-in: with a dedicated agent span, put them only on the agent span (the conclusion span gets
onlyerror.typewhen set); otherwise push them ontoattributes.
- Without the opt-in (shipped): push
-
Usage attributes (
:2731-2753):- Next to
gen_ai.usage.cache_creation.input_tokens, also push
buildAttr("gen_ai.usage.cache_write.input_tokens", agentUsage.cache_write_tokens). Pushcache_creation
only without the opt-in. - With the opt-in, set
gen_ai.usage.input_tokenstoresolveInclusiveInputTokens(agentUsage)(Step 7.7), and
omit it when that isundefined. Without the opt-in, keep the raw value. - Emit
gen_ai.usage.total_tokensonly without the opt-in, and keep its current definition. - Update the comment at
:2743-2747to say thattotal_tokensis a gh-aw compatibility attribute that is not
part of the OpenTelemetry conventions.
- Next to
-
Redaction. The sensitive-key filter (
SENSITIVE_ATTR_KEY_RE) matchesgen_ai.token.modalitybecause the
key containstoken. Let the valuestext,image,audio,videoandunknownthrough for that key only.
Step 5: Phase 2 agent span shape (send_otlp_span.cjs:2756-2791)
With the opt-in only:
const agentPayload = buildOTLPPayload({
traceId,
spanId: generateSpanId(),
...(optIn ? (parentSpanId ? { parentSpanId } : {}) : { parentSpanId: conclusionSpanId }),
spanName: optIn ? (workflowName ? `invoke_agent ${workflowName}` : "invoke_agent") : jobName ? `gh-aw.${jobName}.agent` : "gh-aw.job.agent",
// ...unchanged fields...
kind: optIn ? SPAN_KIND_INTERNAL : SPAN_KIND_CLIENT,
});parentSpanIdis the conclusion span's own parent (:2302, used at:2822).- Without the opt-in, the object must be byte-for-byte the same as today's.
buildOTLPPayloadmust pass the scopeschemaUrl(Step 6) when the opt-in is set.- Status (D12): with the opt-in,
buildOTLPSpandefaultscodeto 0 instead of 1 (:352), the conclusion span uses 0
on success (:2362), andotlp.cjs:148usesisError ? 2 : 0. Explicitly passed codes are unchanged.
Step 6: Resource attributes and schemaUrl
-
In
buildGitHubActionsResourceAttributes(:425-496), add a local helper afterupsertResourceAttr:const addResourceAttrIfAbsent = attr => { if (!resourceAttributes.some(existing => existing.key === attr.key)) resourceAttributes.push(attr); };
Use it just before
returnto add the §8.1 attributes from the existing locals (runId,runUrlAttr,job,
repository,refName,shaand thedeployment.environmentvalue;vcs.repository.url.fulluses
GITHUB_SERVER_URL, defaulthttps://github.com). Forcicd.pipeline.name, add an optionalworkflowName
option: passworkflowNameatsend_otlp_span.cjs:1639and:2628, andprocess.env.GITHUB_WORKFLOW || ""at
otlp.cjs:115andcheck_admission.cjs:260.Only
deployment.environment(:494) changes: with the opt-in, do not emit it.OTEL_RESOURCE_ATTRIBUTESvalues must win, henceaddResourceAttrIfAbsent, notupsertResourceAttr. -
Leave
METRIC_RESOURCE_ATTRIBUTE_KEYS(otlp_metrics.cjs:21) unchanged, so none of these reach metrics (spec
§8.3). Add a test for that. -
schemaUrl: with the opt-in, addschemaUrl: GEN_AI_SCHEMA_URLas a sibling ofscopeon the
scopeSpans[0]entry inbuildOTLPBatchPayload(send_otlp_span.cjs:608-611) and on thescopeMetrics[0]
entry inbuildOTLPMetricsPayload(otlp_metrics.cjs:169). In OTLP,schemaUrlis a field of
ScopeSpans/ScopeMetrics, not ofInstrumentationScope.- The protobuf encoder already supports it (
otlp_protobuf.cjs:247). - Without the opt-in, payloads must not change.
- The protobuf encoder already supports it (
Step 7: Metrics (actions/setup/js/otlp_metrics.cjs)
-
Add a constant next to
DEFAULT_HISTOGRAM_BUCKETS(:8):const GEN_AI_INVOKE_AGENT_DURATION_BUCKETS = [0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6, 51.2, 102.4, 204.8, 409.6, 900, 1800, 3600, 7200, 14400, 43200, 86400];
-
Add these optional parameters to
buildBuiltinRunMetrics(:380) and its JSDoc (:355-379):
provider = "",inclusiveInputTokens,agentName = "",agentDurationSeconds,agentErrorType = "",semconvLatest = false. -
In the token loop (
:435-449), withsemconvLatestskipgen_ai.client.token.usagebut still emit the
gh_aw.tokens.*alias with the same value, minusgen_ai.token.type(the name carries the type; D14).
Without it, nothing changes. -
Right after that loop, still inside
if (emitsTokenUsage), add:if (provider) { const num = v => (typeof v === "number" && Number.isFinite(v) ? v : undefined); const inclusiveInput = num(inclusiveInputTokens); // D5, resolved by the caller const usageAttributes = attributes( buildAttr("gen_ai.operation.name", "chat"), buildAttr("gen_ai.provider.name", bounded(provider)), buildAttr("gen_ai.token.modality", "unknown"), ...(model ? [buildAttr("gen_ai.request.model", bounded(model))] : []) ); for (const [name, value] of [ ["gen_ai.client.inference.usage.input_tokens", inclusiveInput], ["gen_ai.client.inference.usage.output_tokens", num(outputTokens)], ["gen_ai.client.inference.usage.cache_read.input_tokens", num(cacheReadTokens)], ["gen_ai.client.inference.usage.cache_write.input_tokens", num(cacheWriteTokens)], ]) { if (typeof value === "number" && value > 0) { metrics.push(buildOTLPMetric({ name, type: "counter", unit: "{token}", value, attributes: usageAttributes, startMs, endMs, traceContext })); } } }
-
After the token block, when
agentDurationSecondsis a finite number ≥ 0, pushgen_ai.invoke_agent.duration
withbuildOTLPMetric(:59, already acceptsbuckets):histogram, units,
GEN_AI_INVOKE_AGENT_DURATION_BUCKETS, attributesgen_ai.operation.name=invoke_agentplus bounded
gen_ai.agent.name,gen_ai.request.modelanderror.typewhen set. -
In
sendJobConclusionSpan, wherebuildBuiltinRunMetricsis called (send_otlp_span.cjs:2862-2884), pass:provider: engineId ? resolveGenAiProvider(engineId) : "", inclusiveInputTokens: resolveInclusiveInputTokens(agentUsage), agentName: jobName === "agent" ? workflowName : "", agentDurationSeconds: hasDedicatedAgentSpan ? (agentEndMs - agentStartMs) / 1000 : undefined, agentErrorType, semconvLatest: isGenAiLatestExperimental(),
hasDedicatedAgentSpan,agentStartMs,agentEndMsandagentErrorTypeare in scope there (:2693-2757). -
Inclusive input (D5).
model_costs.cjs: exportcomputeInclusiveInputTokens, thecomputeInferenceCostUSDrule: flagtrue→
input;false→ input + read + write; no flag andproviderIncludesCacheReadsInInput→ input + write; else
input + read + write.parseTokenUsageJsonlsums it per record;parse_token_usage.cjs:643writesinput_tokens_inclusivewhen
input_tokensand both cache counts are numbers.send_otlp_span.cjs:normalizeRuntimeTokenUsagepasses throughinput_tokens_inclusiveand
input_tokens_include_cache.resolveInclusiveInputTokens(usage)returns that key; elseinput_tokenswhen the
flag istrueor there is no cache; else input + cache when the flag isfalse; elseundefined.
Step 8: Tests
Follow the test at send_otlp_span.test.cjs:2921 (fetch stub, fs spies). Reset process.env.OTEL_SEMCONV_STABILITY_OPT_IN in afterEach.
actions/setup/js/send_otlp_span.test.cjs:
- Provider map.
it.eachover copilot→github/github_models, claude→anthropic/anthropic, codex→openai/openai,
gemini→gcp.gen_ai/google_vertex_ai, custom-engine→custom-engine/custom-engine.- The agent span and the setup span carry both
gen_ai.provider.name(column 2) andgen_ai.system(column 3). - Extend the cases near
:1505,:2170,:2223; the:2135no-engine case asserts no provider.
- Agent identity. With
GH_AW_INFO_WORKFLOW_NAME = "CI"(send_otlp_span.cjs:2304), the agent span has
gen_ai.agent.name=CI, still hasgen_ai.workflow.name, andgen_ai.operation.name=chat. error.type. Per D7 on the agent and conclusion spans; absent onsuccess.- Cache attributes. With
cache_write_tokens: 7, bothgen_ai.usage.cache_write.input_tokensand
gen_ai.usage.cache_creation.input_tokensequal 7. - Resource. The Step 6
cicd.*,vcs.*anddeployment.environment.namevalues are present
(vcs.provider.name=github);OTEL_RESOURCE_ATTRIBUTES=cicd.pipeline.name=customstayscustom;
deployment.environmentis still present. - Opt-in, set to
gen_ai_latest_experimental. Also run the main case with"http, gen_ai_latest_experimental"
to check splitting and trimming.- The agent span's name is
invoke_agent <workflow>,kindisSPAN_KIND_INTERNAL, andparentSpanIdequals
the conclusion span'sparentSpanId("abcdef1234567890"in the:2921setup). It is not the conclusion
span'sspanId. - The agent span has
gen_ai.operation.name = invoke_agent. - The conclusion span has no
gen_ai.operation.name,gen_ai.response.finish_reasonsorgen_ai.usage.*. gen_ai.usage.input_tokens=input_tokens_inclusiveif set; 10 with flagtrue; 17 withfalse; absent
with cache tokens and no flag (input 10, cache read 5, write 2).- None of these are present anywhere:
gen_ai.system,gen_ai.usage.total_tokens,
gen_ai.usage.cache_creation.input_tokens,gen_ai.workflow.name, resourcedeployment.environment. scopeSpans[0].schemaUrlishttps://opentelemetry.io/schemas/1.45.0, and it is absent without the opt-in.- With the opt-in and no dedicated agent span, the conclusion span carries
gen_ai.operation.name = invoke_agent.
- The agent span's name is
- Without the opt-in, nothing changes. The existing
"gh-aw.agent.agent"name and parent (:2952,:2960)
assertions pass unchanged. Do not loosen any assertion.
actions/setup/js/otlp_metrics.test.cjs:
- The test at
:56asserts the exact ordered list of metric names (:80-100+).- Pass
provider: "github",agentName: "CI",agentDurationSeconds: 2andagentErrorType: "agent_failed"
in its input. - Insert the new names in that list in emission order: the four
gen_ai.client.inference.usage.*names after
gh_aw.tokens.cache_write, thengen_ai.invoke_agent.duration. - Keep every existing entry.
- Pass
- Usage counters. With
inputTokens: 10, outputTokens: 3, cacheReadTokens: 5, cacheWriteTokens: 2, inclusiveInputTokens: 17:- The input counter value is 17, and absent without
inclusiveInputTokens. Output is 3, cache read is 5 and cache write is 2. - Each data point has
gen_ai.operation.name=chat,gen_ai.provider.name=github,gen_ai.token.modality=unknown
andgen_ai.request.model.
- The input counter value is 17, and absent without
- Zero and missing values. With
cacheWriteTokens: 0and nocacheReadTokens, there is no cache usage data
point;gen_ai.client.token.usagestill emits its zero value. - No provider. Without
provider, there are nogen_ai.client.inference.usage.*metrics. - Agent duration.
gen_ai.invoke_agent.durationhas units, the 20 explicit bounds from Step 7.1, and the
attributesgen_ai.operation.name=invoke_agent,gen_ai.agent.name,gen_ai.request.modeland
error.type=agent_failed. WithoutagentDurationSeconds, it is absent. - Opt-in. With
semconvLatest: true,gen_ai.client.token.usageis absent,gh_aw.tokens.*have the same values
withoutgen_ai.token.type, and the new metrics are present. - Metric resource. With
cicd.pipeline.run.idandvcs.ref.head.revisioninresourceAttributespassed to
buildOTLPMetricsPayload, neither appears on the metric resource (spec §8.3).
Parser. parseTokenUsageJsonl sums inclusive input for flag true/false/absent with openai and an
unknown provider; agent_usage.json gets input_tokens_inclusive.
actions/setup/js/otel_contract.test.cjs: it has no name inventory. Extend the customer-contract test: add
OTEL_SEMCONV_STABILITY_OPT_IN to its env list, assert gen_ai.provider.name, gen_ai.agent.name and the §8.1
resource attributes next to the old names, and assert there is no scope schemaUrl without the opt-in.
Backward compatibility (T-OT-020), new send_otlp_span_legacy_contract.test.cjs. Before changing runtime code:
- Run the 9b scenario in process (virtual
/tmp/gh-aw, capturedfetch) on68df009forsuccessandfailure. - Flatten each export into facts (span name, kind, parent, status, attributes and resource attributes with values,
metric type, unit, temporality, data points), without IDs and timestamps; onlygh-aw.action_minutesand
*durationsums are volatile. Two runs must match. - Commit the facts as
conformance/legacy-contract.golden.json, with the capture script. - Assert the default export, and one with
OTEL_SEMCONV_STABILITY_OPT_IN=http, contain every golden fact; with the
opt-in, everygh-aw.*andgithub.*attribute. The test must pass on68df009and fail ifgen_ai.systemis
removed.
Step 9: Interoperability tests
9a. Wire round-trip (T-OT-019). In actions/setup/js/scripts/test_otlp_protobuf.mjs, add one test(...) that
builds opt-in payloads with buildOTLPPayload (span invoke_agent CI, SPAN_KIND_INTERNAL, scope schemaUrl) and
buildOTLPMetricsPayload (gen_ai.client.inference.usage.input_tokens and gen_ai.invoke_agent.duration with the
20 bounds). Assert byte equality with the SDK encoders (as :179, :199) and that
kind, schemaUrl, isMonotonic and explicitBounds survive decoding. It runs in the existing cjs.yml SDK job.
9b. Semantic-convention conformance (T-OT-018, D13). Add actions/setup/js/conformance/:
-
agent-run.cjs, a scenario program. It writes/tmp/gh-awfixtures:aw_info.json(copilot, workflowCI),agent_usage.json(input_tokens: 10, output_tokens: 3, cache_read_tokens: 5, cache_write_tokens: 2, input_tokens_inclusive: 17) andagent_output.json. It setsINPUT_JOB_NAME=agent,GH_AW_AGENT_CONCLUSIONfrom
argv, the opt-in for--latest,GH_AW_OTEL_METRICS=trueandGH_AW_OTLP_ENDPOINTS=[{"url": <runner's OTEL_EXPORTER_OTLP_ENDPOINT>}]. It deletes stale export state first, callssendJobSetupSpanandsendJobConclusionSpan("gh-aw.agent.conclusion", { startMs }), then
removes its fixtures. -
conformance.yaml, using the format in the runner README
(Expectations):runner: genai-conformance instrumented_library: gh-aw instrumentation_library: gh-aw otlp_protocol: http/protobuf expected_violations: - id: not_stable reason: semantic-conventions-genai has no stable release yet. - id: missing_attribute reason: gh-aw.*, github.* (D14) and non-GenAI names (cicd.*, vcs.*, service.version, deployment.environment.name). 9c guards gen_ai.*. - id: missing_metric reason: gh_aw.* metrics (D14). 9c guards gen_ai.*. scenarios: agent_success_latest: {run: node agent-run.cjs success --latest} agent_failure_latest: {run: node agent-run.cjs failure --latest} agent_success_compat: {run: node agent-run.cjs success}
Once any span entry has
count, every emitted span must be matched, so also declare the setup and conclusion spans
(for example bykind).metrics:is an exact list: include everygh_aw.*metric. Both*_latestscenarios MUST have exactly one span matched by
gen_ai.operation.name: invoke_agentwithgen_ai.provider.name: github,gen_ai.agent.name: CI,
gen_ai.request.model: {present: true}, and scopeschema_urlset.error.typeMUST beagent_failedon
failure and absent on success. Neither scenario may declare its ownexpected_violations.
agent_success_compatdocuments today's shape: declare each finding it produces (observed at the pins:
genai_span_name_formatandgenai_expected_attribute_missingfor G2,span_status_ok_set_by_instrumentationfor
G13,instrumentation_scope_schema_url_missingfor G10), with a reason that names the gap. Removed names (G6) show up as
missing_attribute/missing_metric, notdeprecated. A declared finding that stops appearing fails the run. -
check-report.mjs(9c), run after the runner. It reads the Weaver reports (findings in
live_check_result.all_advice[]onsamples[]and their attributes) and fails if amissing_attribute(name in
context.attribute_key) ormissing_metric(name insignal_name) finding in a*_latestscenario names a
gen_ai.*key, or ifgen_ai.client.inference.usage.input_tokensorgen_ai.invoke_agent.durationwas not seen.
CI: add a job to .github/workflows/cjs.yml, modelled on the SDK job. It sets up Python, checks out
open-telemetry/semantic-conventions-conformance at a4321907b3768c468966538a459130ac6b095bdc into $RUNNER_TEMP,
runs pip install -e tools/runner -e tools/gen-ai/runner there (the runner is not on PyPI), installs the Weaver
v0.28.0 release binary into $RUNNER_TEMP, and then runs:
otel-conformance actions/setup/js/conformance \
--registry 'https://github.com/open-telemetry/semantic-conventions-genai.git@e6658f14c9d9ea0760825f029cb82e7673f48fab[model]' \
--report-dir "$RUNNER_TEMP/weaver-reports" --data-file "$RUNNER_TEMP/conformance-data.json"
node actions/setup/js/conformance/check-report.mjs "$RUNNER_TEMP/weaver-reports"Nothing is written to the checkout. Add a make validate-otel-conformance target for the same commands, not in
agent-finish.
9d. Live smoke check. In .github/workflows/smoke-otel-backends.md Step 1, add a jq check that a current-run span in
/tmp/gh-aw/agent/otel.jsonl (the agent's copy) has gen_ai.provider.name, then run gh aw compile.
Step 10: Documentation
.github/aw/otel.md::102(Agent row): add "gen_ai.agent.name,gen_ai.provider.name,error.typeon failure; with
OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimentalthe span isinvoke_agent <workflow>, kind
INTERNAL".:112(Resource identity row): addcicd.*,vcs.*anddeployment.environment.name.- Replace
:115("No OTel metric emitter exists …") and the:121bullet with one line pointing to spec §11.5. :125: removegen_ai.provider.nameandcicd.*from "Aliases not emitted".:15: point it to spec §11.5. Update both "200 names" counts.- Add a short "Semantic-convention opt-in" paragraph that links to spec §6.7.
:24and:78: addgen_ai.provider.name,gen_ai.agent.name,gen_ai.usage.cache_write.input_tokensand
thegen_ai.client.inference.usage.*metrics next to the old names.weekly-otel-reference.mdregenerates this file; check it keeps these edits.
docs/src/content/docs/reference/open-telemetry-attributes.mdx:- Add the new span and resource attributes and the provider table (D2).
- Mark
gen_ai.system,gen_ai.usage.total_tokens,gen_ai.usage.cache_creation.input_tokensand
gen_ai.workflow.nameas compatibility attributes.
docs/src/content/docs/reference/open-telemetry.mdx:-
Add the new metrics to the metrics section.
-
Add a section "Opting in to the latest GenAI conventions" showing:
env: OTEL_SEMCONV_STABILITY_OPT_IN: gen_ai_latest_experimental
with a warning that the conventions are not yet stable.
-
Add a note that the new input-token counter includes cache tokens once (D5), so dashboards must not add cache
tokens to it. -
Add a "Migrating queries" table (old → new, and when the old name stops):
gen_ai.system→
gen_ai.provider.name(values change:github_models→github,google_vertex_ai→gcp.gen_ai);
gen_ai.workflow.name→gen_ai.agent.name;gen_ai.usage.cache_creation.input_tokens→
gen_ai.usage.cache_write.input_tokens;gen_ai.client.token.usage{gen_ai.token.type}→
gen_ai.client.inference.usage.*(input is inclusive); spangh-aw.agent.agent(CLIENT, child of conclusion) →
invoke_agent <workflow>(INTERNAL, sibling); span statusOK→UNSETon success (D12). Say the old names
stay supported and on by default; deprecation comes in a later release (D15). -
Add a short "Conformance" paragraph: what T-OT-018 checks, the pinned registry commit, and how to run
make validate-otel-conformancelocally.
-
- Changeset: add
.changeset/minor-genai-semconv.md("gh-aw": minor), in the style of
.changeset/minor-otlp-protobuf.md. Name the additive attributes and metrics, the opt-in, and the CI-only
conformance job, and say today's names stay supported (D15).
Step 11: Validate
Run these in a devcontainer or Codespace, as CONTRIBUTING.md requires:
make generate-otel-attributes
make check-otel-attributes
make validate-otel-contract
make fmt-cjs
make lint-cjs
make agent-finish
# 9a, needs the isolated SDK install from cjs.yml
GH_AW_OTEL_SDK_DIR=<dir> node --test actions/setup/js/scripts/test_otlp_protobuf.mjs
# 9b and 9c, needs Python and Weaver v0.28.0
make validate-otel-conformanceRe-check D8 only if the compiler's env: handling has changed since 68df009.
6. Acceptance criteria
- Spec. The spec contains §6.7, the new §8.1 table, and the updated §8.4, §9.5, §9.6, §10.3, §11.2, §11.5,
§17.1, §17.1.2 (T-OT-009, T-OT-011, T-OT-014 to T-OT-020), §18.1 and §19, as in Step 1. - Generated files.
specs/otel/attributes.tsphas the new names, and the generated files are up to date
(make check-otel-attributespasses). - No regression without the opt-in. Every span name, kind, parent, attribute key, attribute value and metric
that68df009emits is still emitted with the same value. Existing tests pass; the only allowed edits add
gen_ai.usage.cache_write.input_tokensto exact-set assertions and shift metric-list indexes for the five new
metrics. No assertion is loosened or removed. T-OT-020 passes. - Additions without the opt-in. An agent job also emits:
gen_ai.provider.name(D2) on the setup, agent and conclusion spans;gen_ai.agent.nameandgen_ai.usage.cache_write.input_tokens;error.type(D7) on failure;- the §8.1 resource attributes;
gen_ai.client.inference.usage.*, with an inclusive input counter (cache counted once, D5) and no zero data points;gen_ai.invoke_agent.duration, with the 20 standard buckets.
- With
OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental:- the agent span is
invoke_agent <workflow>,INTERNAL, and a sibling of the conclusion span; - the conclusion span carries no GenAI operation or usage attributes when an agent span exists;
- span
input_tokensincludes cache tokens once, or is absent when unknown (D5); - the scope
schemaUrlis set; - none of the compatibility-only names or metrics are emitted;
- every
gh-aw.*attribute andgh_aw.*metric is still emitted with the same value; onlygh_aw.tokens.*drop
gen_ai.token.type(D14).
- the agent span is
- Metric dimensions. No run-level identifier (
cicd.pipeline.run.id,vcs.ref.head.revision, run URL)
becomes a metric dimension or a metric resource attribute. - Docs.
.github/aw/otel.md,open-telemetry-attributes.mdxandopen-telemetry.mdxare updated, and
.github/aw/otel.mdno longer says that metrics are not emitted. - Interoperability. The 9a wire test and the conformance CI job pass (no undeclared violations; every compat
finding names a gap;check-report.mjsfinds no unknowngen_ai.*name). - Status (D12). With the opt-in, successful built-in spans have status
UNSET; without it they are unchanged. - Changeset and migration. The changeset says today's names stay supported (D15);
open-telemetry.mdxhas
the migration table and conformance paragraph. - Build.
make agent-finishpasses.
7. Out of scope (separate issues)
- Engine spans in the run trace (D11); MCP gateway spans (
github/gh-aw-mcpg). - Session-log
event.name; grader results asgen_ai.evaluation.result; content capture mapping. gen_ai.conversation.id(D9);gen_ai.invoke_agent.*_callshistograms (D10); reasoning tokens.- Compiler forwarding of
vars.OTEL_SEMCONV_STABILITY_OPT_IN(D8). - Deprecating today's names, then making phase 2 the default (D15 stages 2 and 3).
8. Risks and notes for reviewers
- Ingest cost. Phase 1 adds about five metric series per agent job and nine span resource attributes; metric
cardinality is unchanged (§8.3). - Provider value for Copilot.
githubis the endpoint gh-aw calls ("provider as identified by the client");
the model vendor stays visible ingen_ai.request.model. - Development status. GenAI names may still change; the pins in §2 and the opt-in contain that.
- Don't sum token metrics. Phase 1 sends old and new side by side; queries use one (§6.7).
Activity