Skip to content

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
bpalermo merged 1 commit into
mainfrom
fix/telemetry-shared-resource-1575-1576
Oct 9, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/telemetry-shared-resource-1575-1576

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 9, 2026

Copy link
Copy Markdown
Owner

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 produced service.version=other.

Builder service.version before after
common/telemetry/setup (agent, registrar, controller, edge control plane) other the build's
agent/internal/meshdns other the build's
agent/internal/proxy/hotrestart other the build's
prober/internal/prober other the build's
TestResourceServiceVersion/service.version_in_OTEL_RESOURCE_ATTRIBUTES_does_not_replace_the_build's: service.version = "other", want "v1.2.3": the build's version
TestResourceServiceVersion/nor_does_it_beside_an_OTEL_SERVICE_NAME_override:                          service.version = "other", want "v1.2.3": the build's version

Same two cases, all four packages. k8s.node.name=n1 was kept before and is kept after.

Nothing shipped is affected: no chart puts a service.version in the environment of any container.

#1576: one builder

common/telemetry/serviceresource (new) is the only place a Go component's resource is assembled:

serviceresource.New(ctx, name, version)                               // setup, mesh-dns, proxy supervisor
serviceresource.New(ctx, name, version, serviceresource.WithoutHost()) // prober

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.New merges 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 its host.name is its pod name, and a collector that derives a node label from host.name ahead of k8s.node.name labelled every prober series with a pod (#1041). The other three keep host.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/servicename is unchanged. The four builders no longer import it directly; serviceresource does.

Dependencies

serviceresource imports the OTel SDK's resource package, semconv/v1.30.0 and servicename (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_test of the agent, mesh-dns, proxy-supervisor, uds-csi, cni-install, controller, registrar and prober images
  • scripts/check-mesh-dns-deps.sh, check-proxy-supervisor-deps.sh, check-cni-deps.sh, check-uds-csi-deps.sh, check-proxy-ready-deps.sh

Overrides

  • OTEL_SERVICE_NAME does 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 existing TestResourceServiceName cases are untouched and pass.
  • service.version has no override. There is no OTEL_SERVICE_VERSION convention, and the version says which binary produced the telemetry (charts/README.md: it is the binary's build ID, not the chart's appVersion), which only the binary knows. A deployment that wants to label its telemetry with something else can use any other attribute key in OTEL_RESOURCE_ATTRIBUTES; all of those are kept.

Tests

  • TestResourceServiceVersion in each of the four packages (red first, above).
  • TestResourceHostName in the three builders that keep host.name. The prober's existing TestResourceIdentity already pins that it has none.
  • TestNewIdentity and TestNewDetectors in the new package.

Mutations, each reverted:

Mutation Red
version stated before the environment (the old order) TestResourceServiceVersion in all four builders, TestNewIdentity
name stated before the environment (the pre-#1564 order) TestResourceServiceName in all four builders, TestNewIdentity
the environment is not read every case that reads k8s.node.name, in all five packages
the version attribute is not set every version assertion, in all five packages
WithoutHost() does nothing TestNewDetectors/WithoutHost, the prober's TestResourceIdentity
no host by default TestNewDetectors/default, TestResourceHostName in the three builders
the prober does not pass WithoutHost() the prober's TestResourceIdentity

Also run: bazel test and --config=race --build_tests_only on the six touched go_test targets, bazel test //test/harnesscontract/... (not edited), lint with fail_on_violation on the touched packages, make format-check, make go-build-plain (136 packages, none excluded).

docs/configuration.md, otel section: the version rule beside the name rule.

No chart change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…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
Copilot AI balanced review requested due to automatic review settings October 9, 2026 21:30
@bpalermo bpalermo added the observability Metrics, logs, profiles, alerts label Oct 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 serviceresource builder 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.

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

Labels

observability Metrics, logs, profiles, alerts

Projects

None yet

2 participants