microsoft/aspire · error · InvalidOperationException
Metric data point value must be finite.
Error message
Metric data point value must be finite.
What it means
Aspire Dashboard rejects OTLP number data points whose double value is NaN or infinity. Non-finite values cannot be meaningfully charted or aggregated, so ValidateNumberDataPoint throws this InvalidOperationException when an AsDouble gauge/sum value fails double.IsFinite. The check enforces that only well-formed numeric samples enter the telemetry repository.
Solutions
- Fix the instrumenting code so NaN/Infinity never reach the instrument (guard computations before recording values).
- Sanitize at export time, e.g. via a custom MetricReader/Processor or View configuration that drops or clamps non-finite measurements.
- Interpose an OpenTelemetry Collector processor (filter/transform) to discard data points with non-finite values before they reach the Dashboard.
Example fix
// before
meter.CreateGauge<double>("ratio").Record(num / denom);
// after
if (double.IsFinite(value))
{
gauge.Record(value);
} Defensive patterns
Strategy: validation
Validate before calling
// guard each measurement before recording if (!double.IsFinite(value)) return; // skip NaN/Inf instrument.Record(value);
Try / catch
try
{
repository.AddMetrics(request);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("value must be finite"))
{
logger.LogWarning(ex, "Dropping metric batch containing non-finite data point value.");
} Prevention
- Check divisors and math results for zero/NaN before recording measurements.
- Clamp or drop non-finite values in a processor/View before export.
- Enable debug exporter locally to catch NaN values early in development.
When it happens
Trigger: ValidateNumberDataPoint runs during OTLP metric import and throws when point.ValueCase == AsDouble and double.IsFinite(point.AsDouble) is false (NaN, +Inf, -Inf). In practice: an instrument or exporter emits a double gauge/histogram-sum value that is NaN or infinite.
Common situations: Application code that divides by zero or propagates NaN into a Gauge<double>/Counter<double>; serialization quirks sending raw NaN/Inf across the wire; upstream services computing averages of empty sets and exporting the result as a metric value.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Histogram data point has bucket counts without any explicit…
- Histogram data point sum must be finite.
- Circular loop detected for span
- Dimension limit of reached.
- Duplicate span id ' ' detected.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/08f4662c04e05abf.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Dashboard/Otlp/Model/OtlpHelpers.cs:76
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)
{
string? serviceName = null;
string? serviceInstanceId = null;
string? processExecutableName = null;
for (var i = 0; i < resource.Attributes.Count; i++)
{
var attribute = resource.Attributes[i];
if (attribute.Key == OtlpResource.SERVICE_INSTANCE_ID)
{
serviceInstanceId = attribute.Value.GetString();
}
if (attribute.Key == OtlpResource.SERVICE_NAME)
{View on GitHub (pinned to 25830f84bd)