Skip to content

Fix OTLP JSON encoding of non-finite doubles - #8775

Merged
pellared merged 4 commits into
open-telemetry:mainfrom
pellared:agent/fix-otlp-json-non-finite-values
Aug 21, 2026
Merged

pellared merged 4 commits into
open-telemetry:mainfrom
pellared:agent/fix-otlp-json-non-finite-values

Conversation

@pellared

@pellared pellared commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Fixes #8774.

Changes

  • Encode non-finite OTLP doubleValue values as the ProtoJSON strings "NaN", "Infinity", and "-Infinity".
  • Decode the same strings in the internal OTLP JSON request model to preserve round-trip behavior.
  • Add wire-format and round-trip regression coverage for all three values.

Root cause

The OTLP-specific trace JSON encoder represented doubleValue as *float64 and delegated it to encoding/json. Go's JSON encoder rejects non-finite numbers, while the ProtoJSON mapping represents them with string values.

Impact

OTLP/HTTP trace exporters configured for JSON can now send spans containing non-finite double attributes instead of failing to marshal and dropping the affected batch.

@codecov

codecov Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Codecov Report

โŒ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.
โœ… Project coverage is 88.3%. Comparing base (3b9e6e7) to head (3740a5c).

Files with missing lines Patch % Lines
.../internal/otlpjson/export_trace_service_request.go 90.4% 2 Missing โš ๏ธ
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8775   +/-   ##
=====================================
  Coverage   88.3%   88.3%           
=====================================
  Files        331     331           
  Lines      20953   20972   +19     
=====================================
+ Hits       18512   18529   +17     
- Misses      2441    2443    +2     
Files with missing lines Coverage ฮ”
.../internal/otlpjson/export_trace_service_request.go 91.8% <90.4%> (-0.2%) โฌ‡๏ธ
๐Ÿš€ New features to boost your workflow:
  • โ„๏ธ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pellared
pellared marked this pull request as ready for review August 18, 2026 08:34
@pellared
pellared merged commit 4932778 into open-telemetry:main Aug 21, 2026
65 checks passed
@pellared
pellared deleted the agent/fix-otlp-json-non-finite-values branch August 21, 2026 09:29
@pellared pellared mentioned this pull request Aug 24, 2026
pellared added a commit that referenced this pull request Aug 25, 2026
This release is the last to support [Go 1.25].
The next release will require at least [Go 1.26].

### Added

- Support testing of [Go 1.27]. (#8811)
- Support `http/json` protocol in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#8273, #8775, #8831)
- Add `Hasher` struct and methods in
`go.opentelemetry.io/otel/attribute` to compute authoritative `Distinct`
hashes incrementally for attribute filtering and deduplication. (#8598)

### Changed

- Lazily evaluate filtered and dropped attributes on measurement hot
paths in `go.opentelemetry.io/otel/sdk/metric` to avoid unnecessary
attribute set allocations. (#8598)
- Add `ErrExporterShutdown` to `go.opentelemetry.io/otel/sdk/log` and
return it from the
`go.opentelemetry.io/otel/exporters/stdout/stdoutlog`,
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc`, and
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` exporters
when `Export` is called after `Shutdown`. (#8773)
- Clarify in `go.opentelemetry.io/otel/log` that calling
`Logger.Enabled` is optional and that cached results can become stale.
(#8764)

### Fixed

- Export dropped attribute counts in OTLP log records from
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` and
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#8829)
- Name span events created from OpenTracing logs after the `event` log
field, falling back to `log`, instead of always using an empty name in
`go.opentelemetry.io/otel/bridge/opentracing`. (#8648)
- Count exception attributes omitted due to the attribute count limit as
dropped in `go.opentelemetry.io/otel/sdk/log`. (#8796)
- Prevent log record and instrumentation scope attributes with empty
keys from reaching processors and exporters in
`go.opentelemetry.io/otel/sdk/log`. (#8797)
- Fix a data race when span attributes are read concurrently in
`go.opentelemetry.io/otel/sdk/trace`. (#8706)
- Prevent a panic in `(*Set).Filter` when called on a nil receiver in
`go.opentelemetry.io/otel/attribute`. (#8792)
- The simple span and log processors record
`otel.sdk.processor.{span,log}.processed` when the record is submitted
to the exporter instead of after the export completes, and no longer set
`error.type` from the export outcome, in
`go.opentelemetry.io/otel/sdk/trace` and
`go.opentelemetry.io/otel/sdk/log`. (#8705)
- Prevent `Resource.MarshalLog` from panicking on nil resources in
`go.opentelemetry.io/otel/sdk/resource`. (#8758)

[Go 1.27]: https://go.dev/doc/go1.27
[Go 1.26]: https://go.dev/doc/go1.26
[Go 1.25]: https://go.dev/doc/go1.25
@pellared pellared added this to the v1.46.0 milestone Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

otlptracehttp JSON encoding rejects NaN and infinite attribute values

3 participants