Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading