{"record":{"id":"0f859ec9fc2f6886","repo":"thanos-io/thanos","slug":"exponential-histogram-data-point-has-zero-count-b","errorCode":null,"errorMessage":"exponential histogram data point has zero count, but non-zero sum: %f","messagePattern":"exponential histogram data point has zero count, but non-zero sum: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/receive/otlptranslator/histograms.go","lineNumber":124,"sourceCode":"\n\t\tPositiveSpans:  pSpans,\n\t\tPositiveDeltas: pDeltas,\n\t\tNegativeSpans:  nSpans,\n\t\tNegativeDeltas: nDeltas,\n\n\t\tTimestamp: convertTimeStamp(p.Timestamp()),\n\t}\n\n\tif p.Flags().NoRecordedValue() {\n\t\th.Sum = math.Float64frombits(value.StaleNaN)\n\t\th.Count = &prompb.Histogram_CountInt{CountInt: value.StaleNaN}\n\t} else {\n\t\tif p.HasSum() {\n\t\t\th.Sum = p.Sum()\n\t\t}\n\t\th.Count = &prompb.Histogram_CountInt{CountInt: p.Count()}\n\t\tif p.Count() == 0 && h.Sum != 0 {\n\t\t\tannots.Add(fmt.Errorf(\"exponential histogram data point has zero count, but non-zero sum: %f\", h.Sum))\n\t\t}\n\t}\n\treturn h, annots, nil\n}\n\n// convertBucketsLayout translates OTel Exponential Histogram dense buckets\n// representation to Prometheus Native Histogram sparse bucket representation.\n//\n// The translation logic is taken from the client_golang `histogram.go#makeBuckets`\n// function, see `makeBuckets` https://github.com/prometheus/client_golang/blob/main/prometheus/histogram.go\n// The bucket indexes conversion was adjusted, since OTel exp. histogram bucket\n// index 0 corresponds to the range (1, base] while Prometheus bucket index 0\n// to the range (base 1].\n//\n// scaleDown is the factor by which the buckets are scaled down. In other words 2^scaleDown buckets will be merged into one.\nfunc convertBucketsLayout(buckets pmetric.ExponentialHistogramDataPointBuckets, scaleDown int32) ([]prompb.BucketSpan, []int64) {\n\tbucketCounts := buckets.BucketCounts()\n\tif bucketCounts.Len() == 0 {","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/otlptranslator/histograms.go#L106-L142","documentation":"While converting exponential histograms, a data point with Count()==0 but a non-zero Sum is semantically contradictory. The code cannot error without losing the metric, so it records this message as an annotations.Annotations warning attached to the conversion result.","triggerScenarios":"OTLP ExponentialHistogram data point where Count is 0 but Sum != 0, produced by instruments that track sums separately from counts (e.g. reset counters mid-window, or sum-only aggregation).","commonSituations":"Counter resets in backend aggregation layers; buggy custom aggregators that emit sum without count; OTLP from languages where sum is a float and count is tracked independently and initialized late.","solutions":["Fix the telemetry source so count and sum are consistent (count 0 must imply sum 0)","Check aggregators/proxies that may drop bucket counts while retaining the sum after resets","Treat it as a warning annotation — the receiver usually converts it anyway; verify whether your pipeline drops annotated metrics","Upgrade the SDK; some versions had count/sum mismatch bugs on resets"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if dp.Count() == 0 && dp.HasSum() && dp.Sum() != 0 {\n    return errors.New(\"exponential histogram count/sum mismatch\")\n}","typeGuard":"func countSumConsistent(dp pmetric.ExponentialHistogramDataPoint) bool {\n    return dp.Count() != 0 || !dp.HasSum() || dp.Sum() == 0\n}","tryCatchPattern":"h, annots, err := exponentialToNativeHistogram(dp)\nfor _, a := range annots {\n    log.Warnf(\"annotation from conversion: %v\", a) // includes zero-count/non-zero-sum\n}","preventionTips":["Ensure aggregators treat count and sum atomically across counter resets","Drop or repair inconsistent data points upstream","Monitor annotation counts in your conversion path"],"tags":["otlp","histogram","annotation"],"backgroundTag":"inconsistent-metric-data","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}