open-telemetry / open-telemetry/opentelemetry-ruby
Add NaN/Infinity handling policy across aggregations
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 606
- Forks
- 301
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 42
Description
Spec requirement
The SDK MUST handle numerical limits gracefully, including IEEE-754 NaN/Infinity inputs (sdk.md:1956-1973, Numerical limits handling). [Development] Exponential histograms specifically MUST accept the full normal IEEE-754 range excluding ±Inf/NaN, and SHOULD NOT let non-normal values pollute sum/min/max (sdk.md:798-810, Handle all normal values).
Current behavior
No explicit NaN/Infinity guards exist in any aggregation's update path (sum.rb:54-68 (permalink), explicit_bucket_histogram.rb:63-74 (permalink), exponential_bucket_histogram.rb:224-235,268-283 (permalink)). Ruby's native float semantics apply implicitly which prevents crashes, but a NaN measurement silently poisons a running sum rather than being handled by any documented policy.
Suggested fix
Add a guard in each aggregation's update path (Sum, Explicit/Exponential Histogram) that rejects or specially handles NaN/Infinity measurements before they reach sum/min/max, applied consistently across all three aggregation classes in one pass since they share the same underlying pattern.
Related rows in SPEC_COMPLIANCE_METRICS.md
SDK-63, SDK-21
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the update paths in metrics_sdk/lib/opentelemetry/sdk/metrics/aggregation/sum.rb, explicit_bucket_histogram.rb, and exponential_bucket_histogram.rb, alongside the referenced numerical-limits sections in sdk.md. Compare the three aggregation behaviors and the SDK-63 and SDK-21 rows in SPEC_COMPLIANCE_METRICS.md; done means the chosen NaN/Infinity policy is applied consistently before sum, min, or max are affected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100