Repository navigation
Conversation
Pull request dashboard statusWaiting on reviewers · refreshed 2026-11-09 19:55 UTC Review the latest changes. Also blocked by: Merge conflicts. Status above doesn't look right?
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9308 +/- ##
======================================
Coverage 89.8% 89.9%
======================================
Files 357 358 +1
Lines 23987 24094 +107
======================================
+ Hits 21562 21665 +103
- Misses 2425 2429 +4
🚀 New features to boost your workflow:
|
pellared
marked this pull request as ready for review
November 9, 2026 13:52
pellared
requested review from
MrAlias,
XSAM,
dashpole,
dmathieu and
ps-mir
as code owners
November 9, 2026 13:52
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the stdoutmetric JSON formatting and non-finite number support changes.
No open issues 🎉
What changed in this PR
Updates stdoutmetric’s default JSON output to use non-OTLP attribute formatting and export non-finite numbers instead of rejecting entire metric collections, following the stdoutlog changes in #9150.
Changes:
- Adds exporter-local JSON wrappers for attributes and non-finite numeric fields while preserving custom encoders’ original input.
- Adds regression tests and benchmarks covering numeric precision, attribute formatting, empty collections, SDK integration, and error propagation.
- Documents the formatting changes in package documentation and the changelog.
| File | Description |
|---|---|
exporters/stdout/stdoutmetric/json.go |
Implements attribute and numeric JSON conversion. |
exporters/stdout/stdoutmetric/json_test.go |
Adds regression coverage and export benchmarks. |
exporters/stdout/stdoutmetric/doc.go |
Documents non-OTLP attribute formatting and custom encoder behavior. |
exporters/stdout/stdoutmetric/config.go |
Uses the new default encoder and preserves pretty-print support. |
CHANGELOG.md |
Records attribute formatting changes and non-finite value support. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
NaN and infinities in metric values or attributes currently stop the default JSON encoder and leave the entire metric collection unwritten. Share the attribute package's non-OTLP formatting, following merged #9150, and encode non-finite metric numbers as JSON strings.
Attribute values use native JSON types: strings, booleans, finite numbers, arrays, objects, and
nullfor empty values. Bytes use Base64 strings; special floats become"NaN","Infinity", and"-Infinity". JSON-looking strings stay strings, and user map entries namedTypeorValueremain ordinary data. Numeric adapters cover measurements, extrema, bounds, summaries, and exemplars while preserving integer precision and signed zero.Resource, instrumentation scope, and data-point attribute sets become JSON objects. Exemplar attributes remain ordered arrays of single-attribute objects. Empty sets are
{}, nil resources remainnull, and scope metadata is retained.Use exporter-local wrappers with
json.RawMessageattribute fields so finite and non-finite collections follow the same encoding path. Concrete wrapper slices avoid per-record interface boxing. CustomWithEncoderimplementations, including caller-supplied*json.Encodervalues, receive the original metric data. Shared attribute marshaling and other exporters are unaffected; caller-owned input and ordinary export errors are preserved. Focused race tests andmake precommitpass.Fixes #9304.
Six-sample benchmarks below compare against main
dfb660c5eusing the same fixtures on both versions. The existing exporter fixtures use about 57% fewer bytes, increase from 66 to 106 allocations, and measured 12–15% slower. The mixed aggregation fixture measured 42% faster, used 67% fewer bytes, and reduced allocations from 373 to 281. Timings are directional measurements from a shared host. This is a formatting change with performance tradeoffs; non-finite rejection paths are excluded because they do not provide a comparable successful-export baseline.Benchmark commands:
GOMAXPROCS=2 make benchmark/./exporters/stdout/stdoutmetric ARGS='-bench=BenchmarkExporterExport -benchmem -count=6 -benchtime=100ms'andGOMAXPROCS=2 make benchmark/./exporters/stdout/stdoutmetric ARGS='-bench=BenchmarkJSONExport -benchmem -count=6 -benchtime=100ms'.