OTLP exporter flattens array attribute to multiple key value pairs with the same key name #2547
Labels
bug
Something isn't working
good first issue
Good for newcomers
help wanted
Good for taking. Extra help will be provided by maintainers
pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol
Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package
Bug Report
The current OTLP exporter below flattens nested array in Span.Atttributes (Activity.Tags in .NET) into a list of key value pairs with the same key for all these kv pairs. For example,
activity.SetTag('arraykey', new int [] {1, 2, 3}
is converted to JSON like list{{'arraykey': 1}, {'arraykey': 2}, {'arraykey': 3}}
in OTLP. This could cause problem if the OTLP listener would like to process Span.Attributes as dictionary, or store them into table like data structure, because it requires inventing some new rules to handle the duplicated key names.opentelemetry-dotnet/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/ActivityExtensions.cs
Lines 413 to 417 in ce46d00
Instead of flatting the array into the top level of Span.Attributes, I tried below change which keeps the type of array in the Span.Attributes field, when then will be serialized to ArrayValue in OTLP and no longer producing duplicated keys. Please let me know if this will work and I'll make PR to fix all the nested arrays in Span.Attributes.
The text was updated successfully, but these errors were encountered: