Skip to content

stats: auto-populate node.id and node.cluster in OTel stats sink resource#44066

Open
Retr0-XD wants to merge 1 commit intoenvoyproxy:mainfrom
Retr0-XD:feat/otel-stats-sink-node-resource-attrs-39931
Open

stats: auto-populate node.id and node.cluster in OTel stats sink resource#44066
Retr0-XD wants to merge 1 commit intoenvoyproxy:mainfrom
Retr0-XD:feat/otel-stats-sink-node-resource-attrs-39931

Conversation

@Retr0-XD
Copy link

@Retr0-XD Retr0-XD commented Mar 21, 2026

Problem

The OpenTelemetry stats sink emits metrics with an empty Resource (only telemetry.sdk.* attributes). Consumers such as OTel Collector processors have no way to identify which Envoy instance sent the metrics — making correlation of configs with metrics impossible.

Reported in #39931.

Solution

Automatically inject two resource attributes from LocalInfo when building the sink:

Attribute Source Example
node.id LocalInfo::nodeName() "envoy-pod-1"
node.cluster LocalInfo::clusterName() "my-service"

Priority rule: configured resource detectors take precedence — try_emplace ensures detector-set values are never overwritten.

Files changed

  • source/extensions/stat_sinks/open_telemetry/config.cc — inject node.id/node.cluster before constructing OtlpOptions
  • test/extensions/stats_sinks/open_telemetry/config_test.cc — factory smoke-test with non-empty node info + detector-priority test
  • test/extensions/stats_sinks/open_telemetry/open_telemetry_impl_test.cc — end-to-end flush test verifying attributes appear in ResourceMetrics

Example config

No config change required. With the existing bootstrap:

node:
  id: envoy-pod-1
  cluster: my-service
stats_sinks:
- name: envoy.stat_sinks.open_telemetry
  typed_config:
    "@type": type.googleapis.com/envoy.extensions.stat_sinks.open_telemetry.v3.SinkConfig
    grpc_service:
      envoy_grpc:
        cluster_name: otel_collector

The exported ResourceMetrics.resource.attributes will now include:

node.id    = "envoy-pod-1"
node.cluster = "my-service"

AI disclosure: GitHub Copilot was used during implementation and test writing. I fully understand all changes made in this PR.

Commit Message: See PR title
Risk Level: Low
Testing: Unit tests added/verified
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

@Retr0-XD Retr0-XD had a problem deploying to external-contributors March 21, 2026 09:57 — with GitHub Actions Error
@repokitteh-read-only
Copy link

Hi @Retr0-XD, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #44066 was opened by Retr0-XD.

see: more, trace.

…urce

The OpenTelemetry stats sink previously emitted metrics with an empty
Resource (or only telemetry.sdk.* attributes). Consumers downstream —
such as OTel Collector processors — had no way to identify which Envoy
instance emitted the metrics.

This change automatically injects `node.id` and `node.cluster` from
`LocalInfo` into the resource attributes of every export request.
Resource detectors configured by the user retain priority: if a
detector already sets those keys, the auto-populated values are skipped
(try_emplace semantics).

Fixes: envoyproxy#39931

Signed-off-by: Retr0-XD <sakthi.harish@edgeverve.com>
@Retr0-XD Retr0-XD force-pushed the feat/otel-stats-sink-node-resource-attrs-39931 branch from 59ecd90 to 6b784d5 Compare March 22, 2026 06:18
@Retr0-XD Retr0-XD requested a review from mattklein123 as a code owner March 22, 2026 06:18
@Retr0-XD Retr0-XD requested a deployment to external-contributors March 22, 2026 06:18 — with GitHub Actions Waiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant