Skip to main content

Module legacy_bridge

Module legacy_bridge 

Source
Expand description

The legacy native-histogram estimators, delegated to the native kernel.

prom_native_histogram_quantile and prom_native_histogram_fraction used to estimate with the bucket walk inside NativeHistogram itself: exponential bucket bounds computed as 2^x, and a forward walk from the lowest bucket only. The native kernel (histogram_eval) walks the same histogram the way Prometheus does – the bound table in bounds and, for a quantile above the median of a histogram whose sum is not NaN, a walk from the highest bucket down – so keeping both estimators leaves two answers for one histogram that differ in their last places.

These functions read a [NativeHistogram] through the borrowed [HistogramView] that both representations share, hand it to the kernel as the FloatHistogram the kernel owns, and return the answer in the shape the legacy UDFs report it. The scalar arithmetic – add, sub, scale, divide_by – takes the same route below the estimators, so Prometheus’s rules for reconciling a zero bucket, reducing a schema and intersecting custom bounds live in one place.

Structs§

LegacyView 🔒
A [NativeHistogram] borrowed as a [HistogramView], the form the native kernel reads.

Functions§

add 🔒
left + right, or None for a pair the kernel refuses to combine.
bucket_counts 🔒
bucket_total 🔒
What the populated buckets hold, summed in the order the kernel walks them: the negative side from its highest index down, the zero bucket, then the positive side upwards.
combine 🔒
divide_by 🔒
histogram / divisor, with no buckets left for a zero divisor.
field_divided 🔒
field_scaled 🔒
float_histogram 🔒
The native kernel’s owned form of histogram.
fraction_with_info 🔒
histogram_fraction(lower, upper, histogram), with whether NaN observations were excluded.
legacy_histogram 🔒
The legacy representation of histogram, with the span layout it carries.
legacy_spans 🔒
nan_observation_info 🔒
The note for a NaN observation, which the kernel accounts for but does not report.
quantile_with_info 🔒
histogram_quantile(q, histogram), with the NaN-observation note the legacy UDF records.
scale 🔒
histogram * factor, a gauge histogram for a negative factor.
span_columns 🔒
steps_backwards 🔒
Whether a span list steps backwards, which the legacy bucket_indices refused.
sub 🔒
left - right, a gauge histogram the way Prometheus’s - leaves it.