Skip to content

Commit 8276f72

Browse files
authored
fix(metrics): use batches include when collecting metrics (#2765) fixes #2764 #2763
1 parent b5761c9 commit 8276f72

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

index.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,23 @@ declare namespace Bull {
428428
every: number;
429429
}
430430

431+
interface DebounceOptions {
432+
/**
433+
* ttl in milliseconds
434+
*/
435+
ttl?: number;
436+
/**
437+
* Identifier
438+
*/
439+
id: string;
440+
}
441+
431442
interface JobOptions {
443+
/**
444+
* Debounce options.
445+
*/
446+
debounce?: DebounceOptions;
447+
432448
/**
433449
* Optional priority value. ranges from 1 (highest priority) to MAX_INT (lowest priority).
434450
* Note that using priorities has a slight impact on performance, so do not use it if not required

lib/commands/moveToFinished-9.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
]]
4343
local rcall = redis.call
4444

45+
-- Includes
46+
--- @include "includes/removeLock"
47+
--- @include "includes/removeDebounceKeyIfNeeded"
48+
--- @include "includes/batches"
49+
4550
--[[
4651
Functions to collect metrics based on a current and previous count of jobs.
4752
Granualarity is fixed at 1 minute.
@@ -68,7 +73,10 @@ local function collectMetrics(metaKey, dataPointsList, maxDataPoints, timestamp)
6873
local points = {}
6974
points[1] = delta
7075
for i = 2, N do points[i] = 0 end
71-
rcall("LPUSH", dataPointsList, unpack(points))
76+
77+
for from, to in batches(#points, 7000) do
78+
rcall("LPUSH", dataPointsList, unpack(points, from, to))
79+
end
7280
else
7381
-- LPUSH delta to the list
7482
rcall("LPUSH", dataPointsList, delta)
@@ -82,10 +90,6 @@ local function collectMetrics(metaKey, dataPointsList, maxDataPoints, timestamp)
8290
end
8391
end
8492

85-
-- Includes
86-
--- @include "includes/removeLock"
87-
--- @include "includes/removeDebounceKeyIfNeeded"
88-
8993
if rcall("EXISTS", KEYS[3]) == 1 then -- // Make sure job exists
9094
local errorCode = removeLock(KEYS[3], KEYS[8], ARGV[5], ARGV[1])
9195
if errorCode < 0 then

0 commit comments

Comments
 (0)