Skip to content

fix: propagate agent name/version to otel service.name - #285

Merged
edenreich merged 2 commits into
mainfrom
fix/issue-284-20260715-1247
Jul 15, 2026
Merged

edenreich merged 2 commits into
mainfrom
fix/issue-284-20260715-1247

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Summary

Generated Go main.go declared build-time AgentName / Version ldflags vars but never assigned them into the ADK config, so every telemetry-enabled agent exported OTLP traces and metrics with an empty service.name / service.version resource attribute (spans unattributable in Jaeger, infer traces, etc.).

The ADK builds its OTel resource from cfg.AgentName / cfg.AgentVersion (server/otel/otel.go):

res := sdkresource.NewWithAttributes(
    semconv.SchemaURL,
    semconv.ServiceName(cfg.AgentName),       // service.name
    semconv.ServiceVersion(cfg.AgentVersion), // service.version
)

Both fields are documented as // Build-time metadata, not configurable via environment (no env tag), so envconfig never populates them. Per the OpenTelemetry resource docs, service.name must be set explicitly (SDK default is unknown_service) - and the ADK overrides even that default with an empty string.

Change

internal/templates/languages/go/main.go.tmpl: after envconfig.Process, propagate the build-time metadata into the config before anything reads it:

cfg.A2A.AgentName = AgentName
cfg.A2A.AgentVersion = Version

Unconditional (not gated on telemetry) so cfg.A2A always reflects the real build metadata. The TypeScript path already did this correctly (serviceName: card.name); Rust does not support telemetry, so no change there.

Tests

internal/generator/telemetry_test.go: extended TestGenerator_TelemetryEnabled_EndToEnd to assert the rendered main.go propagates both fields into cfg.A2A.

Notes

The optional ADK-side fallback (merge resource.Default() so OTEL_SERVICE_NAME works) remains a separate ADK concern, as noted in the issue.

Closes #284

Comment thread internal/generator/telemetry_test.go Resolved
@edenreich
edenreich merged commit 108edd7 into main Jul 15, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-284-20260715-1247 branch July 15, 2026 13:02
inference-gateway-releaser Bot added a commit that referenced this pull request Jul 15, 2026
## [0.48.4](v0.48.3...v0.48.4) (2026-07-15)

### 🐛 Bug Fixes

* propagate agent name/version to otel service.name ([#285](#285)) ([108edd7](108edd7))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.48.4 🎉

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.

[BUG] Generated main.go does not propagate build-time AgentName/AgentVersion to config - OTel service.name is empty

1 participant