{"record":{"id":"08f4662c04e05abf","repo":"microsoft/aspire","slug":"metric-data-point-value-must-be-finite","errorCode":null,"errorMessage":"Metric data point value must be finite.","messagePattern":"Metric data point value must be finite\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Dashboard/Otlp/Model/OtlpHelpers.cs","lineNumber":76,"sourceCode":"\n    internal static void ValidateHistogramDataPoint(HistogramDataPoint point)\n    {\n        if (!double.IsFinite(point.Sum))\n        {\n            throw new InvalidOperationException(\"Histogram data point sum must be finite.\");\n        }\n\n        if (point.BucketCounts.Count > 0 && point.ExplicitBounds.Count == 0)\n        {\n            throw new InvalidOperationException(\"Histogram data point has bucket counts without any explicit bounds.\");\n        }\n    }\n\n    internal static void ValidateNumberDataPoint(NumberDataPoint point)\n    {\n        if (point.ValueCase == NumberDataPoint.ValueOneofCase.AsDouble && !double.IsFinite(point.AsDouble))\n        {\n            throw new InvalidOperationException(\"Metric data point value must be finite.\");\n        }\n    }\n\n    public static ResourceKey GetResourceKey(this Resource resource)\n    {\n        string? serviceName = null;\n        string? serviceInstanceId = null;\n        string? processExecutableName = null;\n\n        for (var i = 0; i < resource.Attributes.Count; i++)\n        {\n            var attribute = resource.Attributes[i];\n            if (attribute.Key == OtlpResource.SERVICE_INSTANCE_ID)\n            {\n                serviceInstanceId = attribute.Value.GetString();\n            }\n            if (attribute.Key == OtlpResource.SERVICE_NAME)\n            {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Dashboard/Otlp/Model/OtlpHelpers.cs#L58-L94","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nmeter.CreateGauge<double>(\"ratio\").Record(num / denom);\n// after\nif (double.IsFinite(value))\n{\n    gauge.Record(value);\n}","handlingStrategy":"validation","validationCode":"// guard each measurement before recording\nif (!double.IsFinite(value)) return; // skip NaN/Inf\ninstrument.Record(value);","typeGuard":null,"tryCatchPattern":"try\n{\n    repository.AddMetrics(request);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"value must be finite\"))\n{\n    logger.LogWarning(ex, \"Dropping metric batch containing non-finite data point value.\");\n}","preventionTips":["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."],"tags":["opentelemetry","metrics","nan","validation","otlp"],"backgroundTag":"value-out-of-range","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}