microsoft/aspire · error · InvalidOperationException
Histogram data point sum must be finite.
Error message
Histogram data point sum must be finite.
What it means
OtlpHelpers.ValidateHistogramDataPoint sanity-checks incoming OTLP histogram points before they are converted into dashboard metrics. A histogram sum of NaN or infinity cannot be charted or aggregated, so it throws InvalidOperationException. Companion checks require explicit bounds when bucket counts are present.
Solutions
- Fix the emitting application so recorded values are finite — guard against NaN/Infinity before recording histogram measurements
- Sanitize sums at the collector (filter/transform processor) to drop or repair non-finite data points
- Identify the offending instrument via the metric name/dimensions in the failing export and add validation at the instrumentation site
- Update the metrics SDK/instrument library if the non-finite sum originates from a known bug
Example fix
// before
histogram.Record(duration.TotalMilliseconds); // may be NaN when stopwatch failed
// after
var ms = duration.TotalMilliseconds;
if (double.IsFinite(ms))
{
histogram.Record(ms);
} Defensive patterns
Strategy: validation
Validate before calling
if (!double.IsFinite(dataPoint.Sum))
throw new InvalidOperationException("Rejecting histogram point: Sum is NaN or infinite.");
if (dataPoint.BucketCounts.Count > 0 && dataPoint.ExplicitBounds.Count == 0)
throw new InvalidOperationException("Bucket counts require explicit bounds."); Type guard
static bool IsValidHistogramDataPoint(HistogramDataPoint p) =>
double.IsFinite(p.Sum) &&
(p.BucketCounts.Count == 0 || p.ExplicitBounds.Count > 0); Try / catch
try { ConvertHistogram(dataPoint); }
catch (InvalidOperationException ex)
{
logger.LogWarning(ex, "Skipping invalid OTLP histogram data point for metric {Name}.", point.MetricName);
} Prevention
- Guard recorded values against NaN/Infinity at instrumentation time
- Fix timer/clock conversions that can yield NaN durations
- Sanitize metric streams at the collector before export
When it happens
Trigger: Receiving an OTLP ExportMetricsServiceRequest whose histogram data point Sum is NaN or +/-Infinity — typically from a producer computing sums with non-finite values (division by zero, NaN counters) before exporting.
Common situations: Instrumentation bugs where the sum accumulates NaN (e.g. recording NaN durations); exotic timers/clocks producing infinite values; third-party meters exporting degenerate histograms; metric data corrupted upstream.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Histogram data point has bucket counts without any explicit…
- Metric data point value must be finite.
- Dimension limit of reached.
- Histogram data point bucket count length changed.
- Histogram data point bucket count length changed.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/fb804e76ef88ecfd.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Dashboard/Otlp/Model/OtlpHelpers.cs:63
internal static int GetMetricDataPointCount(Metric metric)
{
return metric.DataCase switch
{
Metric.DataOneofCase.Gauge => metric.Gauge.DataPoints.Count,
Metric.DataOneofCase.Sum => metric.Sum.DataPoints.Count,
Metric.DataOneofCase.Histogram => metric.Histogram.DataPoints.Count,
Metric.DataOneofCase.Summary => metric.Summary.DataPoints.Count,
Metric.DataOneofCase.ExponentialHistogram => metric.ExponentialHistogram.DataPoints.Count,
_ => 0,
};
}
internal static void ValidateHistogramDataPoint(HistogramDataPoint point)
{
if (!double.IsFinite(point.Sum))
{
throw new InvalidOperationException("Histogram data point sum must be finite.");
}
if (point.BucketCounts.Count > 0 && point.ExplicitBounds.Count == 0)
{
throw new InvalidOperationException("Histogram data point has bucket counts without any explicit bounds.");
}
}
internal static void ValidateNumberDataPoint(NumberDataPoint point)
{
if (point.ValueCase == NumberDataPoint.ValueOneofCase.AsDouble && !double.IsFinite(point.AsDouble))
{
throw new InvalidOperationException("Metric data point value must be finite.");
}
}
public static ResourceKey GetResourceKey(this Resource resource)
{View on GitHub (pinned to 25830f84bd)