BentoML icon indicating copy to clipboard operation
BentoML copied to clipboard

fix: order Prometheus histogram metrics correctly

Open robin-ede opened this issue 6 months ago • 1 comments

What does this PR address?

Prometheus histograms must list every _bucket before their _count and _sum.
Out-of-order output breaks parsers like fluent-bit.
This patch guarantees the correct order for all BentoML histogram metrics.

Changes

  • PrometheusClient
    • Add _fix_histogram_ordering()
      • Sorts buckets by le, then appends _count, _sum.
      • Transparent in single- and multi-process modes..

Checklist

  • [x] Conventional commit title.
  • [x] pre-commit run -a passes.
  • [x] No doc updates needed.
  • [x] Tests run.

Fixes #5386

robin-ede avatar Jul 01 '25 14:07 robin-ede

What caused us to have to use this dirty method to fix it? How does it produce output in wrong order?

frostming avatar Jul 02 '25 00:07 frostming