Skip to content

Add support for serializing KeyValue lists - WIP#7015

Draft
juliuskoval wants to merge 2 commits intoopen-telemetry:mainfrom
juliuskoval:keyvalue-lists
Draft

Add support for serializing KeyValue lists - WIP#7015
juliuskoval wants to merge 2 commits intoopen-telemetry:mainfrom
juliuskoval:keyvalue-lists

Conversation

@juliuskoval
Copy link
Copy Markdown
Contributor

According to the spec, attribute values should be AnyValue. One of the possible values of AnyValue is KeyValueList, which we currently aren't able to serialize properly.

Changes

This PR adds support for serializing KeyValue lists to the OTLP exporter.

I haven't put a lot of effort into the Zipkin exporter since it is obsolete and I still need to properly implement this feature in the console exporter, so I'm only making this PR a draft.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions bot added pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package labels Mar 29, 2026
@juliuskoval
Copy link
Copy Markdown
Contributor Author

Question: As far as I know, the spec doesn't say anything about limits to have many nested layers there can be, but shouldn't we try to guard against self-referencing IEnumerables?

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 70.58824% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.80%. Comparing base (1f68cce) to head (8d385e9).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...xporter.Console/Implementation/ConsoleTagWriter.cs 0.00% 5 Missing ⚠️
....Exporter.Zipkin/Implementation/ZipkinTagWriter.cs 0.00% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7015      +/-   ##
==========================================
- Coverage   88.90%   88.80%   -0.10%     
==========================================
  Files         263      263              
  Lines       12424    12458      +34     
==========================================
+ Hits        11045    11063      +18     
- Misses       1379     1395      +16     
Flag Coverage Δ
unittests-Project-Experimental 88.47% <70.58%> (-0.12%) ⬇️
unittests-Project-Stable 88.64% <70.58%> (-0.12%) ⬇️
unittests-Solution 88.39% <70.58%> (-0.34%) ⬇️
unittests-UnstableCoreLibraries-Experimental 42.40% <ø> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...Implementation/Serializer/ProtobufOtlpTagWriter.cs 96.90% <100.00%> (+1.01%) ⬆️
...xporter.Console/Implementation/ConsoleTagWriter.cs 69.44% <0.00%> (-11.21%) ⬇️
....Exporter.Zipkin/Implementation/ZipkinTagWriter.cs 50.00% <0.00%> (-10.87%) ⬇️

... and 2 files with indirect coverage changes

@martincostello
Copy link
Copy Markdown
Member

shouldn't we try to guard against self-referencing IEnumerables

I think so, otherwise it would cause a stack overflow? Could just add a recursion limit to track such occurences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package pkg:OpenTelemetry.Exporter.Zipkin Issues related to OpenTelemetry.Exporter.Zipkin NuGet package pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants