Skip to content

Commit

Permalink
fix(metrics): differentiate points in different minutes to be more ac…
Browse files Browse the repository at this point in the history
…curate (#2770)
  • Loading branch information
roggervalf authored Sep 10, 2024
1 parent f59473b commit fbf2fa3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit fbf2fa3

Please sign in to comment.