client_golang
client_golang copied to clipboard
promlint: Add timestamp_seconds suffix restriction
What this PR does
Add a rule to promlint, restricting timestamp_seconds suffix for non-gauge metrics.
timestamp_seconds metrics are not cumulative and shouldn't be split to buckets or quantiles. They should be of gauge type.
For example, in https://kubernetes.io/docs/reference/instrumentation/metrics/#list-of-stable-kubernetes-metrics and https://github.com/kubernetes/kube-state-metrics/tree/main/docs/metrics, all timestamp_seconds metrics are gauges.
@ArthurSens Can you please review this PR?
Isn't there a linter that already fails if a counter doesn't end with _total? Wouldn't it catch this case as well?
Isn't there a linter that already fails if a counter doesn't end with
_total? Wouldn't it catch this case as well?
@ArthurSens For counters yes, but it won't catch other metrics types using the timestamp_seconds suffix. I don't see how timestamps are relevant for histogram and summaries, since they shouldn't be split to buckets or quantiles, so I think this validation makes sense.
@bwplotka thanks for your review :)