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
This commit adds two simple prometheus metrics to the http client that
is being used by the backend; "requests_total" and
"requests_duration_histogram_seconds". With that we should get some
initial visibility into backend failures, response times and client
requests per seconds as well.
I decided to register everything in an `init` function to the
`metrics.Gatherer`. Not perfect, but simple and probably good
enough for a long time. I got to that `metrics.Gatherer` type by
following the metrics-code of `controller-runtime`; I'm not sure if
there's a better way to register metrics to that Registry, or if using a
different registry would be fine as well and they'd simply get
interlaced?...
Additionally, controller-runtime also has a
[`rest_client_requests_total`
metric](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/metrics#pkg-constants)
that it registers. As far as I can tell, this is for the default
`http.Client` and comes from `client-go`. We could probably also make
use of that, but would be missing a latency bucket. That latency bucket
also exists, but is
[disabled by default](kubernetes-sigs/controller-runtime#1587)
because it created a cardinality explosion for some users, so I'm wary
to enable it as well.
By using a completely separate code-path and metrics-handler, we get
metrics for only our backend, instead of them being interlaced with
potential metrics from `client-go`. Additionally, we can start off with
both latency and count-metrics, as I don't think we'll have issues with
cardinality (we're only registering two labels - `client-go` also
registered a "url" label which is not optimal).
0 commit comments