fix: Prometheus client missing time argument #605
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Prometheus backend query method does not propagate the timestamp argument passed on from the compute function upstream.
This results in the twin queries used for good/bad ratio method to default to now (see https://github.com/tomoncle/prometheus-http-client/blob/master/prometheus_http_client/prometheus/client.py#L78) separately. In some cases, this very slight delay is sufficient to cause inconsistencies in the SLO calculation.
This problem seems related to issues like #319. The symptoms on my end where exactly the same as #343, though for a Prometheus backend: we observed random spikes of error counts.
As the
timestampargument already existed in the method signature, but was left unused in the code, I assume this is an oversight.Looking deeper into the code, it turns out that the distribution_cut method did not pass the
timestampargument either to the query method. I initially only tested this with the good_bad_ratio method, so the first version of this fix missed this omission as well.