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 (#2766) (python)
  • Loading branch information
roggervalf authored Sep 10, 2024
1 parent a8cb8a2 commit 7cb670e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/commands/includes/collectMetrics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local function collectMetrics(metaKey, dataPointsList, maxDataPoints,
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 tests/test_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ describe('metrics', function () {
ONE_MINUTE,
ONE_MINUTE,
ONE_MINUTE * 3,
ONE_SECOND * 70,
ONE_SECOND * 50,
ONE_HOUR,
ONE_MINUTE,
];
Expand Down Expand Up @@ -132,6 +134,8 @@ describe('metrics', function () {
'0',
'0',
'1',
'1',
'1',
'0',
'0',
'1',
Expand Down

0 comments on commit 7cb670e

Please sign in to comment.