OpenTelemetry

OpenTelemetry is the observability layer for GitHub Agentic Workflows. It lets workflows export traces and spans to an external backend, and it gives workflows a way to read that telemetry back when they need to inspect behavior across runs.

This guide covers the two ways gh-aw uses OpenTelemetry:

  • Write-side OTLP sends new workflow spans to a backend such as Sentry.
  • Read-side MCP lets a workflow query traces and spans that already exist in that backend.

Keep reusable telemetry setup in shared workflow files when multiple workflows use the same configuration.

Configure observability.otlp in workflow frontmatter when the workflow should emit new spans. A typical Sentry setup looks like this:

.github/workflows/daily-report.md
---
network:
allowed:
- "*.sentry.io"
observability:
otlp:
endpoint:
- url: ${{ secrets.GH_AW_OTEL_SENTRY_ENDPOINT }}
headers:
Authorization: ${{ secrets.GH_AW_OTEL_SENTRY_AUTHORIZATION }}
---

Once configured, gh-aw exports built-in workflow spans such as setup and conclusion events to the configured OTLP backend.

Use the bare secret expression for authorization headers, as shown above, rather than adding an authentication scheme prefix. For Sentry endpoints, gh-aw automatically rewrites Authorization to x-sentry-auth, so no prefix is needed.

OTLP header credentials of at least four characters are masked before setup exports spans, including encoded Basic-auth credentials, decoded passwords, and JSON-escaped values. Artifact and step-summary redaction also derives these values from the configured headers rather than relying on setup logs or recognizable token prefixes. OTLP endpoint and header environment variables, including multi-endpoint aggregated headers, are excluded from the eval agent sandbox.

If a credential was exposed in an earlier run, revoke or rotate it and remove the affected logs and artifacts. Updated redaction does not sanitize retained output from previous runs.

HTTP 401 and 403 export failures are not retried with unchanged credentials. Check the affected collector’s configured authorization header and telemetry-write permissions. Transient delivery failures retain bounded retries; a rejected endpoint does not block other configured endpoints or the local telemetry mirror, and export failure does not fail the functional workflow.

The gh-aw JavaScript exporter defaults to OTLP/HTTP JSON (http/json) for traces, opt-in compact session logs, and metrics, which are enabled by default when OTLP is configured. Set the standard protocol environment variable to use binary OTLP/HTTP protobuf instead:

env:
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
observability:
otlp:
endpoint: ${{ secrets.AZURE_MONITOR_OTLP_ENDPOINT }}
headers:
Authorization: ${{ secrets.AZURE_MONITOR_OTLP_AUTHORIZATION }}

OTEL_EXPORTER_OTLP_TRACES_PROTOCOL, OTEL_EXPORTER_OTLP_LOGS_PROTOCOL, and OTEL_EXPORTER_OTLP_METRICS_PROTOCOL, when non-empty, take precedence over OTEL_EXPORTER_OTLP_PROTOCOL for their respective signals. A signal-specific override affects only that signal. Set these overrides in workflow env when the signals need different encodings. All accept http/json or http/protobuf; gRPC is not supported by this helper. The selected encoding applies to all configured endpoints for that signal. Unsupported protocols and encoding errors produce an exporter diagnostic without retrying or silently falling back to JSON.

To manage the protocol as a repository, organization, or enterprise Actions variable, use gh aw env get and gh aw env update. The defaults file field default_otlp_protocol maps to the standard OTEL_EXPORTER_OTLP_PROTOCOL variable:

Terminal window
gh aw env get defaults.yml

Set this field in the downloaded file, retaining any other defaults:

default_otlp_protocol: http/protobuf
Terminal window
gh aw env update defaults.yml --scope repo

As with other managed fields, setting it to null or omitting it deletes the variable at the selected scope. The compiler injects ${{ vars.OTEL_EXPORTER_OTLP_PROTOCOL }} into workflow env unless that key is explicitly defined by the workflow. Recompile existing workflows once to add that lookup; subsequent variable updates take effect without recompilation.

For Azure Monitor native OTLP ingestion, use the traces endpoint from Application Insights OTLP Connection Info, or construct the Data Collection Endpoint / Data Collection Rule path:

https://<logs-dce-domain>/datacollectionRules/<dcr-immutable-id>/streams/Microsoft-OTLP-Traces/otlp/v1/traces

The exporter retains a complete /v1/traces path, including query parameters. For base endpoints, it appends /v1/traces. Set AZURE_MONITOR_OTLP_AUTHORIZATION to the complete Bearer <access-token> header value for a Microsoft Entra identity authorized to write to the DCR (typically Monitoring Metrics Publisher). Provision and refresh that token outside this helper; protobuf encoding does not provide Azure authentication or make an Application Insights connection string an OTLP endpoint.

When compact session logs are enabled, the exporter selects the independent Microsoft-OTLP-Logs stream for the same DCE and DCR, preserving query parameters:

https://<logs-dce-domain>/datacollectionRules/<dcr-immutable-id>/streams/Microsoft-OTLP-Logs/otlp/v1/logs

The DCR must accept the logs stream as well as the traces stream. A complete logs endpoint is retained; generic collector endpoints use /v1/logs without Azure stream rewriting.

Protobuf requests use Content-Type: application/x-protobuf with binary-safe direct and proxy transports. Traces encode ExportTraceServiceRequest; logs encode ExportLogsServiceRequest, including structured bodies and trace/span correlation; metrics encode ExportMetricsServiceRequest (gauge, monotonic sum, and explicit-bucket histogram data points, with exemplars). The encoder uses only Node.js built-ins, and the sanitized local otel.jsonl trace mirror and otel-metrics.jsonl metrics mirror remain raw OTLP JSON regardless of wire encoding. These settings configure gh-aw JavaScript telemetry; external engines and the MCP gateway retain their own exporter capabilities.

Successful HTTP responses are inspected for OTLP partialSuccess in JSON or protobuf, for traces, logs, and metrics. JSON responses ignore unknown fields and treat null members as unset, following OTLP/ProtoJSON compatibility rules. Rejected spans, log records, or metric data points produce a warning with the signal-specific rejection count and increment gh-aw.otlp.export_errors; sanitized details appear in gh-aw.otlp.export_error_details. Warning-only partial success (zero rejected records with a collector message) warns without incrementing the error count. Collector messages are withheld because they may contain private data or credentials.

Response diagnostics are limited to 64 KiB. Malformed, unsupported, oversized, or unreadable successful responses record an exporter error with acceptance marked unknown. The proxy-aware curl transport has a 10-second request timeout within a 15-second subprocess deadline; a body timeout after known HTTP success reports unknown acceptance without retrying. Empty responses and valid full-success responses remain successful. None of these successful HTTP responses are retried: resending records the collector already accepted could create duplicates. Export diagnostics remain nonfatal and do not prevent delivery to other configured endpoints.

When a workflow does not configure observability.otlp (in its own frontmatter or through an import), the compiler falls back to a default OTLP configuration read from the GitHub Actions environment:

NameKindPurpose
GH_AW_DEFAULT_OTLP_ENDPOINTSecret or variableOTLP endpoint URL used when no endpoint is configured in frontmatter
GH_AW_DEFAULT_OTLP_HEADERSSecretExporter headers (key=value pairs, comma-separated) sent to that endpoint

Because these values are resolved at run time, setting defaults at the repository or organization level enables telemetry for agentic workflows that have not opted out.

To opt out, set observability.otlp: false in the main workflow’s frontmatter and recompile:

observability:
otlp: false

The compiler omits its OTLP endpoint and credential environment variables, even if an import configures OTLP. This does not change variables you define explicitly in env:, trace-context propagation, or local telemetry artifacts. The opt-out applies only in the main workflow; observability.otlp: false in an imported workflow has no effect.

Behavior:

  • The endpoint secret takes precedence over the variable when both are set, including when an organization secret and repository variable are configured. Clear both values to disable OTLP export.
  • When both endpoint values are unset, the endpoint resolves to an empty string and OTLP export is a no-op.
  • An endpoint without GH_AW_DEFAULT_OTLP_HEADERS is treated as unconfigured rather than exported without credentials. The agent job additionally fails with an error so the misconfiguration is visible.
  • Any observability.otlp configuration in frontmatter or an import overrides these defaults entirely.
  • If the workflow already defines any of the OTLP-related environment variables in its own env: block, the compiler skips injecting that specific variable instead of emitting a duplicate key.

Set variables with gh aw env update or gh variable set. Set either value as a secret with gh secret set.

gh aw env otel tests an OTLP endpoint and configures the existing GH_AW_DEFAULT_OTLP_ENDPOINT and GH_AW_DEFAULT_OTLP_HEADERS Actions secrets, plus OTEL_EXPORTER_OTLP_PROTOCOL and GH_AW_OTEL_METRICS Actions variables. This is an operational command: it does not compile workflows, change generated files, or introduce a new configuration format.

Terminal window
gh aw env otel

The interactive command uses the current repository, prompts for the endpoint, displays the targets for confirmation, and reads comma-separated key=value headers with input hidden. Supply a complete authentication header value, and percent-encode commas inside values. Do not put header credentials in command arguments or shell history.

For noninteractive setup, read headers from a protected file or a secret manager’s stdout:

Terminal window
gh aw env otel --repo my-org/my-repo \
--endpoint https://collector.example.com \
--protocol http/protobuf --headers-stdin --yes < otlp-headers.txt
OptionBehavior
--repo owner/repo, --org slug, --enterprise slugRepeat target flags to configure multiple targets with the same endpoint and credentials; without target flags, use the current repository
--scope repo|org|entRestrict the target type; contradictory target flags fail
--visibility all|private|selectedOrganization repository access; defaults to private. Invalid with repository targets
--selected owner/repoRequired for organization selected visibility; repeat for repositories belonging to the target organization
--endpoint URLHTTPS base endpoint or complete /v1/traces URL; userinfo credentials, fragments, raw quotes/backslashes, and control characters are rejected. Percent-encode quotes and backslashes. Plain HTTP is limited to literal loopback IP addresses
--protocol http/json|http/protobufRequest encoding; defaults to http/json
--metrics=falseDisable metrics; otherwise metrics are enabled
--headers-stdinRead the header secret from stdin, up to 48 KiB; requires --endpoint and --yes for noninteractive use
--yesApprove the displayed targets without prompting

Enterprise scope enumerates the enterprise organizations visible to the authenticated user through GitHub GraphQL and configures organization-level secrets and variables in each one. GitHub does not provide an enterprise-level Actions secrets API. Enterprise --visibility all or private applies that repository visibility to each organization. With enterprise --visibility selected --selected my-org, only named member organizations are configured, with private repository visibility. Enumeration requires enterprise read access; preflight fails if Actions secret/variable access is unavailable in an enumerated organization. The displayed targets are the configuration boundary: organizations hidden from enumeration or added later are not configured automatically.

Before any setting is saved, the command sends an authenticated empty traces export to /v1/traces, using the selected protocol. It checks HTTP 200 and the bounded OTLP response, rejecting malformed responses and partial success with rejected spans. Warning-only partial success is accepted without exposing collector messages. This verifies route and credential acceptance, not actual span ingestion, logs, metrics, or connectivity from GitHub runners. The test has a 10-second deadline and a 64 KiB response limit, never follows redirects, and withholds response bodies and raw network errors. Sentry endpoint headers are normalized to x-sentry-auth before testing and saving.

The command preflights encryption keys, variable access, and selected memberships for all targets before writing. Organization setup also checks existing secret visibility and inspects every affected repository for partial endpoint/header secret overrides. It rejects a repository with only one of these secrets, including a repository endpoint variable paired with a repository header secret. Configure both repository secrets before retrying organization setup. Existing complete repository secret overrides remain in effect. Inspection requires access to the affected repositories’ secret metadata; all and private visibility additionally require a complete organization repository inventory. Use selected visibility to restrict inspection to explicitly named repositories. Changing an existing organization secret’s visibility or selected repositories requires a coordinated manual migration.

GitHub settings updates are not transactional. The command first replaces the endpoint secret with a nonempty invalid URL to disable default export without falling back to an endpoint variable. It then writes the header secret and protocol/metrics variables, and restores the validated endpoint last. A failed write can leave export disabled; rerun the command to recover. Earlier targets may already be configured, and the error identifies the failing target. Avoid concurrent settings changes and workflow starts while configuring defaults. Explicit workflow OTLP settings remain unchanged.

Multiple targets do not mean multiple default collectors: runtime defaults support one endpoint/header pair. Use the frontmatter endpoint list for multiple exporters.

For Google Cloud Telemetry, configure Google Workload Identity Federation instead of a static authorization header. gh-aw mints and exchanges a GitHub OIDC token in every span-emitting job, and automatically grants those jobs id-token: write. The workload identity principal needs permission to write telemetry and, when service-account is set, permission to impersonate that service account.

Set audience to the workload identity provider resource name (projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL/providers/PROVIDER). gh-aw derives the GitHub OIDC audience (https://iam.googleapis.com/...) and the Google STS audience (//iam.googleapis.com/...) from it, so either fully-qualified form is also accepted.

observability:
otlp:
endpoint:
- url: https://telemetry.googleapis.com
headers:
x-goog-user-project: ${{ vars.GCP_PROJECT_ID }}
workload-identity:
provider: google
audience: ${{ vars.GCP_WIF_PROVIDER }}
service-account: ${{ vars.GCP_SA_EMAIL }}

Configure mcp-servers when the agent needs to inspect telemetry that already exists in the backend. A typical Sentry read setup looks like this:

.github/workflows/telemetry-investigation.md
---
mcp-servers:
sentry:
command: "npx"
args: ["@sentry/mcp-server@0.33.0"]
allowed:
- whoami
- find_organizations
- find_projects
- get_trace_details
- search_events
- search_issues
env:
SENTRY_ACCESS_TOKEN: ${{ secrets.SENTRY_ACCESS_TOKEN }}
SENTRY_HOST: ${{ env.SENTRY_HOST || 'sentry.io' }}
---

observability.otlp.attributes attaches arbitrary key/value attributes to the job setup, job conclusion, and outcome summary spans:

observability:
otlp:
endpoint: ${{ secrets.OTLP_ENDPOINT }}
headers:
Authorization: ${{ secrets.OTLP_TOKEN }}
attributes:
deployment.environment: production
langfuse.session.id: "{{ gh-aw.episode.id }}"
langfuse.user.id: "{{ github.actor }}"
catalogue.version: "${{ github.aw.metadata.version }}"

Values are plain strings. Template expressions such as {{ gh-aw.episode.id }} or {{ github.actor }} are resolved from attributes already computed for the span. Empty values are omitted. Values of at least 4 characters are masked in runner logs; shorter values are not masked.

Whole-value references in the form ${{ github.aw.metadata.<key> }} resolve at compile time from the root workflow’s top-level metadata map. They work in either custom attribute map, including in shared imported OTLP configuration, and support simple metadata keys such as version, category, and owner. The reference must occupy the entire attribute value; embedded references, nested selectors, missing metadata keys, and metadata values containing GitHub Actions expression delimiters are compile-time errors. Metadata remains string-only, and only explicitly referenced values are exported.

observability.otlp.resource-attributes appends additional resource attributes to the standard gh-aw and GitHub resource attribute set:

observability:
otlp:
endpoint: ${{ secrets.OTLP_ENDPOINT }}
resource-attributes:
service.namespace: platform-automation
deployment.environment: ${{ github.ref_name }}
catalogue.category: "${{ github.aw.metadata.category }}"

Use static strings or GitHub Actions expressions. Do not use secrets.* or vars.* values in resource-attributes because resource attributes are exported to external observability backends and are not treated as secret values.

gh-aw emits a small set of built-in spans and trace artifacts once OTLP is configured.

These fields are a compatibility contract. gh-aw may add OpenTelemetry-standard aliases over time, but existing span names, environment variables, JSONL shape, and documented attributes remain available for dashboards and customer backends.

The built-in agent span uses OpenTelemetry GenAI semantic conventions for standard model, token, and finish-reason fields. gh-aw also adds a small number of gh-aw-specific fields.

By default, gh-aw keeps its existing GenAI names and span shape while adding current standard aliases. Set OTEL_SEMCONV_STABILITY_OPT_IN to gen_ai_v1 in workflow env: to use the current experimental GenAI span names and meanings; compatibility-only GenAI names are then omitted. The opt-in does not rename or remove gh-aw.* attributes or gh_aw.* metrics. The compatibility output remains the default during the staged migration.

gen_ai_v1 identifies the gh-aw opt-in contract; it does not imply a stable upstream GenAI release.

For deprecated and superseded notation, use the specification’s GenAI migration map. It maps legacy span names, attributes, provider values and token metrics to their replacements, including changed input-token semantics and span parentage. Upstream deprecation does not remove gh-aw compatibility support; migrate queries before enabling the opt-in.

You usually do not need to configure or memorize these built-in attributes. They are mainly useful when building backend queries, dashboards, or deeper debugging workflows. For the exhaustive built-in inventory, see the OpenTelemetry attribute reference.

Trace files and artifacts

When observability is enabled, trace data is also mirrored to local JSONL files and uploaded in the agent artifact:

  • otel.jsonl for spans emitted by gh-aw JavaScript helpers

Copilot CLI inherits the standard OpenTelemetry environment variables (OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES) and exports its own spans directly to the configured OTLP backend. Query them there, filtered by the github.run_id resource attribute (see ADR-34450).

See Artifacts for artifact download details.

Shared agentic workflow imports can emit their own OTLP spans alongside the built-in gh-aw telemetry. This lets third-party tools such as APM agents, data pipeline steps, and custom scanners attach their own measurements to the same distributed trace that gh-aw creates for each workflow run.

Quick start

The otlp.cjs helper provides a minimal, stable API. Use it in any steps: entry of a shared import:

logSpan is also re-exported unchanged from the public actions/setup/js/index.cjs entry point: const { logSpan } = require(process.env.RUNNER_TEMP + "/gh-aw/actions/index.cjs");. Existing direct imports from otlp.cjs remain supported.

.github/workflows/shared/my-tool.md
---
# My Tool — shared import that instruments its own telemetry
steps:
- name: My Tool — do work and record telemetry
id: my-tool-run
uses: actions/github-script@v8
with:
script: |
const path = require('path');
const otlp = require(path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions', 'otlp.cjs'));
const startMs = Date.now();
// ... do your tool's work here (e.g. const result = await myTool.run()) ...
const endMs = Date.now();
await otlp.logSpan('my-tool', {
'my-tool.version': '1.2.3',
'my-tool.items_processed': 42,
'my-tool.result': 'success',
}, { startMs, endMs });
---
My tool has run and its telemetry span will appear in the same distributed trace as the workflow run.

Import the shared file in any workflow alongside the OTLP configuration:

.github/workflows/my-workflow.md
---
on:
schedule: daily
engine: copilot
imports:
- shared/otlp.md
- shared/my-tool.md
---
# Daily Report
Run the daily report using my-tool results.

logSpan API

const path = require('path');
const otlp = require(path.join(process.env.RUNNER_TEMP, 'gh-aw', 'actions', 'otlp.cjs'));
await otlp.logSpan(toolName, attributes, options);
ParameterTypeDescription
toolNamestringLogical name for the tool, for example “my-scanner”. Used as service.name and as the span name prefix <toolName>.run.
attributesRecord<string, scalar>Domain-specific attributes emitted on the span. All env plumbing is handled automatically.
options.startMsnumberSpan start time in milliseconds since epoch. Defaults to Date.now().
options.endMsnumberSpan end time in milliseconds since epoch. Defaults to Date.now().
options.isErrorbooleanWhen true, sets the span status to ERROR.
options.errorMessagestringHuman-readable status message included when isError is true.
options.traceIdstringOverride trace ID. Defaults to GITHUB_AW_OTEL_TRACE_ID.
options.parentSpanIdstringOverride parent span ID. Defaults to GITHUB_AW_OTEL_PARENT_SPAN_ID.
options.endpointstringOverride OTLP endpoint. Defaults to OTEL_EXPORTER_OTLP_ENDPOINT.

Here, scalar means string, number, or boolean.

logSpan is non-fatal and never throws. Export failures are surfaced as console.warn. When GITHUB_AW_OTEL_TRACE_ID is missing or invalid, the call returns silently.

Recording an error span

await otlp.logSpan('my-scanner', {
'my-scanner.items_scanned': 100,
}, { isError: true, errorMessage: 'database connection timed out' });

Practical notes

  • Use your-tool. as a prefix for tool-specific attributes, for example my-tool.items_processed.
  • Use OpenTelemetry semantic conventions for cross-cutting concerns, for example db.system and http.response.status_code.
  • Avoid attribute names containing token, secret, password, key, or auth.

Attribute values are sanitized automatically before the payload is exported or mirrored. Matching secret-like keys are redacted, and very long string values are truncated. The same sanitization is applied to both OTLP export and the local JSONL mirror.

For debugging, every span emitted by logSpan is appended as a sanitized JSON line to /tmp/gh-aw/otel.jsonl, even when OTEL_EXPORTER_OTLP_ENDPOINT is not set. This file is included in the agent artifact when OTLP is enabled. Copilot CLI spans are not mirrored to a local file; they are exported directly to the configured OTLP backend and should be queried there.

Terminal window
# Download agent artifacts for a run
gh aw logs <run-id> --artifacts agent
# Inspect spans emitted by your tool
cat otel.jsonl | jq 'select(.resourceSpans[].scopeSpans[].spans[].name | startswith("my-tool"))'
Advanced: low-level API

For full control, use the lower-level helpers from send_otlp_span.cjs directly. The key environment variables set by the actions/setup step are:

VariableDescription
GITHUB_AW_OTEL_TRACE_ID32-character hex trace ID shared by all spans in this run.
GITHUB_AW_OTEL_PARENT_SPAN_ID16-character hex span ID of the job setup span. Use it as parentSpanId to nest spans under it.
OTEL_EXPORTER_OTLP_ENDPOINTOTLP collector base URL.
OTEL_EXPORTER_OTLP_HEADERSComma-separated key=value authentication headers.
const {
buildAttr, buildOTLPPayload, sendOTLPSpan,
generateSpanId, SPAN_KIND_CLIENT,
} = require('/tmp/gh-aw/actions/send_otlp_span.cjs');
const traceId = process.env.GITHUB_AW_OTEL_TRACE_ID;
const parentSpanId = process.env.GITHUB_AW_OTEL_PARENT_SPAN_ID;
const endpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
const setupSpanId = generateSpanId();
const querySpanId = generateSpanId();
await sendOTLPSpan(endpoint, buildOTLPPayload({
traceId, spanId: setupSpanId, parentSpanId,
spanName: 'my-tool.setup', startMs: t0, endMs: t1,
serviceName: 'my-tool', kind: SPAN_KIND_CLIENT,
attributes: [buildAttr('my-tool.phase', 'setup')],
resourceAttributes: [buildAttr('my-tool.version', '1.2.3')],
}));
await sendOTLPSpan(endpoint, buildOTLPPayload({
traceId, spanId: querySpanId, parentSpanId: setupSpanId,
spanName: 'my-tool.query', startMs: t1, endMs: t2,
serviceName: 'my-tool', kind: SPAN_KIND_CLIENT,
attributes: [buildAttr('my-tool.query.rows', 1234)],
}));

Metrics are enabled by default for workflows with OTLP configured. Set GH_AW_OTEL_METRICS to the literal value false in workflow env: to opt out:

env:
GH_AW_OTEL_METRICS: "false"

The compiler injects ${{ vars.GH_AW_OTEL_METRICS || 'true' }} unless the workflow defines GH_AW_OTEL_METRICS itself. To manage the Actions variable by repository, organization, or enterprise scope, use gh aw env get and gh aw env update with default_otel_metrics: false; deleting the variable restores the default-on behavior. Only the literal value true enables metrics. When enabled, metrics are sent to /v1/metrics as OTLP/HTTP JSON by default, or as protobuf when OTEL_EXPORTER_OTLP_METRICS_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL selects http/protobuf (see Protobuf encoding), using the configured OTLP endpoints and their per-endpoint headers, and are mirrored to /tmp/gh-aw/otel-metrics.jsonl before export. The unified artifact includes the metrics mirror only when the effective runtime value is true. It contains metrics recorded in the agent job before artifact upload, including that job’s built-in metrics; built-in metrics from other jobs are exported at post-job time and are not included in an artifact.

The GenAI input counter includes cache-read and cache-write tokens exactly once when the source’s cache semantics are known. Data points include gen_ai.operation.name, gen_ai.provider.name, and gen_ai.token.modality (unknown when modality is unavailable); zero or unavailable token values are omitted. gen_ai.invoke_agent.duration identifies the in-process agent invocation.

Without the GenAI opt-in, gen_ai.client.token.usage with gen_ai.token.type is retained alongside the standard inference counters. OpenTelemetry removed this compatibility metric from its GenAI conventions; gh-aw does not deprecate it in this version. With the opt-in, that compatibility metric is omitted and its gh_aw.tokens.* aliases remain without gen_ai.token.type.

Built-in metrics are emitted at job completion. Counters and histograms use delta temporality; durations and counts are job-level measurements. Unless noted, built-in metrics include gh-aw.job.name and gh-aw.workflow.name when available. Run metrics use the run conclusion for cicd.pipeline.task.run.result. The gh_aw.job.errors unit is {job}, while the gh_aw.run.errors compatibility metric uses {run}.

MetricType and unitAttributes and emission condition
gh_aw.job.durationHistogram, scicd.pipeline.task.run.result (job result), gh-aw.job.name, gh-aw.workflow.name, and (when known) gh-aw.engine.id and gen_ai.request.model; emitted for each completed job.
gh_aw.job.errorsCounter, {job}cicd.pipeline.task.run.result (job result), gh-aw.job.name, and gh-aw.workflow.name; emitted for failure, timed_out, or cancelled jobs.
gen_ai.client.inference.usage.input_tokens, gen_ai.client.inference.usage.output_tokens, gen_ai.client.inference.usage.cache_read.input_tokens, gen_ai.client.inference.usage.cache_write.input_tokensCounter, {token}gen_ai.operation.name, gen_ai.provider.name, and gen_ai.token.modality (unknown when unavailable); emitted for available, positive token counts. The input count includes cache-read and cache-write tokens once when cache semantics are known.
gen_ai.client.token.usageCompatibility counter, {token}Emitted by default with gen_ai.token.type set to input, output, input_cache_read, or input_cache_write; omitted with the GenAI opt-in. This superseded metric is not deprecated by this version.
gen_ai.invoke_agent.durationHistogram, sgen_ai.operation.name=invoke_agent; emitted for the in-process agent invocation.
gh_aw.agent.turnsHistogram, {turn}Job and workflow names; emitted when a non-negative agent turn count is available.
gh_aw.tool_callsCounter, {call}gh-aw.tool.status is ok or error; emitted for nonzero tool-call counts.
gh_aw.ai.credits.limit_exceededCounter, {event}Job and workflow names; emitted when an AI-credit limit is exceeded.
gh_aw.ai.credits.rate_limit_errorsCounter, {event}Job and workflow names; emitted when an AI-credit rate-limit error occurs.
gh_aw.workflow.output.itemsCounter, {item}gh-aw.safe_output.type; emitted for each output type recorded by the workflow.

The exporter also emits these compatibility names:

Compatibility metricCorresponding metric
gh_aw.run.durationgh_aw.job.duration (uses the run conclusion for cicd.pipeline.task.run.result)
gh_aw.run.errorsgh_aw.job.errors (unit {run}; emitted according to the run conclusion for cicd.pipeline.task.run.result)
gh_aw.tokens.inputInput token count
gh_aw.tokens.outputOutput token count
gh_aw.tokens.cache_readCache-read token count
gh_aw.tokens.cache_writeCache-write token count
gh_aw.safe_outputsgh_aw.workflow.output.items

The gh_aw.run.* names remain job-level measurements, not workflow-wide aggregates. Query a canonical metric or its compatibility name, not both, to avoid double counting.

gh_aw.otlp.export.failures is a monotonic delta counter with unit {failure}. It counts endpoint exports that fail after bounded retries, including failures already observed before the metrics export. Its attributes use fixed classes gh-aw.otlp.endpoint.class=configured and gh-aw.otlp.failure.class=export; bounded job and workflow names may also be present. The exporter reports unreported failures to endpoints that successfully receive metrics and tracks reported failures to avoid counting them again. If no endpoint succeeds, the failure metric is still mirrored locally, but cannot be delivered to a collector. Export failures do not fail the workflow.

Metric resources include standard service attributes and may include only these additional attributes from OTEL_RESOURCE_ATTRIBUTES: gh-aw.repository, gh-aw.engine.id, gh-aw.workflow.name, github.event_name, and github.job. Additional values must be strings no longer than 128 characters; other resource attributes, including run IDs and other per-run identifiers, are excluded. When trace context is available, data points include trace-linked exemplars.

Custom instrumentation can use logMetric(name, value, options) from otlp.cjs:

const { logMetric } = require(path.join(process.env.RUNNER_TEMP, "gh-aw", "actions", "otlp.cjs"));
await logMetric("my-tool.items_processed", 42, {
type: "counter",
unit: "{item}",
attributes: { "my-tool.result": "ok" },
});

logMetric() accepts the following parameters:

ParameterDescription and validation
nameRequired OpenTelemetry instrument name: a letter followed by up to 254 letters, digits, _, ., -, or /.
valueRequired finite number. Counter values must be non-negative; gauges and histogram observations may be negative.
options.typegauge (default), counter, or histogram. Counters are monotonic delta sums; each histogram call records one observation.
options.unitOptional printable ASCII string of at most 63 characters.
options.descriptionOptional string of at most 1023 characters.
options.attributesOptional map of at most eight string, finite-number, or boolean values. Keys and string values are limited to 128 characters.
options.bucketsOptional finite, distinct explicit histogram bounds, sorted before export. Defaults to [1, 5, 15, 30, 60, 120, 300, 600, 1800, 3600]; ignored for other types.

An attribute key matching a high-cardinality pattern (including run, job, trace, span, commit, user, actor, issue, pull-request, conversation, or URL identifiers) is rejected; do not encode per-run identifiers in other attribute values. Calls are limited to 100 unique series per process, where a series is identified by its name, type, unit, description, attributes, and (for histograms) buckets. Invalid calls are dropped with a warning and do not throw to the caller.

Custom metrics are buffered for up to one second before export. Pending calls for the same series are merged: gauges keep the latest value, counters sum their values, and histograms combine their observations and bucket counts. Before a job exports its built-in metrics, it flushes any pending custom metrics.

Metric names, units, descriptions, and attribute values containing known credential formats or configured secret values cause the call to be dropped. Metric fields are also screened and redacted before they are mirrored or exported. Export and mirror failures are non-fatal.