Skip to content

Observability: align the OTel spec and runtime with OpenTelemetry semantic-conventions-genai (provider, invoke_agent, token and agent metrics) #79089

Done

Description

@sudivate

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 68df009 in 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 on a245939 (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.system REQUIRED.
  • §11.2 requires gen_ai.client.token.usage with gen_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_IN contains gen_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

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.name and gen_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.type drives generic error-rate views (spec §10.5 requires it).
  • CI context is standard. cicd.* and vcs.* 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 is invoke_agent {gen_ai.agent.name}, or
    invoke_agent when there is no name. The kind is INTERNAL and gen_ai.operation.name = invoke_agent.
    gen_ai.agent.name is Conditionally Required when available, and error.type is Conditionally Required on error.
  • Remote agent (gen_ai.client.invoke_agent): the same, except the kind is CLIENT and gen_ai.provider.name
    is Required. Not used here (see D3).
  • Agent-span attributes: gen_ai.request.model is Recommended if the agent uses a single model; input tokens
    SHOULD include cached tokens; content attributes (gen_ai.input.messages and 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 (true for OpenAI-style
    prompt_tokens). The AI-credits spec prices cache with that flag, then a provider default
    (model_costs.cjs:97-108, :196-212), but agent_usage.json sums raw input_tokens, so its meaning varies.
  • Where input excludes cache, cache dominates: actions/setup/js/fixtures/agy_ci_sessions.cjs:61 has
    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.usage row 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 | … assert gen_ai.provider.name equals the mapped value
    and, without the opt-in, gen_ai.system is 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_tokens and error.type on built-in spans; the gen_ai.client.inference.usage.*
    and gen_ai.invoke_agent.duration metrics.
  • Changed: gen_ai.system, gen_ai.usage.total_tokens, gen_ai.usage.cache_creation.input_tokens,
    gen_ai.workflow.name and gen_ai.client.token.usage are compatibility names, still supported and on by default
    (not deprecated, §6.7); with the opt-in, the agent span
    is invoke_agent (INTERNAL) and gen_ai.usage.input_tokens includes 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)

  1. 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";
  2. Export resolveGenAiProvider, isGenAiLatestExperimental and GEN_AI_SCHEMA_URL from module.exports
    (around :2900), because otlp_metrics.cjs already requires this module lazily.

Step 4: Phase 1 span attributes (send_otlp_span.cjs)

  1. Provider on the setup span (:1602-1606) and the conclusion span (:2487-2491). Replace

    const 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_ID push unchanged.

  2. Agent attributes (:2547-2560). Split the block so the agent-specific GenAI attributes are collected in a new
    array instead of the shared attributes:

    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, agentEndMs at :2693-2714, or add the array when building payloads):

    • Without the opt-in (shipped): push ...agentGenAiAttrs onto attributes, 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
      only error.type when set); otherwise push them onto attributes.
  3. 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). Push cache_creation
      only without the opt-in.
    • With the opt-in, set gen_ai.usage.input_tokens to resolveInclusiveInputTokens(agentUsage) (Step 7.7), and
      omit it when that is undefined. Without the opt-in, keep the raw value.
    • Emit gen_ai.usage.total_tokens only without the opt-in, and keep its current definition.
    • Update the comment at :2743-2747 to say that total_tokens is a gh-aw compatibility attribute that is not
      part of the OpenTelemetry conventions.
  4. Redaction. The sensitive-key filter (SENSITIVE_ATTR_KEY_RE) matches gen_ai.token.modality because the
    key contains token. Let the values text, image, audio, video and unknown through 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,
});
  • parentSpanId is 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.
  • buildOTLPPayload must pass the scope schemaUrl (Step 6) when the opt-in is set.
  • Status (D12): with the opt-in, buildOTLPSpan defaults code to 0 instead of 1 (:352), the conclusion span uses 0
    on success (:2362), and otlp.cjs:148 uses isError ? 2 : 0. Explicitly passed codes are unchanged.

Step 6: Resource attributes and schemaUrl

  1. In buildGitHubActionsResourceAttributes (:425-496), add a local helper after upsertResourceAttr:

    const addResourceAttrIfAbsent = attr => {
      if (!resourceAttributes.some(existing => existing.key === attr.key)) resourceAttributes.push(attr);
    };

    Use it just before return to add the §8.1 attributes from the existing locals (runId, runUrlAttr, job,
    repository, refName, sha and the deployment.environment value; vcs.repository.url.full uses
    GITHUB_SERVER_URL, default https://github.com). For cicd.pipeline.name, add an optional workflowName
    option: pass workflowName at send_otlp_span.cjs:1639 and :2628, and process.env.GITHUB_WORKFLOW || "" at
    otlp.cjs:115 and check_admission.cjs:260.

    Only deployment.environment (:494) changes: with the opt-in, do not emit it.

    OTEL_RESOURCE_ATTRIBUTES values must win, hence addResourceAttrIfAbsent, not upsertResourceAttr.

  2. Leave METRIC_RESOURCE_ATTRIBUTE_KEYS (otlp_metrics.cjs:21) unchanged, so none of these reach metrics (spec
    §8.3). Add a test for that.

  3. schemaUrl: with the opt-in, add schemaUrl: GEN_AI_SCHEMA_URL as a sibling of scope on the
    scopeSpans[0] entry in buildOTLPBatchPayload (send_otlp_span.cjs:608-611) and on the scopeMetrics[0]
    entry in buildOTLPMetricsPayload (otlp_metrics.cjs:169). In OTLP, schemaUrl is a field of
    ScopeSpans/ScopeMetrics, not of InstrumentationScope.

    • The protobuf encoder already supports it (otlp_protobuf.cjs:247).
    • Without the opt-in, payloads must not change.

Step 7: Metrics (actions/setup/js/otlp_metrics.cjs)

  1. 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];
  2. Add these optional parameters to buildBuiltinRunMetrics (:380) and its JSDoc (:355-379):
    provider = "", inclusiveInputTokens, agentName = "", agentDurationSeconds, agentErrorType = "", semconvLatest = false.

  3. In the token loop (:435-449), with semconvLatest skip gen_ai.client.token.usage but still emit the
    gh_aw.tokens.* alias with the same value, minus gen_ai.token.type (the name carries the type; D14).
    Without it, nothing changes.

  4. 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 }));
        }
      }
    }
  5. After the token block, when agentDurationSeconds is a finite number ≥ 0, push gen_ai.invoke_agent.duration
    with buildOTLPMetric (:59, already accepts buckets): histogram, unit s,
    GEN_AI_INVOKE_AGENT_DURATION_BUCKETS, attributes gen_ai.operation.name=invoke_agent plus bounded
    gen_ai.agent.name, gen_ai.request.model and error.type when set.

  6. In sendJobConclusionSpan, where buildBuiltinRunMetrics is 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, agentEndMs and agentErrorType are in scope there (:2693-2757).

  7. Inclusive input (D5).

    • model_costs.cjs: export computeInclusiveInputTokens, the computeInferenceCostUSD rule: flag true →
      input; false → input + read + write; no flag and providerIncludesCacheReadsInInput → input + write; else
      input + read + write.
    • parseTokenUsageJsonl sums it per record; parse_token_usage.cjs:643 writes input_tokens_inclusive when
      input_tokens and both cache counts are numbers.
    • send_otlp_span.cjs: normalizeRuntimeTokenUsage passes through input_tokens_inclusive and
      input_tokens_include_cache. resolveInclusiveInputTokens(usage) returns that key; else input_tokens when the
      flag is true or there is no cache; else input + cache when the flag is false; else undefined.

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:

  1. Provider map.
    • it.each over 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) and gen_ai.system (column 3).
    • Extend the cases near :1505, :2170, :2223; the :2135 no-engine case asserts no provider.
  2. Agent identity. With GH_AW_INFO_WORKFLOW_NAME = "CI" (send_otlp_span.cjs:2304), the agent span has
    gen_ai.agent.name = CI, still has gen_ai.workflow.name, and gen_ai.operation.name = chat.
  3. error.type. Per D7 on the agent and conclusion spans; absent on success.
  4. Cache attributes. With cache_write_tokens: 7, both gen_ai.usage.cache_write.input_tokens and
    gen_ai.usage.cache_creation.input_tokens equal 7.
  5. Resource. The Step 6 cicd.*, vcs.* and deployment.environment.name values are present
    (vcs.provider.name = github); OTEL_RESOURCE_ATTRIBUTES=cicd.pipeline.name=custom stays custom;
    deployment.environment is still present.
  6. 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>, kind is SPAN_KIND_INTERNAL, and parentSpanId equals
      the conclusion span's parentSpanId ("abcdef1234567890" in the :2921 setup). It is not the conclusion
      span's spanId.
    • The agent span has gen_ai.operation.name = invoke_agent.
    • The conclusion span has no gen_ai.operation.name, gen_ai.response.finish_reasons or gen_ai.usage.*.
    • gen_ai.usage.input_tokens = input_tokens_inclusive if set; 10 with flag true; 17 with false; 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, resource deployment.environment.
    • scopeSpans[0].schemaUrl is https://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.
  7. 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:

  1. The test at :56 asserts the exact ordered list of metric names (:80-100+).
    • Pass provider: "github", agentName: "CI", agentDurationSeconds: 2 and agentErrorType: "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, then gen_ai.invoke_agent.duration.
    • Keep every existing entry.
  2. 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
      and gen_ai.request.model.
  3. Zero and missing values. With cacheWriteTokens: 0 and no cacheReadTokens, there is no cache usage data
    point; gen_ai.client.token.usage still emits its zero value.
  4. No provider. Without provider, there are no gen_ai.client.inference.usage.* metrics.
  5. Agent duration. gen_ai.invoke_agent.duration has unit s, the 20 explicit bounds from Step 7.1, and the
    attributes gen_ai.operation.name=invoke_agent, gen_ai.agent.name, gen_ai.request.model and
    error.type=agent_failed. Without agentDurationSeconds, it is absent.
  6. Opt-in. With semconvLatest: true, gen_ai.client.token.usage is absent, gh_aw.tokens.* have the same values
    without gen_ai.token.type, and the new metrics are present.
  7. Metric resource. With cicd.pipeline.run.id and vcs.ref.head.revision in resourceAttributes passed 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:

  1. Run the 9b scenario in process (virtual /tmp/gh-aw, captured fetch) on 68df009 for success and failure.
  2. 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; only gh-aw.action_minutes and
    *duration sums are volatile. Two runs must match.
  3. Commit the facts as conformance/legacy-contract.golden.json, with the capture script.
  4. Assert the default export, and one with OTEL_SEMCONV_STABILITY_OPT_IN=http, contain every golden fact; with the
    opt-in, every gh-aw.* and github.* attribute. The test must pass on 68df009 and fail if gen_ai.system is
    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-aw fixtures: aw_info.json (copilot, workflow CI), agent_usage.json (input_tokens: 10, output_tokens: 3, cache_read_tokens: 5, cache_write_tokens: 2, input_tokens_inclusive: 17) and agent_output.json. It sets INPUT_JOB_NAME=agent, GH_AW_AGENT_CONCLUSION from
    argv, the opt-in for --latest, GH_AW_OTEL_METRICS=true and GH_AW_OTLP_ENDPOINTS=[{"url": <runner's OTEL_EXPORTER_OTLP_ENDPOINT>}]. It deletes stale export state first, calls sendJobSetupSpan and sendJobConclusionSpan("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 by kind). metrics: is an exact list: include every gh_aw.* metric. Both *_latest scenarios MUST have exactly one span matched by
    gen_ai.operation.name: invoke_agent with gen_ai.provider.name: github, gen_ai.agent.name: CI,
    gen_ai.request.model: {present: true}, and scope schema_url set. error.type MUST be agent_failed on
    failure and absent on success. Neither scenario may declare its own expected_violations.
    agent_success_compat documents today's shape: declare each finding it produces (observed at the pins:
    genai_span_name_format and genai_expected_attribute_missing for G2, span_status_ok_set_by_instrumentation for
    G13, instrumentation_scope_schema_url_missing for G10), with a reason that names the gap. Removed names (G6) show up as
    missing_attribute/missing_metric, not deprecated. 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[] on samples[] and their attributes) and fails if a missing_attribute (name in
    context.attribute_key) or missing_metric (name in signal_name) finding in a *_latest scenario names a
    gen_ai.* key, or if gen_ai.client.inference.usage.input_tokens or gen_ai.invoke_agent.duration was 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

  1. .github/aw/otel.md:
    • :102 (Agent row): add "gen_ai.agent.name, gen_ai.provider.name, error.type on failure; with
      OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental the span is invoke_agent <workflow>, kind
      INTERNAL".
    • :112 (Resource identity row): add cicd.*, vcs.* and deployment.environment.name.
    • Replace :115 ("No OTel metric emitter exists …") and the :121 bullet with one line pointing to spec §11.5.
    • :125: remove gen_ai.provider.name and cicd.* 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.
    • :24 and :78: add gen_ai.provider.name, gen_ai.agent.name, gen_ai.usage.cache_write.input_tokens and
      the gen_ai.client.inference.usage.* metrics next to the old names.
    • weekly-otel-reference.md regenerates this file; check it keeps these edits.
  2. 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_tokens and
      gen_ai.workflow.name as compatibility attributes.
  3. 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); span gh-aw.agent.agent (CLIENT, child of conclusion) →
      invoke_agent <workflow> (INTERNAL, sibling); span status OK → UNSET on 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-conformance locally.

  4. 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-conformance

Re-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.tsp has the new names, and the generated files are up to date
    (make check-otel-attributes passes).
  • No regression without the opt-in. Every span name, kind, parent, attribute key, attribute value and metric
    that 68df009 emits is still emitted with the same value. Existing tests pass; the only allowed edits add
    gen_ai.usage.cache_write.input_tokens to 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.name and gen_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_tokens includes cache tokens once, or is absent when unknown (D5);
    • the scope schemaUrl is set;
    • none of the compatibility-only names or metrics are emitted;
    • every gh-aw.* attribute and gh_aw.* metric is still emitted with the same value; only gh_aw.tokens.* drop
      gen_ai.token.type (D14).
  • 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.mdx and open-telemetry.mdx are updated, and
    .github/aw/otel.md no 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.mjs finds no unknown gen_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.mdx has
    the migration table and conformance paragraph.
  • Build. make agent-finish passes.

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 as gen_ai.evaluation.result; content capture mapping.
  • gen_ai.conversation.id (D9); gen_ai.invoke_agent.*_calls histograms (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. github is the endpoint gh-aw calls ("provider as identified by the client");
    the model vendor stays visible in gen_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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions