You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenMetrics parser drops native histogram spans with a negative offset #1232
prometheus_client.openmetrics.parser.text_string_to_metric_families silently drops positive_spans and negative_spans when a span offset is negative. The deltas are still parsed, so the resulting NativeHistogram has pos_spans=None (or neg_spans=None) next to a non empty pos_deltas, which no longer describes the original histogram.
The offset of the first span is the starting bucket index, and it is negative for any bucket whose upper bound is below 1. With schema 0, an observation of 0.3 falls in bucket index -1, so this affects most histograms measured in seconds.
The client's own exposition writes these offsets as is, so its output does not round trip through its own parser.
What should happen
Spans with a negative offset are parsed into BucketSpan objects like any other span.
Minimal repro
fromprometheus_client.openmetrics.parserimporttext_string_to_metric_familiestext="""# TYPE nh histogramnh {count:2,sum:0.7,schema:0,zero_threshold:0.001,zero_count:0,positive_spans:[-2:2],positive_deltas:[1,0]}# EOF"""print(list(text_string_to_metric_families(text))[0].samples[0].native_histogram)
Activity