Repository navigation
fix(telemetry): a service.version in OTEL_RESOURCE_ATTRIBUTES no longer replaces the build's, and the four resource builders are one (#1575, #1576) - #1592
Merged
Conversation
…er replaces the build's, and the four resource builders are one (#1575, #1576) 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. 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 shared builder preserves component-specific behavior and is covered by focused regression tests.
0 open findings
What changed in this PR
Centralizes OpenTelemetry resource construction and ensures environment attributes cannot override the binary’s build version.
Changes:
- Adds the shared
serviceresourcebuilder with optional host detection. - Migrates all four resource-building paths to it.
- Adds regression tests and documents attribute precedence.
| File | Description |
|---|---|
common/telemetry/serviceresource/serviceresource.go |
Implements the shared resource builder. |
common/telemetry/serviceresource/serviceresource_test.go |
Tests identity precedence and detectors. |
common/telemetry/serviceresource/BUILD.bazel |
Defines new Go targets. |
common/telemetry/setup/setup.go |
Uses the shared builder. |
common/telemetry/setup/resource_test.go |
Tests version and host attributes. |
common/telemetry/setup/BUILD.bazel |
Updates builder dependency. |
agent/internal/meshdns/telemetry.go |
Migrates mesh-DNS resource creation. |
agent/internal/meshdns/telemetry_test.go |
Adds mesh-DNS regressions. |
agent/internal/meshdns/BUILD.bazel |
Updates telemetry dependency. |
agent/internal/proxy/hotrestart/telemetry.go |
Migrates supervisor resource creation. |
agent/internal/proxy/hotrestart/telemetry_test.go |
Adds supervisor regressions. |
agent/internal/proxy/hotrestart/BUILD.bazel |
Updates telemetry dependency. |
prober/internal/prober/prober.go |
Uses shared builder without host detection. |
prober/internal/prober/resource_test.go |
Tests prober version precedence. |
prober/internal/prober/BUILD.bazel |
Updates builder dependency. |
docs/configuration.md |
Documents name and version ownership. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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 #1575
Closes #1576
#1575: the premise is true, for all four builders
The issue was inferred from the SDK's merge order. The test came first and was red against the unchanged code: with
OTEL_RESOURCE_ATTRIBUTES=service.version=other,k8s.node.name=n1, each builder producedservice.version=other.service.versionbeforecommon/telemetry/setup(agent, registrar, controller, edge control plane)otheragent/internal/meshdnsotheragent/internal/proxy/hotrestartotherprober/internal/proberotherSame two cases, all four packages.
k8s.node.name=n1was kept before and is kept after.Nothing shipped is affected: no chart puts a
service.versionin the environment of any container.#1576: one builder
common/telemetry/serviceresource(new) is the only place a Go component's resource is assembled:The order inside it is the fix for both #1562 and #1575: the environment first, then the component's name (
servicename.Option, unchanged), then the build's version, then the SDK's detectors.resource.Newmerges in order and the later option wins.What is shared: all four builders. None is left out.
The one difference, kept as an option:
WithoutHost(). The prober is not hostNetwork, so itshost.nameis its pod name, and a collector that derives a node label fromhost.nameahead ofk8s.node.namelabelled every prober series with a pod (#1041). The other three keephost.name, as before; mesh-dns and the proxy supervisor are hostNetwork, so it is the node's name there.What is not shared: each builder still wraps the error in its own words, and still owns its exporters, readers and providers. Only the resource was a copy.
common/telemetry/servicenameis unchanged. The four builders no longer import it directly;serviceresourcedoes.Dependencies
serviceresourceimports the OTel SDK'sresourcepackage,semconv/v1.30.0andservicename(which imports the same two). Every one of these binaries linked all three already, so no binary gains a module. Guards run, all green://agent/cmd/mesh-dns:deps_test,//agent/cmd/proxy-supervisor:deps_test,//cni/cmd/cni:deps_test,//agent/cmd/uds-csi:deps_test, and the stdlib-only probes'deps_test(agent-ready,proxy-ready,mesh-dns-ready,identity-ready)image_testof the agent, mesh-dns, proxy-supervisor, uds-csi, cni-install, controller, registrar and prober imagesscripts/check-mesh-dns-deps.sh,check-proxy-supervisor-deps.sh,check-cni-deps.sh,check-uds-csi-deps.sh,check-proxy-ready-deps.shOverrides
OTEL_SERVICE_NAMEdoes exactly what fix(telemetry): a service.name in OTEL_RESOURCE_ATTRIBUTES no longer renames a component (#1562) #1564 left it doing: it overrides the component's name; blank counts as unset. The existingTestResourceServiceNamecases are untouched and pass.service.versionhas no override. There is noOTEL_SERVICE_VERSIONconvention, and the version says which binary produced the telemetry (charts/README.md: it is the binary's build ID, not the chart'sappVersion), which only the binary knows. A deployment that wants to label its telemetry with something else can use any other attribute key inOTEL_RESOURCE_ATTRIBUTES; all of those are kept.Tests
TestResourceServiceVersionin each of the four packages (red first, above).TestResourceHostNamein the three builders that keephost.name. The prober's existingTestResourceIdentityalready pins that it has none.TestNewIdentityandTestNewDetectorsin the new package.Mutations, each reverted:
TestResourceServiceVersionin all four builders,TestNewIdentityTestResourceServiceNamein all four builders,TestNewIdentityk8s.node.name, in all five packagesWithoutHost()does nothingTestNewDetectors/WithoutHost, the prober'sTestResourceIdentityTestNewDetectors/default,TestResourceHostNamein the three buildersWithoutHost()TestResourceIdentityAlso run:
bazel testand--config=race --build_tests_onlyon the six touchedgo_testtargets,bazel test //test/harnesscontract/...(not edited), lint withfail_on_violationon the touched packages,make format-check,make go-build-plain(136 packages, none excluded).docs/configuration.md,otelsection: the version rule beside the name rule.No chart change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr