fix(metrics): use batches include when collecting metrics (#2765) fixes #2764 #2763

This commit is contained in:
Rogger Valverde
2024-08-27 22:15:10 -06:00
committed by GitHub
parent b5761c96bd
commit 8276f72b30
2 changed files with 25 additions and 5 deletions
Vendored
+16
View File
@@ -428,7 +428,23 @@ declare namespace Bull {
every: number;
}
interface DebounceOptions {
/**
* ttl in milliseconds
*/
ttl?: number;
/**
* Identifier
*/
id: string;
}
interface JobOptions {
/**
* Debounce options.
*/
debounce?: DebounceOptions;
/**
* Optional priority value. ranges from 1 (highest priority) to MAX_INT (lowest priority).
* Note that using priorities has a slight impact on performance, so do not use it if not required
+9 -5
View File
@@ -42,6 +42,11 @@
]]
local rcall = redis.call
-- Includes
--- @include "includes/removeLock"
--- @include "includes/removeDebounceKeyIfNeeded"
--- @include "includes/batches"
--[[
Functions to collect metrics based on a current and previous count of jobs.
Granualarity is fixed at 1 minute.
@@ -68,7 +73,10 @@ local function collectMetrics(metaKey, dataPointsList, maxDataPoints, timestamp)
local points = {}
points[1] = delta
for i = 2, N do points[i] = 0 end
rcall("LPUSH", dataPointsList, unpack(points))
for from, to in batches(#points, 7000) do
rcall("LPUSH", dataPointsList, unpack(points, from, to))
end
else
-- LPUSH delta to the list
rcall("LPUSH", dataPointsList, delta)
@@ -82,10 +90,6 @@ local function collectMetrics(metaKey, dataPointsList, maxDataPoints, timestamp)
end
end
-- Includes
--- @include "includes/removeLock"
--- @include "includes/removeDebounceKeyIfNeeded"
if rcall("EXISTS", KEYS[3]) == 1 then -- // Make sure job exists
local errorCode = removeLock(KEYS[3], KEYS[8], ARGV[5], ARGV[1])
if errorCode < 0 then