bookingcom / carbonapi

High-performance Graphite frontend in Go
Other
81 stars 23 forks source link

TimeLagSeries function fix #499

Closed nick-demianchuk closed 11 months ago

nick-demianchuk commented 11 months ago

What issue is this change attempting to solve?

TimeSeriesLag function calculates time-based lag (e.g. for Kafka offsets) based on two offsets metrics - consumer and producer.

Currently the lag function has a bug that produces negative values in some cases.

image

This MR simplifies and updates the logic of the function, and fixes this bug.

How does this change solve the problem? Why is this the best approach?

Code changes make the logic of lag calculation more understandable and account for the bug that was producing the negative values

How can we be sure this works as expected?

Additional tests were added, broken tests were fixed