stats: auto-populate node.id and node.cluster in OTel stats sink resource#44066
Open
Retr0-XD wants to merge 1 commit intoenvoyproxy:mainfrom
Open
stats: auto-populate node.id and node.cluster in OTel stats sink resource#44066Retr0-XD wants to merge 1 commit intoenvoyproxy:mainfrom
Retr0-XD wants to merge 1 commit intoenvoyproxy:mainfrom
Conversation
|
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. |
…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>
59ecd90 to
6b784d5
Compare
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.
Problem
The OpenTelemetry stats sink emits metrics with an empty
Resource(onlytelemetry.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
LocalInfowhen building the sink:node.idLocalInfo::nodeName()"envoy-pod-1"node.clusterLocalInfo::clusterName()"my-service"Priority rule: configured resource detectors take precedence —
try_emplaceensures detector-set values are never overwritten.Files changed
source/extensions/stat_sinks/open_telemetry/config.cc— injectnode.id/node.clusterbefore constructingOtlpOptionstest/extensions/stats_sinks/open_telemetry/config_test.cc— factory smoke-test with non-empty node info + detector-priority testtest/extensions/stats_sinks/open_telemetry/open_telemetry_impl_test.cc— end-to-end flush test verifying attributes appear inResourceMetricsExample config
No config change required. With the existing bootstrap:
The exported
ResourceMetrics.resource.attributeswill now include: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