Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(metrics): differentiate points in different minutes to be more accurate #2770

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/commands/includes/collectMetrics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local function collectMetrics(metaKey, dataPointsList, maxDataPoints, timestamp)
return
end

local N = math.min(math.floor((timestamp - prevTS) / 60000), tonumber(maxDataPoints))
local N = math.min(math.floor(timestamp / 60000) - math.floor(prevTS / 60000), tonumber(maxDataPoints))

if N > 0 then
local delta = count - rcall("HGET", metaKey, "prevCount")
Expand Down
4 changes: 4 additions & 0 deletions test/test_metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ describe('metrics', () => {
ONE_MINUTE,
ONE_MINUTE,
ONE_MINUTE * 3,
ONE_SECOND * 70,
ONE_SECOND * 50,
ONE_HOUR,
ONE_MINUTE
];
Expand Down Expand Up @@ -100,6 +102,8 @@ describe('metrics', () => {
'0',
'0',
'1',
'1',
'1',
'0',
'0',
'1',
Expand Down
Loading