[receiver/datadogreciever] Add EnableMultiTagParsing feature gate
#44747
+102
−1
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.
Description
Datadog's metric model treats tags on data points as arbitrary strings. However, the product has special support for tags formatted as a
key:valuestring.key:valuetags allow slicing metrics in powerful ways and are core to many of Datadog's offerings.Since Datadog tags are arbitrary strings, there's nothing to stop users from recording tags with the same
key:prefix on the same data point. In fact, Datadog's own integrations can do this: Thekube_servicetag from thekubeletintegration will have one entry per Kubernetes service that fronts a pod. (An example set of tags might look something like[...,"kube_service:datadog-cluster-agent-metrics-api","kube_service:datadog-cluster-agent-admission-controller",...]).Currently, when the
datadogreceiverreceives multiple tags for a data point that share the same key, it only retains the lastkey:valuepair as an OpenTelemetry attribe. In the above example, the attribute map would have an entrykube_service = datadog-cluster-agent-admission-controller- "datadog-cluster-agent-metrics-api" would have been discarded.This change introduces a feature gate that changes the tag parsing behaviour to support tags that share the same key. Instead of overwriting the previous
Strentry in the attribute map, it converts the attribute map to aSliceand stores all values for that key. This conversion only happens if more than one value is encountered for the same key, so even with the feature flag enabled, there will not be any behaviour change for users who do not send tags that share the same key.I chose to implement this as a feature flag instead of a config setting because I believe this is technically correct behaviour, and should be the default in some future release of the OpenTelemetry Collector. Feedback on this decision is appreciated.
Testing
Unit tests have been added against
tagsToAttributesto make sure attribute conversion works as expected both with and without the feature gate. The collector has been built and run locally, confirming that exporters receive the expected (slice) attributes when multiple tags with the same key are received.Documentation
The README for the receiver now describes how tags are processed, both with and without the feature gate.