[otlp/metrics] Add EncodeSliceMetadataAsTags option #43881
Draft
+45
−13
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.
What does this PR do?
Currently, when converting OpenTelemetry attributes to Datadog tags, all attribute values are converted as-is to strings. For simple types (strings, ints, etc) this works as expected, but OpenTelemetry also supports more complex types as attribute values. Array values in particular are a useful attribute value type, as both OpenTelemetry (e.g.
container.image.repo_digests) and Datadog (e.g.kube_service) support having multiple values on the same key for the same data point. To support these cases, this change gives the OTLPTranslatorthe ability to covert top-level array attribute values into multiple Datadog tags (instead of a single tag formatted like a JSON array).Motivation
This has been a particular pain point when using the OpenTelemetry collector's
datadogexporterplugin to ingest metrics into Datadog. The collector plugin depends on theopentelemetry-mapping-gopackage updated in this change. By exposing this new setting, metrics sent from the collector can more fully use Datadog's rich tag slicing feature with OpenTelemetry-based metrics.Describe how you validated your changes
Unit tests test that both the old behaviour still works as expected. I also built a version of the OpenTelemetry Collector that uses this change, and it exports metrics with the expected tags.