Repository navigation
[Exporters] Encode maps and arrays as JSON - #7694
martincostello merged 25 commits into
Conversation
- Format `byte[]` values for non-OTLP exporters as Base64-encoded strings. - Format arrays and map values in the Prometheus exporter as JSON.
Add PR number.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7694 +/- ##
==========================================
- Coverage 90.53% 90.50% -0.03%
==========================================
Files 378 379 +1
Lines 22144 22201 +57
Branches 4108 4118 +10
==========================================
+ Hits 20048 20094 +46
- Misses 1518 1524 +6
- Partials 578 583 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Add missing test coverage.
There was a problem hiding this comment.
@martincostello, thanks a lot for the PR!
Only the changes in OpenTelemetry.Exporter.Zipkin seem to be against the spec and may break some users.
Pull request dashboard statusMerged · refreshed 2026-10-27 15:16 UTC Status above doesn't look right?
|
Revert Zipkin to previous behaviour for backwards-compatibility.
There was a problem hiding this comment.
🟡 Changes recommended
Some supported map forms and nested or non-finite array values are serialized incorrectly.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates non-OTLP exporters to encode byte arrays as Base64 and Prometheus arrays/maps as JSON.
Changes:
- Adds shared Base64 byte-array serialization, preserving Zipkin behavior.
- Adds Prometheus JSON serialization for arrays and maps.
- Adds tests, diagnostics, dependencies, and changelog entries.
File summaries
| File | Description |
|---|---|
test/OpenTelemetry.Exporter.Zipkin.Tests/Implementation/ZipkinActivityConversionTests.cs |
Verifies Zipkin byte-array compatibility. |
test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusSerializerTests.cs |
Tests Prometheus structured values. |
test/OpenTelemetry.Exporter.Console.Tests/ConsoleKvListAttributeTests.cs |
Tests Base64 console output. |
src/Shared/TagWriter/JsonStringArrayTagWriter.cs |
Adds shared Base64 encoding. |
src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinTagWriter.cs |
Retains Zipkin’s JSON-array behavior. |
src/OpenTelemetry.Exporter.Prometheus.HttpListener/OpenTelemetry.Exporter.Prometheus.HttpListener.csproj |
Links serialization support. |
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/Serialization/TextFormatSerializer.cs |
Routes structured labels through JSON encoding. |
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/Serialization/PrometheusAnyValueWriter.cs |
Implements Prometheus AnyValue JSON serialization. |
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusExporterEventSource.cs |
Adds unsupported-value diagnostics. |
src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md |
Documents HttpListener changes. |
src/OpenTelemetry.Exporter.Prometheus.AspNetCore/OpenTelemetry.Exporter.Prometheus.AspNetCore.csproj |
Links shared tag writers. |
src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md |
Documents ASP.NET Core changes. |
src/OpenTelemetry.Exporter.Console/CHANGELOG.md |
Documents console encoding changes. |
Review details
Suppressed comments (1)
src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/Serialization/TextFormatSerializer.cs:1417
- The cached/scope-label path has the same incomplete map detection: for example,
Dictionary<string, string>is not convertible toIEnumerable<KeyValuePair<string, object?>>, so it remains a .NET type name instead of JSON. Match every map shape supported byTagWriter.
byte[] byteArrayValue => Convert.ToBase64String(byteArrayValue),
Array or IEnumerable<KeyValuePair<string, object?>> => PrometheusAnyValueWriter.Instance.ToLabelValueString(key, labelValue),
- Files reviewed: 13/13 changed files
- Comments generated: 6
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Support nested arrays and maps. - Handle other map shapes. - Handle `NaN` and infinite numbers as JSON strings. - Fix-up CHANGELOG entries.
Update test for new format.
Changes
byte[]values for non-OTLP exporters as Base64-encoded strings (spec) except Zipkin./cc @pellared
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)