Skip to content

trace: encode non-finite floats in auto telemetry JSON#8364

Open
immanuwell wants to merge 1 commit into
open-telemetry:mainfrom
immanuwell:fix-auto-trace-non-finite-floats
Open

trace: encode non-finite floats in auto telemetry JSON#8364
immanuwell wants to merge 1 commit into
open-telemetry:mainfrom
immanuwell:fix-auto-trace-non-finite-floats

Conversation

@immanuwell
Copy link
Copy Markdown

Fixes a tiny footgun in auto trace telemetry.

When an auto span has a float attribute like math.Inf(1), json.Marshal rejects it. autoSpan.end ignored that error, so the emitted span buffer was nil. Kinda bad: the span just disappears.

Repro on origin/main:

WithAttributes(attribute.Float64("inf", math.Inf(1)))

A focused test fails with span data was dropped.

This PR encodes non-finite doubles as protobuf JSON strings: NaN, Infinity, -Infinity, and decodes them too.

Checked:

go test ./... # in trace/
make precommit

@immanuwell immanuwell force-pushed the fix-auto-trace-non-finite-floats branch from 70b961d to 4b16e07 Compare May 22, 2026 09:59
@dashpole
Copy link
Copy Markdown
Collaborator

This comes up when using opentelemetry-go-instrumentation, right? Can you open a bug describing how you encountered this?

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 80.64516% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.9%. Comparing base (15063b2) to head (4b16e07).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
trace/internal/telemetry/number.go 77.7% 3 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #8364   +/-   ##
=====================================
  Coverage   82.9%   82.9%           
=====================================
  Files        314     314           
  Lines      25087   25114   +27     
=====================================
+ Hits       20801   20826   +25     
+ Misses      3912    3910    -2     
- Partials     374     378    +4     
Files with missing lines Coverage Δ
trace/internal/telemetry/value.go 65.0% <100.0%> (+0.8%) ⬆️
trace/internal/telemetry/number.go 57.6% <77.7%> (+17.0%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants