Skip to content

fix(telemetry): a service.name in OTEL_RESOURCE_ATTRIBUTES no longer renames a component (#1562) - #1564

Merged
bpalermo merged 4 commits into
mainfrom
fix/1562-service-name-env-override
Oct 9, 2026
Merged

bpalermo merged 4 commits into
mainfrom
fix/1562-service-name-env-override

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 9, 2026

Copy link
Copy Markdown
Owner

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=n1 each one built a resource whose service.name was other.

Builder service.name before after
common/telemetry/setup (agent, registrar, controller, edge control plane) other the component's
agent/internal/meshdns other aether-mesh-dns
agent/internal/proxy/hotrestart other aether-proxy-supervisor
prober/internal/prober other aether-prober

The cause is the one the issue names: resource.New merges its options in order and the later one wins, and each builder passed WithAttributes(service.name=…) before WithFromEnv().

Nothing shipped is affected. No chart puts a service.name in 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's service.name. Each builder passes it after WithFromEnv(). It imports only the OTel SDK's resource package and semconv, which every one of these binaries already links, so no module is added anywhere.
  • Every other attribute in OTEL_RESOURCE_ATTRIBUTES is kept; the tests assert k8s.node.name=n1 survives in every case.
  • service.version is left where it was (before WithFromEnv), so this change is about the name only.
  • The supervisor built its resource inline in NewTelemetry; it moves into newTelemetryResource so a test can read it. Same options, same order.
  • docs/configuration.md, otel section: who names a component, and how to rename one on purpose.

OTEL_SERVICE_NAME

It 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.name that rides along in an attribute string copied from another container. And the SDK itself ranks it above OTEL_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.name in OTEL_RESOURCE_ATTRIBUTES no longer takes part.

Tests

TestResourceServiceName in each of the four packages, and TestOption in the new one. Seen red against the unchanged builders (the supervisor's after the extraction only, which changes no behaviour):

service.name_in_OTEL_RESOURCE_ATTRIBUTES_does_not_rename_the_component: service.name = "other", want "aether-mesh-dns"
a_blank_OTEL_SERVICE_NAME_is_no_override:                               service.name = "other", want "aether-mesh-dns"

The same two cases failed in all four packages. The OTEL_SERVICE_NAME cases passed before and after: they pin behaviour that is kept.

Mutations, each reverted:

Mutation Red
the option ignores OTEL_SERVICE_NAME (the component's name always wins) the override cases, in all five packages
OTEL_SERVICE_NAME is not trimmed the blank-value case, in all five packages
the option is passed before WithFromEnv() in each builder the two original cases, in all four builders

Also run: bazel test and --config=race on the five test targets, //agent/cmd/mesh-dns:deps_test, //agent/cmd/proxy-supervisor:deps_test, the three image_test targets, 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

…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
Copilot AI balanced review requested due to automatic review settings October 9, 2026 18:08
@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 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.

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 implementation consistently fixes all affected builders and includes focused regression coverage.

0 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:25

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 precedence fix is consistently applied and covered by focused regression tests for every resource builder.

0 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 9, 2026 19:52

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 centralized fix consistently covers every resource builder and includes focused regression tests for precedence and attribute preservation.

0 open findings

🧠 Review effort: Balanced

@bpalermo
bpalermo merged commit 60ce18f into main Oct 9, 2026
31 checks passed
@bpalermo
bpalermo deleted the fix/1562-service-name-env-override branch October 9, 2026 20:11
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]>
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

Development

Successfully merging this pull request may close these issues.

telemetry: a service.name in OTEL_RESOURCE_ATTRIBUTES may override the component's own

2 participants