Fix a bucket mapping issue with the origin inspector latency metrics #172
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 exporter maps bucketed counters from the real-time stats API to a Prometheus histogram. Since it doesn't have the actual values that were used to build the bucketed counters it has to pick a value for each bucket to call Observe() with.
The current code uses values that are mapping to the wrong buckets. Here's a subset of the buckets from the origin latency histogram definition:
0.001, 0.005, 0.010
Calling Observe() with the value of 0.005 places the value in the 1-5ms bucket, not the 5-10ms bucket. The result of the current behavior is that the counts for each bucket are shifted to the next smallest bucket.
This fixes the issue by using the values at the end of each bucket interval as the parameters to Observe(). This will result in increased origin latency values when users upgrade to a release with this commit, but the increased numbers are more accurate.