Skip to content

[OpenTelemetry] Improve HistogramExplicitBounds#7165

Open
martincostello wants to merge 8 commits into
open-telemetry:mainfrom
martincostello:gh-3428
Open

[OpenTelemetry] Improve HistogramExplicitBounds#7165
martincostello wants to merge 8 commits into
open-telemetry:mainfrom
martincostello:gh-3428

Conversation

@martincostello
Copy link
Copy Markdown
Member

@martincostello martincostello commented Apr 25, 2026

Fixes #3428

Changes

Apply recommendations from #3428:

  • Use SIMD vectorization to find buckets.
  • Use radix sort.
  • Apply cap to histogram explicit bounds (10M).

Written primarily by Copilot through an iterative approach.

Final benchmark results are shown below: #7165 (comment)

I haven't benchmarked the ARM64 SIMD branch as I don't have the hardware for that locally.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Apply recommendations from open-telemetry#3428:

- Use SIMD vectorization to find buckets.
- Use radix sort.
- Apply cap to histogram explicit bounds (10M).

Written primarily by Copilot through an iterative approach.
@github-actions github-actions Bot added pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package perf Performance related labels Apr 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

❌ Patch coverage is 98.24561% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.93%. Comparing base (ed44995) to head (dcf2c50).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...c/OpenTelemetry/Metrics/HistogramExplicitBounds.cs 98.07% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7165      +/-   ##
==========================================
+ Coverage   89.86%   89.93%   +0.06%     
==========================================
  Files         275      275              
  Lines       13852    13935      +83     
==========================================
+ Hits        12448    12532      +84     
+ Misses       1404     1403       -1     
Flag Coverage Δ
unittests-Project-Experimental 89.59% <98.24%> (-0.19%) ⬇️
unittests-Project-Stable 89.67% <98.24%> (-0.19%) ⬇️
unittests-Solution 89.89% <98.24%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/OpenTelemetry/Metrics/MetricStreamIdentity.cs 92.63% <100.00%> (+0.13%) ⬆️
...trics/View/ExplicitBucketHistogramConfiguration.cs 89.47% <100.00%> (+6.14%) ⬆️
...c/OpenTelemetry/Metrics/HistogramExplicitBounds.cs 98.26% <98.07%> (-1.74%) ⬇️

... and 4 files with indirect coverage changes

Add missing patch coverage.
Fix CS8604 warning.
@martincostello
Copy link
Copy Markdown
Member Author

Benchmark Results

Copilot Summary

  • 56 benchmark cases
  • 34/56 are faster on gh-3428
  • 22/56 are slower on gh-3428
  • Allocations are unchanged in every common case: 0 B -> 0 B (1.00x, 0%)

Runtime trends

Area Duration change in gh-3428 vs main Allocations
10 / 49 bounds: LookupExactBoundary, LookupInRangeValue, LookupWithInfiniteBounds 0.34x to 0.73x (27% to 66% faster) 1.00x, 0%
10 / 49 bounds: LookupPositiveInfinity 0.02x to 0.15x (85% to 98% faster) 1.00x, 0%
All sizes: LookupNaN 0.00x to 0.01x (99% to 100% faster) 1.00x, 0%
50 / 1000 bounds: LookupNegativeInfinity, LookupPositiveInfinity 0.06x to 0.20x (80% to 94% faster) 1.00x, 0%
50 / 1000 bounds: LookupExactBoundary, LookupInRangeValue, LookupWithInfiniteBounds 6.80x to 143.78x (580% to 14,278% slower) in the worst cases 1.00x, 0%

Notable improvements

  • 49 / PositiveOnly / LookupPositiveInfinity: 21.5079 ns -> 0.4840 ns (0.02x, 97.75% faster)
  • 49 / PositiveOnly / LookupExactBoundary: 11.3438 ns -> 3.8311 ns (0.34x, 66.23% faster)
  • 50 / PositiveOnly / LookupNegativeInfinity: 1.7324 ns -> 0.1553 ns (0.09x, 91.04% faster)

Notable regressions

  • 1000 / PositiveOnly / LookupExactBoundary: 0.0645 ns -> 9.2740 ns (143.78x, 14,278.29% slower)
  • 1000 / PositiveOnly / LookupWithInfiniteBounds: 0.1380 ns -> 9.2317 ns (66.90x, 6,589.64% slower)
  • 50 / MixedSigned / LookupExactBoundary: 0.0460 ns -> 2.4807 ns (53.93x, 5,292.83% slower)

Caveat on the largest regressions

Some of the biggest percentage regressions come from very small sub-nanosecond baselines in main, so the ratio looks dramatic even when the absolute increase is still only a few nanoseconds. For
example:

  • 10 / PositiveOnly / LookupEmptyBounds: 0.0008 ns -> 0.1083 ns = 135.37x, but only +0.1075 ns
  • 50 / PositiveOnly / LookupEmptyBounds: 0.0014 ns -> 0.1886 ns = 134.71x, but only +0.1872 ns
  • 50 / MixedSigned / LookupExactBoundary: 0.0460 ns -> 2.4807 ns = 53.93x, but the absolute change is +2.4347 ns
  • 1000 / PositiveOnly / LookupExactBoundary: 0.0645 ns -> 9.2740 ns = 143.78x, with an absolute delta of +9.2095 ns

So the practical picture is:

  • No allocation regressions
  • Clear wins for many 10/49-bound lookups
  • Clear regressions for several 50/1000-bound exact/in-range/infinite-bound lookups
  • The worst percentage regressions are real, but several are amplified by near-zero starting values

Detailed Results

Expand to view

main


BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8246/25H2/2025Update/HudsonValley2)
13th Gen Intel Core i7-13700H 2.90GHz, 1 CPU, 20 logical and 14 physical cores
.NET SDK 10.0.203
  [Host]    : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3
  .NET 10.0 : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3

Job=.NET 10.0  Runtime=.NET 10.0  Toolchain=net10.0  

Method BoundCount Layout Mean Error StdDev Median Allocated
LookupExactBoundary 10 MixedSigned 1.8827 ns 0.0680 ns 0.1172 ns 1.8705 ns -
LookupInRangeValue 10 MixedSigned 1.8671 ns 0.0679 ns 0.0952 ns 1.8729 ns -
LookupNegativeInfinity 10 MixedSigned 0.5037 ns 0.0420 ns 0.1084 ns 0.4856 ns -
LookupPositiveInfinity 10 MixedSigned 0.7109 ns 0.0455 ns 0.0797 ns 0.7004 ns -
LookupNaN 10 MixedSigned 0.0303 ns 0.0273 ns 0.0242 ns 0.0201 ns -
LookupWithInfiniteBounds 10 MixedSigned 1.8116 ns 0.0676 ns 0.1053 ns 1.7988 ns -
LookupEmptyBounds 10 MixedSigned 0.2151 ns 0.0386 ns 0.0706 ns 0.2271 ns -
LookupExactBoundary 10 PositiveOnly 1.7108 ns 0.0700 ns 0.1477 ns 1.7178 ns -
LookupInRangeValue 10 PositiveOnly 1.6939 ns 0.0433 ns 0.0362 ns 1.6853 ns -
LookupNegativeInfinity 10 PositiveOnly 0.2010 ns 0.0100 ns 0.0089 ns 0.2014 ns -
LookupPositiveInfinity 10 PositiveOnly 0.4993 ns 0.0443 ns 0.0853 ns 0.4876 ns -
LookupNaN 10 PositiveOnly 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupWithInfiniteBounds 10 PositiveOnly 1.6749 ns 0.0621 ns 0.0985 ns 1.6882 ns -
LookupEmptyBounds 10 PositiveOnly 0.1083 ns 0.0327 ns 0.0911 ns 0.1025 ns -
LookupExactBoundary 49 MixedSigned 4.8914 ns 0.1323 ns 0.2932 ns 4.9897 ns -
LookupInRangeValue 49 MixedSigned 4.8479 ns 0.0810 ns 0.0757 ns 4.9088 ns -
LookupNegativeInfinity 49 MixedSigned 0.2089 ns 0.0390 ns 0.0618 ns 0.2017 ns -
LookupPositiveInfinity 49 MixedSigned 0.5000 ns 0.0462 ns 0.0965 ns 0.4882 ns -
LookupNaN 49 MixedSigned 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupWithInfiniteBounds 49 MixedSigned 4.9532 ns 0.1340 ns 0.3505 ns 4.9701 ns -
LookupEmptyBounds 49 MixedSigned 0.1702 ns 0.0394 ns 0.0952 ns 0.2395 ns -
LookupExactBoundary 49 PositiveOnly 3.8311 ns 0.1124 ns 0.2778 ns 3.9235 ns -
LookupInRangeValue 49 PositiveOnly 3.6580 ns 0.0733 ns 0.0686 ns 3.6208 ns -
LookupNegativeInfinity 49 PositiveOnly 0.1531 ns 0.0382 ns 0.0606 ns 0.1833 ns -
LookupPositiveInfinity 49 PositiveOnly 0.4840 ns 0.0451 ns 0.0951 ns 0.4819 ns -
LookupNaN 49 PositiveOnly 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupWithInfiniteBounds 49 PositiveOnly 3.8269 ns 0.1120 ns 0.2790 ns 3.9150 ns -
LookupEmptyBounds 49 PositiveOnly 0.1556 ns 0.0376 ns 0.0856 ns 0.1900 ns -
LookupExactBoundary 50 MixedSigned 2.4807 ns 0.0311 ns 0.0291 ns 2.4855 ns -
LookupInRangeValue 50 MixedSigned 1.7416 ns 0.0590 ns 0.0552 ns 1.7339 ns -
LookupNegativeInfinity 50 MixedSigned 0.2267 ns 0.0213 ns 0.0199 ns 0.2367 ns -
LookupPositiveInfinity 50 MixedSigned 0.4537 ns 0.0438 ns 0.0767 ns 0.4212 ns -
LookupNaN 50 MixedSigned 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupWithInfiniteBounds 50 MixedSigned 1.6833 ns 0.0665 ns 0.1093 ns 1.6786 ns -
LookupEmptyBounds 50 MixedSigned 0.2199 ns 0.0228 ns 0.0213 ns 0.2353 ns -
LookupExactBoundary 50 PositiveOnly 3.0571 ns 0.0931 ns 0.1580 ns 3.0941 ns -
LookupInRangeValue 50 PositiveOnly 3.2708 ns 0.0286 ns 0.0268 ns 3.2597 ns -
LookupNegativeInfinity 50 PositiveOnly 0.1553 ns 0.0387 ns 0.0697 ns 0.1739 ns -
LookupPositiveInfinity 50 PositiveOnly 0.4037 ns 0.0438 ns 0.0744 ns 0.4194 ns -
LookupNaN 50 PositiveOnly 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupWithInfiniteBounds 50 PositiveOnly 2.9535 ns 0.0922 ns 0.1540 ns 2.9539 ns -
LookupEmptyBounds 50 PositiveOnly 0.1886 ns 0.0102 ns 0.0085 ns 0.1915 ns -
LookupExactBoundary 1000 MixedSigned 2.4369 ns 0.0534 ns 0.0500 ns 2.4279 ns -
LookupInRangeValue 1000 MixedSigned 1.7855 ns 0.0703 ns 0.1683 ns 1.8419 ns -
LookupNegativeInfinity 1000 MixedSigned 0.2590 ns 0.0399 ns 0.1030 ns 0.2724 ns -
LookupPositiveInfinity 1000 MixedSigned 0.4029 ns 0.0435 ns 0.0784 ns 0.4055 ns -
LookupNaN 1000 MixedSigned 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupWithInfiniteBounds 1000 MixedSigned 1.5443 ns 0.0645 ns 0.1042 ns 1.5438 ns -
LookupEmptyBounds 1000 MixedSigned 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupExactBoundary 1000 PositiveOnly 9.2740 ns 0.0480 ns 0.0400 ns 9.2598 ns -
LookupInRangeValue 1000 PositiveOnly 9.2957 ns 0.1858 ns 0.1738 ns 9.3023 ns -
LookupNegativeInfinity 1000 PositiveOnly 0.2255 ns 0.0385 ns 0.0674 ns 0.2264 ns -
LookupPositiveInfinity 1000 PositiveOnly 0.4491 ns 0.0443 ns 0.0822 ns 0.4422 ns -
LookupNaN 1000 PositiveOnly 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupWithInfiniteBounds 1000 PositiveOnly 9.2317 ns 0.1105 ns 0.1033 ns 9.2097 ns -
LookupEmptyBounds 1000 PositiveOnly 0.2889 ns 0.0386 ns 0.0871 ns 0.3483 ns -

This PR


BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8246/25H2/2025Update/HudsonValley2)
13th Gen Intel Core i7-13700H 2.90GHz, 1 CPU, 20 logical and 14 physical cores
.NET SDK 10.0.203
  [Host]    : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3
  .NET 10.0 : .NET 10.0.7 (10.0.7, 10.0.726.21808), X64 RyuJIT x86-64-v3

Job=.NET 10.0  Runtime=.NET 10.0  Toolchain=net10.0  

Method BoundCount Layout Mean Error StdDev Median Allocated
LookupExactBoundary 10 MixedSigned 2.5795 ns 0.0836 ns 0.1277 ns 2.5751 ns -
LookupInRangeValue 10 MixedSigned 2.7171 ns 0.0506 ns 0.0474 ns 2.6910 ns -
LookupNegativeInfinity 10 MixedSigned 0.1816 ns 0.0374 ns 0.0674 ns 0.1895 ns -
LookupPositiveInfinity 10 MixedSigned 4.8894 ns 0.0803 ns 0.0751 ns 4.8628 ns -
LookupNaN 10 MixedSigned 3.3870 ns 0.0848 ns 0.0793 ns 3.3534 ns -
LookupWithInfiniteBounds 10 MixedSigned 2.6517 ns 0.0207 ns 0.0183 ns 2.6475 ns -
LookupEmptyBounds 10 MixedSigned 0.0198 ns 0.0139 ns 0.0200 ns 0.0198 ns -
LookupExactBoundary 10 PositiveOnly 2.6876 ns 0.0243 ns 0.0227 ns 2.6929 ns -
LookupInRangeValue 10 PositiveOnly 2.6312 ns 0.0845 ns 0.1340 ns 2.6540 ns -
LookupNegativeInfinity 10 PositiveOnly 0.1845 ns 0.0374 ns 0.0512 ns 0.1822 ns -
LookupPositiveInfinity 10 PositiveOnly 4.8825 ns 0.0830 ns 0.0776 ns 4.8365 ns -
LookupNaN 10 PositiveOnly 3.2612 ns 0.0469 ns 0.0439 ns 3.2743 ns -
LookupWithInfiniteBounds 10 PositiveOnly 2.5876 ns 0.0849 ns 0.1615 ns 2.6719 ns -
LookupEmptyBounds 10 PositiveOnly 0.0008 ns 0.0036 ns 0.0028 ns 0.0000 ns -
LookupExactBoundary 49 MixedSigned 11.1400 ns 0.0496 ns 0.0414 ns 11.1275 ns -
LookupInRangeValue 49 MixedSigned 11.1331 ns 0.0477 ns 0.0373 ns 11.1426 ns -
LookupNegativeInfinity 49 MixedSigned 0.1949 ns 0.0365 ns 0.0721 ns 0.1861 ns -
LookupPositiveInfinity 49 MixedSigned 22.1588 ns 0.0255 ns 0.0199 ns 22.1550 ns -
LookupNaN 49 MixedSigned 16.1436 ns 0.3446 ns 0.3384 ns 16.0638 ns -
LookupWithInfiniteBounds 49 MixedSigned 11.0795 ns 0.1648 ns 0.1461 ns 11.1297 ns -
LookupEmptyBounds 49 MixedSigned 0.0585 ns 0.0335 ns 0.0579 ns 0.0414 ns -
LookupExactBoundary 49 PositiveOnly 11.3438 ns 0.2552 ns 0.4601 ns 11.1409 ns -
LookupInRangeValue 49 PositiveOnly 10.8891 ns 0.1127 ns 0.0880 ns 10.8852 ns -
LookupNegativeInfinity 49 PositiveOnly 0.2377 ns 0.0376 ns 0.0629 ns 0.2387 ns -
LookupPositiveInfinity 49 PositiveOnly 21.5079 ns 0.2636 ns 0.2058 ns 21.5919 ns -
LookupNaN 49 PositiveOnly 15.6336 ns 0.2147 ns 0.1793 ns 15.6089 ns -
LookupWithInfiniteBounds 49 PositiveOnly 10.8612 ns 0.2498 ns 0.3068 ns 10.7812 ns -
LookupEmptyBounds 49 PositiveOnly 0.0376 ns 0.0310 ns 0.0527 ns 0.0060 ns -
LookupExactBoundary 50 MixedSigned 0.0460 ns 0.0288 ns 0.0563 ns 0.0235 ns -
LookupInRangeValue 50 MixedSigned 0.1542 ns 0.0904 ns 0.2667 ns 0.0000 ns -
LookupNegativeInfinity 50 MixedSigned 1.7275 ns 0.0568 ns 0.1023 ns 1.7084 ns -
LookupPositiveInfinity 50 MixedSigned 2.2397 ns 0.0768 ns 0.1404 ns 2.2436 ns -
LookupNaN 50 MixedSigned 0.0442 ns 0.0281 ns 0.0555 ns 0.0184 ns -
LookupWithInfiniteBounds 50 MixedSigned 0.0552 ns 0.0290 ns 0.0493 ns 0.0469 ns -
LookupEmptyBounds 50 MixedSigned 0.0523 ns 0.0270 ns 0.0545 ns 0.0442 ns -
LookupExactBoundary 50 PositiveOnly 0.0304 ns 0.0229 ns 0.0377 ns 0.0000 ns -
LookupInRangeValue 50 PositiveOnly 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupNegativeInfinity 50 PositiveOnly 1.7324 ns 0.0671 ns 0.1527 ns 1.7376 ns -
LookupPositiveInfinity 50 PositiveOnly 2.4364 ns 0.0678 ns 0.0634 ns 2.4470 ns -
LookupNaN 50 PositiveOnly 0.7791 ns 0.0495 ns 0.0678 ns 0.7592 ns -
LookupWithInfiniteBounds 50 PositiveOnly 0.3815 ns 0.0485 ns 0.0740 ns 0.3557 ns -
LookupEmptyBounds 50 PositiveOnly 0.0014 ns 0.0036 ns 0.0060 ns 0.0000 ns -
LookupExactBoundary 1000 MixedSigned 0.2292 ns 0.0361 ns 0.0506 ns 0.2088 ns -
LookupInRangeValue 1000 MixedSigned 0.2625 ns 0.0385 ns 0.0654 ns 0.2673 ns -
LookupNegativeInfinity 1000 MixedSigned 3.6791 ns 0.0242 ns 0.0214 ns 3.6714 ns -
LookupPositiveInfinity 1000 MixedSigned 4.5544 ns 0.1243 ns 0.2334 ns 4.6707 ns -
LookupNaN 1000 MixedSigned 0.1678 ns 0.0389 ns 0.1012 ns 0.1713 ns -
LookupWithInfiniteBounds 1000 MixedSigned 0.1998 ns 0.0236 ns 0.0184 ns 0.2030 ns -
LookupEmptyBounds 1000 MixedSigned 0.1847 ns 0.0385 ns 0.0704 ns 0.1987 ns -
LookupExactBoundary 1000 PositiveOnly 0.0645 ns 0.0245 ns 0.0633 ns 0.0509 ns -
LookupInRangeValue 1000 PositiveOnly 0.0000 ns 0.0000 ns 0.0000 ns 0.0000 ns -
LookupNegativeInfinity 1000 PositiveOnly 3.7157 ns 0.1082 ns 0.1063 ns 3.6949 ns -
LookupPositiveInfinity 1000 PositiveOnly 4.5028 ns 0.1236 ns 0.2496 ns 4.5693 ns -
LookupNaN 1000 PositiveOnly 0.0556 ns 0.0201 ns 0.0543 ns 0.0457 ns -
LookupWithInfiniteBounds 1000 PositiveOnly 0.1380 ns 0.0555 ns 0.1636 ns 0.0720 ns -
LookupEmptyBounds 1000 PositiveOnly 0.0362 ns 0.0255 ns 0.0273 ns 0.0410 ns -

Add note for histogram boundary upper limit.
@martincostello martincostello marked this pull request as ready for review April 25, 2026 14:55
@martincostello martincostello requested a review from a team as a code owner April 25, 2026 14:55
Copilot AI review requested due to automatic review settings April 25, 2026 14:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves histogram explicit-bound bucket lookup performance in the metrics pipeline, and adds a hard cap on the number of explicit boundaries to prevent pathological allocations/processing.

Changes:

  • Replaces the previous large-bound lookup strategy with a radix-partitioned search + SIMD-accelerated linear scan fallback.
  • Adds a 10,000,000 max explicit boundary count check for both view configuration and instrument advice.
  • Adds unit tests, fuzz/property tests, and benchmarks; updates changelog and solution/project wiring.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs Adds unit test validating boundary-count limit exception details.
test/OpenTelemetry.Tests/Metrics/AggregatorTests.cs Adds coverage for large-bound lookup edge cases (mixed signs, infinities, NaN, degenerate NaN bounds) and display-bounds cleanup.
test/OpenTelemetry.FuzzTests/OpenTelemetry.FuzzTests.csproj New fuzz test project for OpenTelemetry core metrics.
test/OpenTelemetry.FuzzTests/Metrics/HistogramExplicitBoundsFuzzTests.cs Adds FsCheck property tests comparing optimized path vs scalar baseline.
test/Benchmarks/Metrics/HistogramExplicitBoundsBenchmarks.cs Adds BenchmarkDotNet benchmarks for bucket lookup across sizes/layouts.
src/OpenTelemetry/OpenTelemetry.csproj Grants InternalsVisibleTo for the new OpenTelemetry.FuzzTests project.
src/OpenTelemetry/Metrics/View/ExplicitBucketHistogramConfiguration.cs Introduces MaxBoundaryCount and enforces it when setting Boundaries.
src/OpenTelemetry/Metrics/MetricStreamIdentity.cs Enforces MaxBoundaryCount for instrument advice-provided boundaries.
src/OpenTelemetry/Metrics/HistogramExplicitBounds.cs Implements radix-partitioned + SIMD-assisted bucket index lookup and infinity cleanup.
src/OpenTelemetry/CHANGELOG.md Documents the explicit-boundary cap as a breaking change.
OpenTelemetry.slnx Adds the new fuzz test project to the solution.
Comments suppressed due to low confidence (1)

src/OpenTelemetry/Metrics/View/ExplicitBucketHistogramConfiguration.cs:74

  • IsSortedAndDistinct currently treats double.NaN as valid because all comparisons with NaN return false, so arrays containing NaN can pass validation even though they are not meaningfully “ascending order with distinct values”. Consider explicitly rejecting NaN (and possibly non-finite values) in this check so Boundaries validation matches the documented requirements and downstream bucketing assumptions.
        for (var i = 1; i < values.Length; i++)
        {
            if (values[i] <= values[i - 1])
            {
                return false;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/OpenTelemetry/Metrics/MetricStreamIdentity.cs Outdated
Comment thread src/OpenTelemetry/Metrics/MetricStreamIdentity.cs Outdated
@martincostello martincostello added the keep-open Prevents issues and pull requests being closed as stale label May 7, 2026
@Kielek
Copy link
Copy Markdown
Member

Kielek commented May 19, 2026

@cijothomas, could you please check this PR? Especially adding boundaries?

@Kielek Kielek requested a review from cijothomas May 19, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

keep-open Prevents issues and pull requests being closed as stale perf Performance related pkg:OpenTelemetry Issues related to OpenTelemetry NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate possible histogram performance improvements

3 participants