Skip to content

feat: Add built-in OTLP metrics emission for per-job run observability #78427

Done

Description

@eedorenko

Summary

Add automatic OTLP metrics emission capability to gh-aw so operators can observe
per-job performance (duration, token usage, tool call rates) without
writing custom instrumentation. Extends the existing OTLP traces pipeline
to emit metrics via /v1/metrics on the same endpoint.

Scope: This issue covers the metric emission plumbing only — the OTLP
transport, the logMetric() public API, and a minimal set of built-in
per-job metrics to validate the pipeline. A follow-up issue will propose
the full canonical list of built-in metrics and default dashboard structure.

Use Case

An agentic factory with 10+ concurrent executor runs needs aggregate visibility:

  • How long are runs taking? (gh_aw.run.duration histogram)
  • Which runs fail? (gh_aw.run.errors counter)
  • Token spend per workflow? (gh_aw.tokens.input/output counters)

Without metrics, operators must parse JSONL logs or trace data for aggregation.

Expected Behavior

When GH_AW_OTEL_METRICS=true is set in a workflow:

  1. At job conclusion, gh-aw automatically emits the following built-in metrics
    via OTLP/HTTP to the same endpoint(s) configured for traces:

    Metric Type Unit Description
    gh_aw.run.duration Histogram s Wall-clock job duration
    gh_aw.run.errors Counter {run} Emitted on failure / timed_out only
    gh_aw.tokens.input Counter {token} LLM input tokens
    gh_aw.tokens.output Counter {token} LLM output tokens
    gh_aw.tool_calls Counter {call} Tool executions, by gh-aw.tool.status
    gh_aw.safe_outputs Counter {item} Safe-output items, by gh-aw.safe_output.type

    See the full spec additions (§11.5 + §12.6, v0.7.0):
    https://github.com/eedorenko/gh-aw/pull/1/changes#diff-44f20ea27777b62159e5b64cb7d66081d566f6f3c41d6840553c6d39772a975f

  2. Metrics are mirrored to /tmp/gh-aw/otel-metrics.jsonl before remote export

  3. A logMetric(name, value, options) public API is available for custom metrics

  4. No metrics are emitted when the flag is absent (fully opt-in)

Implementation (complete — available in fork)

A working implementation exists in eedorenko/gh-aw PR #1. See that PR for
the full diff. Summary of changes:

New file: actions/setup/js/otlp_metrics.cjs

  • buildOTLPMetric(opts) — OTLP/JSON builder for counter, gauge, histogram
  • buildBuiltinRunMetrics(conclusionData) — emits the 6 built-in metrics
  • sendOTLPMetrics(payload, endpointOverride) — mirrors first, then fan-out
  • logMetric(name, value, opts) — non-fatal public API

Modified: actions/setup/js/otlp.cjs, index.cjs, index.test.cjs

  • Exports logMetric alongside existing logSpan

Go: pkg/constants/job_constants.go

  • Adds OtelMetricsJsonlFilename constant

Go: pkg/workflow/compiler_yaml_post_agent.go

  • Adds metrics JSONL to artifact recovery paths when OTLP is configured

Tests: 8 golden file updates + new unit tests (otlp_metrics.test.cjs)

Docs: docs/src/content/docs/reference/open-telemetry.mdx

  • Documents logMetric() API and built-in metrics flag

Spec: specs/otel-observability-spec.md

  • Adds §11.5 (built-in job metrics) and §12.6 (logMetric API), bumps to v0.7.0

Step-by-Step Agentic Plan

  1. Review fork PR eedorenko/gh-aw#1 diff
  2. Run existing test suite: npm test in actions/setup/
  3. Add any missing test cases for otlp_metrics.cjs edge cases
  4. Verify golden files reflect the new artifact path
  5. Update spec per §11.5 and §12.6 as described above
  6. Merge PR, link to this issue

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions