Repository navigation
fix(telemetry): a service.name in OTEL_RESOURCE_ATTRIBUTES no longer renames a component (#1562) - #1564
Merged
Conversation
…renames a component (#1562) The four resource builders (common/telemetry/setup, mesh-dns, the proxy supervisor, the prober) passed WithAttributes(service.name) before WithFromEnv(). The SDK merges resource options in order and the later one wins, so a service.name in OTEL_RESOURCE_ATTRIBUTES replaced the component's own. A test per builder showed it: service.name came back "other". The component's name now goes after WithFromEnv, through one shared option (common/telemetry/servicename). Every other attribute of the variable is kept. OTEL_SERVICE_NAME still overrides the name, as it did before: naming the service is all that variable does, and the SDK ranks it above OTEL_RESOURCE_ATTRIBUTES. The supervisor's builder moves into its own function so a test can read the resource; it builds the same thing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation consistently updates every affected builder and includes comprehensive regression coverage.
0 open findings
What changed in this PR
Prevents OTEL_RESOURCE_ATTRIBUTES from overriding component-owned telemetry service names while preserving explicit OTEL_SERVICE_NAME overrides.
Changes:
- Adds a shared service-name resource option.
- Updates all four OTel resource builders.
- Adds regression tests and configuration documentation.
| File | Description |
|---|---|
common/telemetry/servicename/servicename.go |
Implements service-name precedence. |
common/telemetry/servicename/servicename_test.go |
Tests environment precedence. |
common/telemetry/servicename/BUILD.bazel |
Defines package targets. |
common/telemetry/setup/setup.go |
Applies the shared option. |
common/telemetry/setup/resource_test.go |
Tests shared setup behavior. |
common/telemetry/setup/BUILD.bazel |
Adds dependencies and test source. |
agent/internal/meshdns/telemetry.go |
Protects mesh-DNS service name. |
agent/internal/meshdns/telemetry_test.go |
Adds mesh-DNS regression coverage. |
agent/internal/meshdns/BUILD.bazel |
Wires package and test dependencies. |
agent/internal/proxy/hotrestart/telemetry.go |
Extracts and updates resource construction. |
agent/internal/proxy/hotrestart/telemetry_test.go |
Adds supervisor regression coverage. |
agent/internal/proxy/hotrestart/BUILD.bazel |
Wires package and test dependencies. |
prober/internal/prober/prober.go |
Protects the prober service name. |
prober/internal/prober/resource_test.go |
Adds prober regression coverage. |
prober/internal/prober/BUILD.bazel |
Registers the package and test changes. |
docs/configuration.md |
Documents service-name precedence. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 9, 2026
This was referenced Oct 9, 2026
bpalermo
added a commit
that referenced
this pull request
Oct 9, 2026
…er replaces the build's, and the four resource builders are one (#1575, #1576) (#1592) common/telemetry/serviceresource builds the OpenTelemetry resource of every Go component. common/telemetry/setup (agent, registrar, controller, edge control plane), mesh-dns, the proxy supervisor and the prober each built theirs from a copy of the same option list; they call the shared builder now. service.version is stated after the environment is read, so the build's version wins over a service.version in OTEL_RESOURCE_ATTRIBUTES. Nothing overrides it: there is no OTEL_SERVICE_VERSION convention. OTEL_SERVICE_NAME still overrides the name, as #1564 left it, and every other attribute in the variable is kept. The one difference between the builders is an option: the prober passes WithoutHost, because it is not hostNetwork and its host.name is the pod name (#1041). The new package imports the OTel SDK's resource package, semconv and servicename, which every one of these binaries already linked. Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1562.
What was wrong
The issue's premise was inferred from the code. It is true, for all four resource builders: with
OTEL_RESOURCE_ATTRIBUTES=service.name=other,k8s.node.name=n1each one built a resource whoseservice.namewasother.service.namebeforecommon/telemetry/setup(agent, registrar, controller, edge control plane)otheragent/internal/meshdnsotheraether-mesh-dnsagent/internal/proxy/hotrestartotheraether-proxy-supervisorprober/internal/proberotheraether-proberThe cause is the one the issue names:
resource.Newmerges its options in order and the later one wins, and each builder passedWithAttributes(service.name=…)beforeWithFromEnv().Nothing shipped is affected. No chart puts a
service.namein the environment of a Go component; the edge Envoy container does, and Envoy is not one of these builders.The change
common/telemetry/servicename(new, 51 lines):servicename.Option(name)is a resource option that sets the component'sservice.name. Each builder passes it afterWithFromEnv(). It imports only the OTel SDK'sresourcepackage andsemconv, which every one of these binaries already links, so no module is added anywhere.OTEL_RESOURCE_ATTRIBUTESis kept; the tests assertk8s.node.name=n1survives in every case.service.versionis left where it was (beforeWithFromEnv), so this change is about the name only.NewTelemetry; it moves intonewTelemetryResourceso a test can read it. Same options, same order.docs/configuration.md,otelsection: who names a component, and how to rename one on purpose.OTEL_SERVICE_NAMEIt keeps doing what it did before this change: it overrides the component's name. Two reasons. Naming the service is the only thing that variable does, so setting it on a container is a decision, unlike a
service.namethat rides along in an attribute string copied from another container. And the SDK itself ranks it aboveOTEL_RESOURCE_ATTRIBUTES. A blank value counts as unset, as in the SDK.So the order is now:
OTEL_SERVICE_NAME, then the component's own name.service.nameinOTEL_RESOURCE_ATTRIBUTESno longer takes part.Tests
TestResourceServiceNamein each of the four packages, andTestOptionin the new one. Seen red against the unchanged builders (the supervisor's after the extraction only, which changes no behaviour):The same two cases failed in all four packages. The
OTEL_SERVICE_NAMEcases passed before and after: they pin behaviour that is kept.Mutations, each reverted:
OTEL_SERVICE_NAME(the component's name always wins)OTEL_SERVICE_NAMEis not trimmedWithFromEnv()in each builderAlso run:
bazel testand--config=raceon the five test targets,//agent/cmd/mesh-dns:deps_test,//agent/cmd/proxy-supervisor:deps_test, the threeimage_testtargets,scripts/check-mesh-dns-deps.sh,scripts/check-proxy-supervisor-deps.sh, lint on the touched packages,make format-check.No chart change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr