A one-line type bug that hid p99 latency in MinIO
I did not go looking for a bug in MinIO. I went looking for a p99.
We were running MinIO as the object store under a lakehouse experiment, and I was wiring its metrics into Prometheus so I could put one honest latency chart on a dashboard. Time-to-first-byte is the number I wanted: it tells you how long a client waits before the first byte of an object arrives, which is the part users feel. MinIO exports a distribution for it, so the query should have been boring:
histogram_quantile(0.99, sum by (le) (rate(minio_s3_ttfb_seconds_distribution[5m])))
The panel came back empty. No error, no warning, just an empty graph. That silence is the whole story.
What histogram_quantile() expects
A Prometheus histogram is not one series. It is a family of series: a _bucket series per upper bound, each carrying an le label, plus _sum and _count. histogram_quantile() walks those buckets, finds where the requested fraction of observations falls, and interpolates. It is picky about its input in a way that is easy to forget: the series must be cumulative buckets with le labels. Give it anything else and it does not complain. It returns an empty result.
MinIO was emitting the TTFB distribution with le labels, so at first glance the shape looked right. The difference was the metric type in the exposition format. The # TYPE line said gauge.
Why a gauge fails silently
Prometheus itself does not validate types on scrape. It stores whatever samples arrive. The type only matters to the client side: PromQL functions that are defined for histograms check that the input looks like one. A gauge with le labels is, to the function, a set of unrelated gauges. There is nothing to interpolate across, so the result set is empty, and an empty result set is not an error in PromQL. Your dashboard shows a flat nothing and every other panel keeps working.
This is the failure mode that worries me most in observability work. A wrong number is bad, but somebody eventually notices a wrong number. An empty panel gets deleted, or replaced by an average, and the p99 you actually needed quietly stops existing.
The fix
The change itself is small: declare the TTFB distribution as a histogram so the exposition says # TYPE ... histogram and the series are published as a proper bucket family. In cmd/metrics-v2.go the two TTFB descriptions, per API call and per bucket, changed like this:
Help: "Distribution of time to first byte across API calls",
-Type: gaugeMetric,
+Type: histogramMetric,
+Buckets: []float64{0.01, 0.05, 0.1, 0.5, 1.0, 2.0, 5.0},
The Buckets field is new on MetricDescription; the rest of the diff is the regenerated MessagePack code for it.
The pull request is minio/minio#20999, titled "Fix: Change TTFB metric type to histogram". I opened it on 2 March 2025 and it was merged on 2 April 2025. Harshavardhana, MinIO's co-founder, reviewed it himself: one round of changes requested over a Go formatting detail, then approval and merge the next morning. The metric name did not change afterwards; ttfb_seconds_distribution is still what the current master exposes.
The meaningful diff being one line is exactly why it survived so long. Nobody reviews the type line of a metric declaration. Tests check that the metric exists and that the value moves. They do not run a PromQL quantile against the scrape output, which is the only test that would have caught this.
Working in a 60k-star Go codebase as a non-Go-daily developer
I write Python and Scala for a living. Go is a language I read more than I write. A few things made the contribution manageable:
- The metrics layer is its own package. I never had to understand the object storage internals to fix how a number is described. Finding the declaration took longer than changing it.
- The reviewers asked for evidence, not style. The useful part of the PR description was a before/after scrape and the PromQL query that went from empty to a number. That is the artefact a maintainer can verify in a minute.
- CI does the formatting argument for you.
gofmtand the linters settle the questions a newcomer would otherwise get wrong.
It is also a good reminder that "contributing to open source" is mostly reporting precisely. The code change was trivial. The work was proving that the metric was unusable as published, and that the fix made the standard query work.
The follow-up in Delta Lake
Around the same time I opened a second change, this time in Delta Lake: delta-io/delta#4225, "Fix handling of LocalDate in Delta table metadata query optimization". It is still open. The bug: the metadata-only COUNT/MIN/MAX path assumed a DATE column's statistics arrive as java.sql.Date, so when Spark hands it a java.time.LocalDate the blind cast throws a ClassCastException; the fix matches on both types. As of October 2026 it has had no review. The stale bot tried to close it in September 2026 and a committer marked it "not stale", so it is alive, just waiting. The pattern is the same as the MinIO one: a narrow correctness issue that only shows up when you actually run the thing against real data, found while doing the day job rather than while looking for things to contribute.
What I took from it
- If a metric is meant for quantiles, test it with
histogram_quantile()in CI, not with "the series exists". - Treat an empty PromQL result on a known-good metric as a bug report, not as "no traffic yet".
- The cheapest open-source contribution is the one you make while using the software for real. You already have the reproduction.
If you maintain an exporter, grep your # TYPE lines once. It costs nothing and it is where this class of bug lives.