Skip to content

Opt-in REST client metrics: allow overriding histogram buckets (sub-5ms resolution for fast controllers) #3559

Description

@aditya-shantanu

Context

We've been using the opt-in REST client metrics from #3510 (thanks for that work — also for the cherry-pick to release-0.24 in #3525) during a controller latency investigation in kubernetes-sigs/agent-sandbox, where they were instrumental in finding client-side bottlenecks (e.g. HTTP/2 stream-limit queuing that is invisible to server-side metrics).

Problem

The classic buckets for rest_client_request_duration_seconds and rest_client_rate_limiter_duration_seconds start at 5ms:

Buckets: []float64{0.005, 0.025, 0.1, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 15.0, 30.0, 60.0},

For controllers whose hot-path requests are fast — in our case warm-path PATCH/PUT calls with real p50s in the 1–15ms range — everything below 5ms collapses into the first bucket and the 5–25ms span into the second, so p50/p90 estimates over the exact range being optimized are mostly quantization artifact.

We're aware NativeHistogramBucketFactor is set, and native histograms fully solve this where the scrape pipeline supports them — but many pipelines still consume only classic buckets.

Ask

Since the file documents that the default buckets intentionally mirror core Kubernetes, changing the defaults seems off the table. Instead: would you accept making buckets overridable at registration, e.g. an options variant of RegisterRESTClientMetrics (or a WithBuckets-style option) that applies caller-supplied buckets before the collectors are registered? Callers who need low-end resolution could then prepend e.g. 0.001, 0.0025 without any divergence in the defaults.

Happy to send a PR if maintainers are open to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions