Skip to content

Commit

Permalink
fix(metrics): use batches include when collecting metrics (#2765) fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Aug 28, 2024
1 parent b5761c9 commit 8276f72
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
16 changes: 16 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions lib/commands/moveToFinished-9.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 8276f72

Please sign in to comment.