Skip to content

feat: generate OTel-aligned telemetry configuration from extended spec.telemetry - #281

Merged
edenreich merged 3 commits into
mainfrom
feat/wip-280
Jul 14, 2026
Merged

edenreich merged 3 commits into
mainfrom
feat/wip-280

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Extends spec.telemetry from a single enabled boolean into a structured, OpenTelemetry-aligned configuration and generates the matching SDK environment variables into the scaffolded .env.example.

Closes #280.

What changed

spec.telemetry now accepts declarative traces / metrics exporter blocks:

telemetry:
  enabled: true
  traces:
    exporter:
      otlp:
        endpoint: http://localhost:4318
        protocol: http/protobuf
  metrics:
    exporter:
      prometheus:
        port: 9464

internal/templates/telemetry_env.go maps these to the standard OTEL_* SDK variables, with a language-specific prefix:

  • Go - emits A2A_OTEL_*. The Go ADK nests its whole server config under the A2A_ prefix (config.Config.A2A is env:",prefix=A2A_") and its OTelConfig carries no prefix of its own, so A2A_OTEL_* is what actually reaches the exporters. Uses the shared OTEL_EXPORTER_OTLP_{ENDPOINT,PROTOCOL} pair (the Go ADK has no per-signal OTLP fields) and supports the Prometheus pull exporter.
  • TypeScript - emits bare OTEL_*. The TS ADK hands these straight to the OpenTelemetry Node SDK, which reads unprefixed names from process.env; prefixing them would silently disable telemetry. Supports per-signal OTLP endpoints and collapses to the shared pair when both signals target the same collector.
  • Rust - spec.telemetry is not supported and is ignored; the validator warns.

Generated .env.example

  # Go                                     # TypeScript
  A2A_TELEMETRY_ENABLE=true                TELEMETRY_ENABLE=true
  A2A_OTEL_TRACES_EXPORTER=otlp            OTEL_TRACES_EXPORTER=otlp
  A2A_OTEL_METRICS_EXPORTER=prometheus     OTEL_METRICS_EXPORTER=otlp
  A2A_OTEL_EXPORTER_OTLP_ENDPOINT=...      OTEL_EXPORTER_OTLP_ENDPOINT=...
  A2A_OTEL_EXPORTER_OTLP_PROTOCOL=...      OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
  A2A_OTEL_EXPORTER_PROMETHEUS_PORT=9464

Also included

  • Schema + generated types extended for the new traces / metrics exporter blocks. The committed schema.json stays byte-identical to upstream v0.19.0, so verify-schema passes.
  • Non-fatal validator warnings for unsupported combinations: Rust (telemetry ignored) and TypeScript + Prometheus pull.
  • Go ADK pin bumped to v0.23.0 (go.mod.tmpl + built-in vendor pin in vendor.go).
  • telemetry.go.tmpl / main.go.tmpl reconciled so the top-level envconfig.Process reads A2A_OTEL_* (dropped a stray overlay that re-read bare OTEL_*).
  • New unit tests (telemetry_env_test.go) lock in the Go-A2A_ vs TS-bare contract.
  • Regression coverage via examples/{go,typescript}-agent-telemetry.yaml.

Notes / limitations

  • The A2A_ prefix is deliberately Go-only; the TS OTel Node SDK requires bare OTEL_*.
  • On Go, a manifest pushing both traces and metrics over OTLP to different endpoints can't be expressed (the Go ADK has one shared OTLP endpoint); Go emits the traces endpoint.

Verification

  • go build ./..., go vet ./..., go test ./... - all green
  • task verify-schema - no drift from upstream v0.19.0
  • task examples:test - all manifests valid, including both telemetry examples
  • CI green on the branch

@edenreich

Copy link
Copy Markdown
Contributor

@claude Can you finalize this PR?

I want the OTLP environment variables to be generated with the A2A_* prefix!

Use /ponytail:ponytail

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 22m 24s —— View job


Finalized: A2A_*-prefixed OTLP telemetry env vars

Picked up the partial work for #280 and finalized it. (/ponytail:ponytail isn't available in this environment, so I proceeded directly.)

Todo:

  • Analyze the branch and the request
  • Trace the Go + TypeScript ADK env-var contracts
  • telemetry_env.go: emit A2A_OTEL_* for Go, bare OTEL_* for TS
  • main.go.tmpl: drop the bare-OTEL_* overlay (top-level Process already loads A2A_OTEL_*)
  • Update .env.example, telemetry.go.tmpl, and the Go example comments to match
  • Fix the pre-existing, unrelated TestGenerator_VendorWiring failure the WIP left behind
  • Build, go vet, full go test ./..., and schema-drift check all green
  • Commit to the branch (4d1f209)

What changed

The key insight (traced through [email protected] and @inference-gateway/[email protected]):

  • Go: the generated config.Config nests the ADK's server config under A2A serverConfig.Config \env:",prefix=A2A_"`, and the ADK's OTelConfigfield has **no** prefix of its own -> the top-levelenvconfig.Processalready readsA2A_OTEL_, and the exporters are built explicitly from that struct (ResolveTelemetry()->WithEndpointURL(...)). So A2A_OTEL_genuinely reaches the exporters. The WIP's extraenvconfig.Process(ctx, &cfg.A2A.OTelConfig)overlay re-read **bare**OTEL_*` and overrode that - removed.
  • TypeScript: createTelemetryProvider hands the OTLP vars to the OpenTelemetry Node SDK, which reads bare OTEL_* from process.env. Prefixing those would silently disable TS telemetry, so the prefix is Go-only (TS keeps TELEMETRY_ENABLE + bare OTEL_*).

Generated .env.example now (verified by rendering the real templates):

  # Go                                    # TypeScript (unchanged, intentional)
  A2A_TELEMETRY_ENABLE=true               TELEMETRY_ENABLE=true
- OTEL_TRACES_EXPORTER=otlp               OTEL_TRACES_EXPORTER=otlp
+ A2A_OTEL_TRACES_EXPORTER=otlp           OTEL_METRICS_EXPORTER=otlp
+ A2A_OTEL_METRICS_EXPORTER=prometheus    OTEL_EXPORTER_OTLP_ENDPOINT=...
+ A2A_OTEL_EXPORTER_OTLP_ENDPOINT=...     OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
+ A2A_OTEL_EXPORTER_OTLP_PROTOCOL=...
+ A2A_OTEL_EXPORTER_PROMETHEUS_PORT=9464

Also fixed / added:

  • A correctness bug the prefix surfaced: the Go ADK's OTelConfig has only the shared OTEL_EXPORTER_OTLP_{ENDPOINT,PROTOCOL} fields (no per-signal variants), but the WIP emitted ..._TRACES_ENDPOINT for the traces-otlp + metrics-prometheus example. Bare, that was masked by the SDK's env fallback; A2A_-prefixed it would be read by nothing and the endpoint would be lost. Go now always emits the shared pair.
  • Synced the vendor built-in ADK pin (vendor.go) to v0.23.0 and fixed the pre-existing TestGenerator_VendorWiring failure (the WIP bumped go.mod.tmpl to v0.23.0 but left the map + test asserting v0.22.0).
  • New tests in telemetry_env_test.go lock in the Go-A2A_ vs TS-bare contract.
  • Confirmed the committed schema.json is byte-identical to upstream v0.19.0, so verify-schema passes.

Notes / limitations

  • The A2A_ prefix is deliberately Go-only - the TS OTel Node SDK requires bare OTEL_*. If you want it applied to TS as well, the TS ADK's telemetry provider would need to read the prefixed names first.
  • On Go, a manifest that pushes both traces and metrics over OTLP to different endpoints can't be expressed (the Go ADK has one shared OTLP endpoint); Go emits the traces endpoint. A validator warning for that combination could be a small follow-up.
  • I verified the real generated output by executing the .env.example/main.go templates through the engine and running the full test + schema-drift checks; I couldn't run task examples:generate directly here because executing the freshly built binary needs interactive approval in this sandbox.
  • branch feat/wip-280

The Go ADK nests its whole server config under the A2A_ prefix and its
OTelConfig carries no prefix of its own, so the OpenTelemetry SDK settings
are read as A2A_OTEL_*. Emit the exporter variables with that prefix for Go
and drop the main.go overlay that re-read the bare OTEL_* names. TypeScript
keeps bare OTEL_* since the OpenTelemetry Node SDK reads process.env directly.

Go now always emits the shared OTEL_EXPORTER_OTLP_{ENDPOINT,PROTOCOL} pair
(the Go ADK has no per-signal fields). Sync the vendor built-in ADK pin and
the stale VendorWiring test to v0.23.0, and cover the prefix contract.
Comment thread internal/templates/telemetry_env.go Resolved
Comment thread internal/templates/telemetry_env.go Resolved
@edenreich
edenreich marked this pull request as ready for review July 14, 2026 23:33
@edenreich
edenreich requested a review from a team as a code owner July 14, 2026 23:33
@edenreich

Copy link
Copy Markdown
Contributor

@claude So is it ready for merge now? can you update the title and the body?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 4m 55s —— View job


Ready for merge ✅ - title & body updated

Yes, this is ready to merge. Everything is green and the earlier review suggestions were already folded in (8ccabbd - comment cleanups by you).

  • Review the branch state and the applied review suggestions
  • Verify build, go vet, and full test suite are green
  • Confirm schema-drift check passes
  • Assess merge readiness
  • Update PR title and body

Merge readiness

Check Result
CI (both runs on 8ccabbd) ✅ passing
go build ./... / go vet ./... ✅ clean
go test ./... ✅ all packages pass
task verify-schema ✅ no drift from upstream v0.19.0
task examples:test (all manifests) ✅ valid, incl. both telemetry examples
Review suggestions ✅ applied in 8ccabbd

Title
feat: generate OTel-aligned telemetry configuration from extended spec.telemetry
(conventional-commit feat: so semantic-release cuts a minor bump; dropped the wip:/(run did not finish))

Body rewritten to a proper description: summary, Closes #280, the Go A2A_OTEL_* vs TS bare OTEL_* contract, the generated .env.example, schema/validator/vendor changes, known limitations, and the verification checklist.

Note: the branch is still named feat/wip-280, but that's cosmetic - a squash merge uses the PR title. I can't perform the merge itself (bot can't approve or merge PRs), so the final merge is yours to click.
• branch feat/wip-280

@inference-gateway-maintainer inference-gateway-maintainer Bot changed the title wip: [FEATURE] Generate OTel-aligned telemetry configuration from extended spec.telemetry (run did not finish) feat: generate OTel-aligned telemetry configuration from extended spec.telemetry Jul 14, 2026
@edenreich

Copy link
Copy Markdown
Contributor

@claude Can you create the follow-up for the operator Agents CRDs ?

@edenreich
edenreich merged commit 47c5b3d into main Jul 14, 2026
1 check passed
@edenreich
edenreich deleted the feat/wip-280 branch July 14, 2026 23:42
@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 4m 20s —— View job


Follow-up created: OTel-aligned telemetry in the operator Agent CRD

➡️ inference-gateway/operator#153 - feat: support OTel-aligned telemetry (traces/metrics exporters) in Agent CRD

The gap it tracks

PR #281 extended the ADL spec.telemetry into an OTel-aligned shape (traces.exporter.otlp, metrics.exporter.{otlp,prometheus}) and now generates A2A_OTEL_* env vars into .env.example. The operator hasn't caught up:

Where Current state
api/v1alpha1/gateway_types.go - TelemetrySpec (reused by the Agent CRD) only Enabled + Metrics{Enabled, Port}
internal/controller/agent_controller.go (~L394) only injects TELEMETRY_ENABLED

So agents deployed via the operator can't express or receive the new exporter configuration.

Scope captured in the issue

  • Extend TelemetrySpec/MetricsSpec with the traces/metrics exporter blocks (ADL v0.19.0)
  • Regenerate CRDs + deepcopy (make manifests generate)
  • Emit the Go-ADK A2A_OTEL_* vars from the controller, mirroring adl-cli's telemetry_env.go
  • Reconcile TELEMETRY_ENABLED (operator) vs A2A_TELEMETRY_ENABLE (Go ADK) enable-var naming
  • Update samples + controller tests

No code changes here - this was a tracking issue only, filed in the operator repo where the Agent CRD lives.

inference-gateway-releaser Bot added a commit that referenced this pull request Jul 14, 2026
## [0.48.0](v0.47.1...v0.48.0) (2026-07-14)

### ✨ Features

* bump Go version to 1.26.4 ([#279](#279)) ([4945a28](4945a28))
* generate OTel-aligned telemetry configuration from extended spec.telemetry ([#281](#281)) ([47c5b3d](47c5b3d))

### 🐛 Bug Fixes

* quote boolean and numeric env values in compose template ([#267](#267)) ([6198824](6198824))

### 📚 Documentation

* add missing CLI flags to README generate/init flag tables ([#275](#275)) ([db0a842](db0a842))
* document spec.telemetry OpenTelemetry generation ([#277](#277)) ([bd75c08](bd75c08)), references [#259](#259)
* fix project structure diagrams and universal files section ([#274](#274)) ([17bad1b](17bad1b)), closes [#272](#272)
* mark Service Injection code examples as illustrative with template references ([#278](#278)) ([69b9806](69b9806))
* remove missing example ref, document all examples ([#273](#273)) ([4e30aff](4e30aff)), closes [#268](#268)
* update Template System and Architecture section with accurate Context struct and file mapping ([#276](#276)) ([352d084](352d084))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.48.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Generate OTel-aligned telemetry configuration from extended spec.telemetry

1 participant