@worker-manager/metrics 1.1.0 → 9.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -86
- package/dist/HistoryAdmin.d.ts +87 -23
- package/dist/HistoryAdmin.js +330 -21
- package/dist/HistoryAdmin.js.map +1 -1
- package/dist/HistoryStore.d.ts +9 -9
- package/dist/HistoryStore.js +0 -22
- package/dist/HistoryStore.js.map +1 -1
- package/dist/LatencySampler.d.ts +32 -27
- package/dist/LatencySampler.js +156 -55
- package/dist/LatencySampler.js.map +1 -1
- package/dist/LatencyStore.d.ts +3 -8
- package/dist/LatencyStore.js +0 -18
- package/dist/LatencyStore.js.map +1 -1
- package/dist/MetricsRecorder.d.ts +10 -34
- package/dist/MetricsRecorder.js +20 -30
- package/dist/MetricsRecorder.js.map +1 -1
- package/dist/RedisMetricsHistoryProvider.d.ts +17 -7
- package/dist/RedisMetricsHistoryProvider.js +136 -9
- package/dist/RedisMetricsHistoryProvider.js.map +1 -1
- package/dist/index.d.ts +2 -10
- package/dist/index.js +1 -10
- package/dist/index.js.map +1 -1
- package/dist/keys.d.ts +0 -7
- package/dist/keys.js +1 -23
- package/dist/keys.js.map +1 -1
- package/package.json +4 -14
- package/dist/RedisHistoryAdmin.d.ts +0 -95
- package/dist/RedisHistoryAdmin.js +0 -328
- package/dist/RedisHistoryAdmin.js.map +0 -1
- package/dist/RedisMetricsStore.d.ts +0 -27
- package/dist/RedisMetricsStore.js +0 -42
- package/dist/RedisMetricsStore.js.map +0 -1
- package/dist/StoreHistoryProvider.d.ts +0 -27
- package/dist/StoreHistoryProvider.js +0 -127
- package/dist/StoreHistoryProvider.js.map +0 -1
- package/dist/jobSources.d.ts +0 -97
- package/dist/jobSources.js +0 -248
- package/dist/jobSources.js.map +0 -1
- package/dist/postgres/PostgresMetricsHistoryProvider.d.ts +0 -37
- package/dist/postgres/PostgresMetricsHistoryProvider.js +0 -30
- package/dist/postgres/PostgresMetricsHistoryProvider.js.map +0 -1
- package/dist/postgres/PostgresMetricsStore.d.ts +0 -65
- package/dist/postgres/PostgresMetricsStore.js +0 -88
- package/dist/postgres/PostgresMetricsStore.js.map +0 -1
- package/dist/postgres/admin.d.ts +0 -31
- package/dist/postgres/admin.js +0 -178
- package/dist/postgres/admin.js.map +0 -1
- package/dist/postgres/connection.d.ts +0 -53
- package/dist/postgres/connection.js +0 -54
- package/dist/postgres/connection.js.map +0 -1
- package/dist/postgres/context.d.ts +0 -29
- package/dist/postgres/context.js +0 -76
- package/dist/postgres/context.js.map +0 -1
- package/dist/postgres/schema.d.ts +0 -26
- package/dist/postgres/schema.js +0 -148
- package/dist/postgres/schema.js.map +0 -1
- package/dist/postgres/stores.d.ts +0 -51
- package/dist/postgres/stores.js +0 -252
- package/dist/postgres/stores.js.map +0 -1
- package/dist/store.d.ts +0 -80
- package/dist/store.js +0 -3
- package/dist/store.js.map +0 -1
package/dist/HistoryAdmin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryAdmin.js","sourceRoot":"","sources":["../src/HistoryAdmin.ts"],"names":[],"mappings":";;;AACA,2DAAwD;AAGxD,yDAAsD;AAA7C,oHAAA,eAAe,OAAA;AAgExB;;;GAGG;AACH,MAAa,mBAAmB;IAK9B,YAAY,IAAgC;QAC1C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC;YACzC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,IAAI,qCAAiB,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAC1F,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;YACpC,IAAI,CAAC,UAAU,GAAG,KAAK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AC;wBACnB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;wBACd,MAAM,GAAG,CAAC;oBACZ,CAAC;gBACH,CAAC;YACH,CAAC,QAAQ,MAAM,KAAK,GAAG,EAAE;QAC3B,CAAC;IACH,CAAC;CACF;AA1RD,kDA0RC"}
|
package/dist/HistoryStore.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { MetricsClient } from './connection';
|
|
2
|
-
import type { MinutePoint } from './dataMapping';
|
|
3
2
|
import { type MetricsKeys } from './keys';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export interface Retention {
|
|
4
|
+
/** Days of minute-level detail. Doubles as the recorder's catch-up window. */
|
|
5
|
+
minutes: number;
|
|
6
|
+
/** Days of hourly rollup. */
|
|
7
|
+
hours: number;
|
|
8
|
+
/** Days of daily totals, which is what the shipped charts read. */
|
|
9
|
+
days: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class HistoryStore {
|
|
8
12
|
private readonly redis;
|
|
9
13
|
private readonly keys;
|
|
10
14
|
readonly retention: Retention;
|
|
@@ -14,10 +18,6 @@ export declare class HistoryStore implements CounterStore {
|
|
|
14
18
|
retention: Retention;
|
|
15
19
|
});
|
|
16
20
|
upsertMinute(queue: string, metric: string, minute: number, value: number): Promise<void>;
|
|
17
|
-
/** One EVAL per minute, in order, exactly as a caller looping `upsertMinute` would. */
|
|
18
|
-
upsertMinutes(queue: string, metric: string, points: MinutePoint[]): Promise<void>;
|
|
19
|
-
readDailyTotals(queue: string, metric: string, days: string[]): Promise<(number | null)[]>;
|
|
20
|
-
readHours(queue: string, metric: string, days: string[]): Promise<Record<string, number>>;
|
|
21
21
|
/**
|
|
22
22
|
* Raw HMGET of the totals hash: `null` means the day was never recorded, a present
|
|
23
23
|
* string (including `'0'`) means it was. Distinguishing "missing" from "stored zero"
|
package/dist/HistoryStore.js
CHANGED
|
@@ -73,7 +73,6 @@ const SECONDS_PER_DAY = 86400;
|
|
|
73
73
|
function ttl(days) {
|
|
74
74
|
return String(Math.max(1, Math.floor(days * SECONDS_PER_DAY)));
|
|
75
75
|
}
|
|
76
|
-
/** The Redis `CounterStore`: one hash per queue, metric and day, rolled up by one EVAL. */
|
|
77
76
|
class HistoryStore {
|
|
78
77
|
constructor(opts) {
|
|
79
78
|
this.redis = opts.redis;
|
|
@@ -88,27 +87,6 @@ class HistoryStore {
|
|
|
88
87
|
const day = (0, keys_1.minuteToDay)(minute);
|
|
89
88
|
await this.redis.eval(UPSERT_MINUTE, 6, this.keys.day(queue, metric, day), this.keys.hour(queue, metric, day), this.keys.totals(queue, metric), this.keys.day(keys_1.GLOBAL_QUEUE, metric, day), this.keys.hour(keys_1.GLOBAL_QUEUE, metric, day), this.keys.totals(keys_1.GLOBAL_QUEUE, metric), String(minute), String((0, keys_1.minuteToHour)(minute)), day, String(value), ttl(this.retention.minutes), ttl(this.retention.hours), ttl(this.retention.days), (0, keys_1.shiftDay)(day, -this.retention.days));
|
|
90
89
|
}
|
|
91
|
-
/** One EVAL per minute, in order, exactly as a caller looping `upsertMinute` would. */
|
|
92
|
-
async upsertMinutes(queue, metric, points) {
|
|
93
|
-
for (const point of points) {
|
|
94
|
-
await this.upsertMinute(queue, metric, point.minute, point.value);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async readDailyTotals(queue, metric, days) {
|
|
98
|
-
const raw = await this.readDailyTotalsRaw(queue, metric, days);
|
|
99
|
-
return raw.map((value) => (value == null ? null : Number(value) || 0));
|
|
100
|
-
}
|
|
101
|
-
async readHours(queue, metric, days) {
|
|
102
|
-
var _a;
|
|
103
|
-
const out = {};
|
|
104
|
-
const perDay = await Promise.all(days.map((day) => this.readDayHours(queue, metric, day)));
|
|
105
|
-
for (const hours of perDay) {
|
|
106
|
-
for (const field of Object.keys(hours)) {
|
|
107
|
-
out[field] = ((_a = out[field]) !== null && _a !== void 0 ? _a : 0) + hours[field];
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return out;
|
|
111
|
-
}
|
|
112
90
|
/**
|
|
113
91
|
* Raw HMGET of the totals hash: `null` means the day was never recorded, a present
|
|
114
92
|
* string (including `'0'`) means it was. Distinguishing "missing" from "stored zero"
|
package/dist/HistoryStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryStore.js","sourceRoot":"","sources":["../src/HistoryStore.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"HistoryStore.js","sourceRoot":"","sources":["../src/HistoryStore.ts"],"names":[],"mappings":";;;AACA,iCAA6F;AAW7F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CrB,CAAC;AAEF,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,SAAS,GAAG,CAAC,IAAY;IACvB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,MAAa,YAAY;IAKvB,YAAY,IAAuE;QACjF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG;YACf,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACxD,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACpD,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,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OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,GAAW;QACvC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,GAAG,GAA2B,EAAE,CAAC;QACvC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,GAAG,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAjGD,oCAiGC"}
|
package/dist/LatencySampler.d.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import type { BaseAdapter } from '@worker-manager/api/baseAdapter';
|
|
2
2
|
import type { MetricsClient } from './connection';
|
|
3
3
|
import type { MetricsKeys } from './keys';
|
|
4
|
-
import type {
|
|
4
|
+
import type { LatencyStore } from './LatencyStore';
|
|
5
5
|
export interface LatencySamplerOptions {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* used. PostgreSQL-backed queues are always read through their own pool.
|
|
10
|
-
*/
|
|
11
|
-
redis?: MetricsClient;
|
|
12
|
-
/** Unused since the lease and watermark moved into `store`. Accepted for compatibility. */
|
|
13
|
-
keys?: MetricsKeys;
|
|
14
|
-
store: LatencyStorage;
|
|
6
|
+
redis: MetricsClient;
|
|
7
|
+
keys: MetricsKeys;
|
|
8
|
+
store: LatencyStore;
|
|
15
9
|
/** Recorder tick, used to size the lease and to bound a cold start. */
|
|
16
10
|
tickMs: number;
|
|
17
11
|
/** Above this, the tick subsamples uniformly rather than fetching every job. */
|
|
@@ -32,26 +26,24 @@ export interface LatencySamplerOptions {
|
|
|
32
26
|
onError?: (error: unknown, queueName: string) => void;
|
|
33
27
|
}
|
|
34
28
|
/**
|
|
35
|
-
* Copies job durations out of
|
|
36
|
-
*
|
|
37
|
-
* Both backends index finished jobs by finish time (Redis: the completed and failed sorted
|
|
38
|
-
* sets; PostgreSQL: `job_finished_idx`), so scanning past a stored watermark returns exactly
|
|
39
|
-
* the jobs finished since the last tick, with no gaps and no bias. The only loss is a queue
|
|
40
|
-
* whose removeOnComplete trims faster than the tick runs.
|
|
29
|
+
* Copies job durations out of BullMQ's finished sets on the recorder's tick.
|
|
41
30
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
31
|
+
* BullMQ's moveToFinished does `ZADD targetSet, timestamp, jobId` and writes the same value
|
|
32
|
+
* to finishedOn, so the completed and failed sets are sorted sets scored by finish time.
|
|
33
|
+
* Scanning past a stored watermark therefore returns exactly the jobs finished since the
|
|
34
|
+
* last tick, with no gaps and no bias. The only loss is a queue whose removeOnComplete
|
|
35
|
+
* trims faster than the tick runs.
|
|
45
36
|
*/
|
|
46
37
|
export declare class LatencySampler {
|
|
47
38
|
private readonly redis;
|
|
39
|
+
private readonly keys;
|
|
48
40
|
private readonly store;
|
|
49
41
|
private readonly tickMs;
|
|
50
42
|
private readonly maxSamples;
|
|
51
43
|
private readonly safetyMarginMs;
|
|
52
44
|
private readonly onError?;
|
|
53
45
|
private readonly id;
|
|
54
|
-
private readonly
|
|
46
|
+
private readonly redisBacked;
|
|
55
47
|
constructor(opts: LatencySamplerOptions);
|
|
56
48
|
static supports(adapter: BaseAdapter): boolean;
|
|
57
49
|
/**
|
|
@@ -61,15 +53,21 @@ export declare class LatencySampler {
|
|
|
61
53
|
* indistinguishable from a queue with nothing to sample.
|
|
62
54
|
*/
|
|
63
55
|
sample(adapter: BaseAdapter): Promise<void>;
|
|
56
|
+
/** `getQueueKey` answers for a PostgreSQL-backed queue too, with keys no Redis holds. */
|
|
57
|
+
private isRedisBacked;
|
|
64
58
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
59
|
+
* Increments are not idempotent the way the counter upsert is, so two recorders scanning
|
|
60
|
+
* the same range would double every histogram. Only the lease holder scans.
|
|
61
|
+
*
|
|
62
|
+
* The TTL is a crash ceiling, not the normal lifetime: a process that dies mid-scan must
|
|
63
|
+
* not lock the queue out forever. The normal path releases in a finally, because a lease
|
|
64
|
+
* outliving its scan would make the next tick no-op and halve the sampling rate.
|
|
69
65
|
*/
|
|
70
|
-
private
|
|
66
|
+
private acquireLease;
|
|
67
|
+
/** Compare and delete, so a lease that already expired and was retaken is left alone. */
|
|
68
|
+
private releaseLease;
|
|
71
69
|
/**
|
|
72
|
-
* Bounded rather than eternal: an unexpiring watermark would leave one
|
|
70
|
+
* Bounded rather than eternal: an unexpiring watermark would leave one key behind per
|
|
73
71
|
* queue forever once that queue is purged or decommissioned, which is exactly the
|
|
74
72
|
* unbounded-storage failure this package exists to avoid. The day retention is already the
|
|
75
73
|
* horizon everything else here is bounded by. Losing the watermark just means the next
|
|
@@ -78,6 +76,13 @@ export declare class LatencySampler {
|
|
|
78
76
|
private watermarkTtlSeconds;
|
|
79
77
|
private sampleDurations;
|
|
80
78
|
private flush;
|
|
81
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* The backlog is not all in one place. `wait` holds it while the queue is running, but
|
|
81
|
+
* pausing RENAMEs that list to `paused` and routes new jobs there, and anything added with
|
|
82
|
+
* a priority goes to the `prioritized` sorted set instead, which can leave `wait`
|
|
83
|
+
* permanently empty. Reading only `wait` reports a healthy zero for a queue that is badly
|
|
84
|
+
* backed up, which is the opposite of what this gauge is for, so all three are consulted
|
|
85
|
+
* and the worst age wins.
|
|
86
|
+
*/
|
|
82
87
|
private sampleQueueAge;
|
|
83
88
|
}
|
package/dist/LatencySampler.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LatencySampler = void 0;
|
|
4
4
|
const histogram_1 = require("./histogram");
|
|
5
|
-
const jobSources_1 = require("./jobSources");
|
|
6
5
|
const MS_PER_HOUR = 3600000;
|
|
7
6
|
const SECONDS_PER_DAY = 86400;
|
|
8
7
|
const DEFAULT_MAX_SAMPLES = 5000;
|
|
@@ -14,30 +13,28 @@ const DEFAULT_MAX_SAMPLES = 5000;
|
|
|
14
13
|
* means anything finishing inside the margin is picked up by the next tick instead.
|
|
15
14
|
* Costs a few seconds of freshness in data that is bucketed hourly.
|
|
16
15
|
*
|
|
17
|
-
* The score is `Date.now()` read in the worker process and passed into BullMQ's Lua
|
|
18
|
-
*
|
|
16
|
+
* The score is `Date.now()` read in the worker process and passed into BullMQ's Lua, not a
|
|
17
|
+
* Redis-side clock, so the margin only holds while the worker and this recorder agree on
|
|
19
18
|
* the time: the effective margin is `margin - skew`. A worker running far enough ahead of
|
|
20
19
|
* the recorder can still land jobs below an already-advanced watermark and lose them.
|
|
21
20
|
*/
|
|
22
21
|
const SAFETY_MARGIN_MS = 5000;
|
|
23
22
|
/**
|
|
24
|
-
* Copies job durations out of
|
|
23
|
+
* Copies job durations out of BullMQ's finished sets on the recorder's tick.
|
|
25
24
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* Where the durations are read from (a `JobSource`) and where they are written to (a
|
|
32
|
-
* `LatencyStorage`) are independent: the watermark, margin, lease and subsampling logic
|
|
33
|
-
* here is the same for every combination.
|
|
25
|
+
* BullMQ's moveToFinished does `ZADD targetSet, timestamp, jobId` and writes the same value
|
|
26
|
+
* to finishedOn, so the completed and failed sets are sorted sets scored by finish time.
|
|
27
|
+
* Scanning past a stored watermark therefore returns exactly the jobs finished since the
|
|
28
|
+
* last tick, with no gaps and no bias. The only loss is a queue whose removeOnComplete
|
|
29
|
+
* trims faster than the tick runs.
|
|
34
30
|
*/
|
|
35
31
|
class LatencySampler {
|
|
36
32
|
constructor(opts) {
|
|
37
33
|
var _a, _b;
|
|
38
34
|
this.id = `${process.pid}-${Math.random().toString(36).slice(2)}`;
|
|
39
|
-
this.
|
|
35
|
+
this.redisBacked = new Map();
|
|
40
36
|
this.redis = opts.redis;
|
|
37
|
+
this.keys = opts.keys;
|
|
41
38
|
this.store = opts.store;
|
|
42
39
|
this.tickMs = opts.tickMs;
|
|
43
40
|
this.maxSamples = (_a = opts.maxSamplesPerTick) !== null && _a !== void 0 ? _a : DEFAULT_MAX_SAMPLES;
|
|
@@ -60,19 +57,18 @@ class LatencySampler {
|
|
|
60
57
|
}
|
|
61
58
|
const name = adapter.getName();
|
|
62
59
|
try {
|
|
63
|
-
|
|
64
|
-
if (!source) {
|
|
60
|
+
if (!(await this.isRedisBacked(adapter, name))) {
|
|
65
61
|
return;
|
|
66
62
|
}
|
|
67
|
-
if (!(await this.
|
|
63
|
+
if (!(await this.acquireLease(name))) {
|
|
68
64
|
return;
|
|
69
65
|
}
|
|
70
66
|
try {
|
|
71
|
-
await this.sampleDurations(
|
|
72
|
-
await this.sampleQueueAge(
|
|
67
|
+
await this.sampleDurations(adapter, name);
|
|
68
|
+
await this.sampleQueueAge(adapter, name);
|
|
73
69
|
}
|
|
74
70
|
finally {
|
|
75
|
-
await this.
|
|
71
|
+
await this.releaseLease(name);
|
|
76
72
|
}
|
|
77
73
|
}
|
|
78
74
|
catch (error) {
|
|
@@ -85,27 +81,35 @@ class LatencySampler {
|
|
|
85
81
|
}
|
|
86
82
|
}
|
|
87
83
|
}
|
|
84
|
+
/** `getQueueKey` answers for a PostgreSQL-backed queue too, with keys no Redis holds. */
|
|
85
|
+
async isRedisBacked(adapter, name) {
|
|
86
|
+
const known = this.redisBacked.get(name);
|
|
87
|
+
if (known !== undefined) {
|
|
88
|
+
return known;
|
|
89
|
+
}
|
|
90
|
+
const backed = (await adapter.getRedisInfo()) !== null;
|
|
91
|
+
this.redisBacked.set(name, backed);
|
|
92
|
+
return backed;
|
|
93
|
+
}
|
|
88
94
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
95
|
+
* Increments are not idempotent the way the counter upsert is, so two recorders scanning
|
|
96
|
+
* the same range would double every histogram. Only the lease holder scans.
|
|
97
|
+
*
|
|
98
|
+
* The TTL is a crash ceiling, not the normal lifetime: a process that dies mid-scan must
|
|
99
|
+
* not lock the queue out forever. The normal path releases in a finally, because a lease
|
|
100
|
+
* outliving its scan would make the next tick no-op and halve the sampling rate.
|
|
93
101
|
*/
|
|
94
|
-
async
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
source = client ? new jobSources_1.RedisJobSource(client, adapter) : null;
|
|
103
|
-
}
|
|
104
|
-
this.sources.set(name, source);
|
|
105
|
-
return source;
|
|
102
|
+
async acquireLease(name) {
|
|
103
|
+
const held = await this.redis.set(this.keys.lease(name), this.id, 'PX', this.tickMs * 2, 'NX');
|
|
104
|
+
return held === 'OK';
|
|
105
|
+
}
|
|
106
|
+
/** Compare and delete, so a lease that already expired and was retaken is left alone. */
|
|
107
|
+
async releaseLease(name) {
|
|
108
|
+
await this.redis.eval(`if redis.call('GET', KEYS[1]) == ARGV[1] then return redis.call('DEL', KEYS[1]) end
|
|
109
|
+
return 0`, 1, this.keys.lease(name), this.id);
|
|
106
110
|
}
|
|
107
111
|
/**
|
|
108
|
-
* Bounded rather than eternal: an unexpiring watermark would leave one
|
|
112
|
+
* Bounded rather than eternal: an unexpiring watermark would leave one key behind per
|
|
109
113
|
* queue forever once that queue is purged or decommissioned, which is exactly the
|
|
110
114
|
* unbounded-storage failure this package exists to avoid. The day retention is already the
|
|
111
115
|
* horizon everything else here is bounded by. Losing the watermark just means the next
|
|
@@ -114,45 +118,74 @@ class LatencySampler {
|
|
|
114
118
|
watermarkTtlSeconds() {
|
|
115
119
|
return Math.max(1, Math.floor(this.store.retention.days * SECONDS_PER_DAY));
|
|
116
120
|
}
|
|
117
|
-
async sampleDurations(
|
|
118
|
-
|
|
121
|
+
async sampleDurations(adapter, name) {
|
|
122
|
+
var _a;
|
|
123
|
+
const watermarkRaw = await this.redis.get(this.keys.watermark(name));
|
|
119
124
|
// Cold start covers one tick ending at the safety bound rather than backfilling, since a
|
|
120
125
|
// first run against a large completed set would be a surprise fetch storm. Ending at the
|
|
121
126
|
// bound rather than at now is what keeps a tick shorter than the margin from producing a
|
|
122
127
|
// window that is empty on every tick, leaving the watermark stuck forever.
|
|
123
|
-
const watermark =
|
|
128
|
+
const watermark = watermarkRaw
|
|
129
|
+
? Number(watermarkRaw)
|
|
130
|
+
: Date.now() - this.tickMs - this.safetyMarginMs;
|
|
124
131
|
const upperBound = Date.now() - this.safetyMarginMs;
|
|
125
132
|
if (upperBound <= watermark) {
|
|
126
133
|
return; // ticks closer together than the margin; next tick covers this range
|
|
127
134
|
}
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
await this.
|
|
135
|
+
const ids = [];
|
|
136
|
+
for (const set of ['completed', 'failed']) {
|
|
137
|
+
const found = await this.redis.zrangebyscore(adapter.getQueueKey(set), `(${watermark}`, upperBound);
|
|
138
|
+
ids.push(...found);
|
|
139
|
+
}
|
|
140
|
+
if (ids.length === 0) {
|
|
141
|
+
await this.redis.set(this.keys.watermark(name), String(upperBound), 'EX', this.watermarkTtlSeconds());
|
|
131
142
|
return;
|
|
132
143
|
}
|
|
144
|
+
// The id list is one cheap round trip; the HMGETs are the real cost. Above the cap take
|
|
145
|
+
// a uniform subset rather than the first N, which would bias towards the tick's start.
|
|
146
|
+
const selected = ids.length > this.maxSamples ? sampleUniformly(ids, this.maxSamples) : ids;
|
|
133
147
|
// Counts are scaled back up by this ratio, so a subsampled hour reads as an estimate
|
|
134
148
|
// with the same shape rather than a dip. The fact that it was subsampled is currently
|
|
135
149
|
// invisible to clients: marking it would mean persisting a flag alongside the packed
|
|
136
150
|
// vector, which is a storage-format change. Known follow-up.
|
|
137
|
-
const ratio =
|
|
151
|
+
const ratio = ids.length / selected.length;
|
|
152
|
+
const pipeline = this.redis.pipeline();
|
|
153
|
+
for (const id of selected) {
|
|
154
|
+
pipeline.hmget(adapter.getQueueKey(String(id)), 'timestamp', 'processedOn', 'finishedOn',
|
|
155
|
+
// BullMQ 5 counts attempts in `atm`; `attemptsMade` is the pre-v5 name and is read
|
|
156
|
+
// as a fallback exactly the way Job.fromJSON does.
|
|
157
|
+
'atm', 'attemptsMade');
|
|
158
|
+
}
|
|
159
|
+
const rows = await pipeline.exec();
|
|
138
160
|
const runByHour = new Map();
|
|
139
161
|
const waitByHour = new Map();
|
|
140
|
-
for (const
|
|
141
|
-
const
|
|
142
|
-
|
|
162
|
+
for (const row of rows !== null && rows !== void 0 ? rows : []) {
|
|
163
|
+
const values = row === null || row === void 0 ? void 0 : row[1];
|
|
164
|
+
if (!values) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const [timestamp, processedOn, finishedOn, atm, attemptsMade] = values;
|
|
168
|
+
if (!processedOn || !finishedOn) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const finished = Number(finishedOn);
|
|
172
|
+
const processed = Number(processedOn);
|
|
173
|
+
const hour = Math.floor(finished / MS_PER_HOUR);
|
|
174
|
+
observe(runByHour, hour, finished - processed, ratio);
|
|
143
175
|
// A retried job's timestamp is its creation, but processedOn is the latest attempt,
|
|
144
176
|
// so wait would absorb every prior attempt and backoff. Run time is unaffected.
|
|
145
|
-
|
|
146
|
-
|
|
177
|
+
const attempts = Number((_a = atm !== null && atm !== void 0 ? atm : attemptsMade) !== null && _a !== void 0 ? _a : 0);
|
|
178
|
+
if (timestamp && attempts <= 1) {
|
|
179
|
+
// Every one of these is a Date.now() taken in some client process, not a Redis-side
|
|
147
180
|
// clock: timestamp in the producer, processedOn in the worker. Skew between the two
|
|
148
181
|
// can make the difference negative, hence the clamp.
|
|
149
|
-
observe(waitByHour, hour, Math.max(0,
|
|
182
|
+
observe(waitByHour, hour, Math.max(0, processed - Number(timestamp)), ratio);
|
|
150
183
|
}
|
|
151
184
|
}
|
|
152
185
|
await this.flush(name, 'runtime', runByHour);
|
|
153
186
|
await this.flush(name, 'waittime', waitByHour);
|
|
154
187
|
// The bound, not the highest score observed. See SAFETY_MARGIN_MS.
|
|
155
|
-
await this.
|
|
188
|
+
await this.redis.set(this.keys.watermark(name), String(upperBound), 'EX', this.watermarkTtlSeconds());
|
|
156
189
|
}
|
|
157
190
|
async flush(name, metric, byHour) {
|
|
158
191
|
for (const [hour, vector] of byHour) {
|
|
@@ -162,14 +195,73 @@ class LatencySampler {
|
|
|
162
195
|
await this.store.addSamples(name, metric, hour, vector.map((v) => Math.round(v)));
|
|
163
196
|
}
|
|
164
197
|
}
|
|
165
|
-
/**
|
|
166
|
-
|
|
198
|
+
/**
|
|
199
|
+
* The backlog is not all in one place. `wait` holds it while the queue is running, but
|
|
200
|
+
* pausing RENAMEs that list to `paused` and routes new jobs there, and anything added with
|
|
201
|
+
* a priority goes to the `prioritized` sorted set instead, which can leave `wait`
|
|
202
|
+
* permanently empty. Reading only `wait` reports a healthy zero for a queue that is badly
|
|
203
|
+
* backed up, which is the opposite of what this gauge is for, so all three are consulted
|
|
204
|
+
* and the worst age wins.
|
|
205
|
+
*/
|
|
206
|
+
async sampleQueueAge(adapter, name) {
|
|
207
|
+
var _a;
|
|
167
208
|
const hour = Math.floor(Date.now() / MS_PER_HOUR);
|
|
168
|
-
const
|
|
169
|
-
|
|
209
|
+
const candidates = await this.redis
|
|
210
|
+
.pipeline()
|
|
211
|
+
// BullMQ LPUSHes to the wait list and workers RPOPLPUSH from it, so the tail is oldest.
|
|
212
|
+
.lrange(adapter.getQueueKey('wait'), -1, -1)
|
|
213
|
+
.lrange(adapter.getQueueKey('paused'), -1, -1)
|
|
214
|
+
// The prioritized set is scored by priority, not by time, so neither end is guaranteed
|
|
215
|
+
// to hold the oldest job. Both ends are an approximation, and a cheap one: the true
|
|
216
|
+
// oldest would mean fetching the whole set every tick.
|
|
217
|
+
// String indices: ioredis v6 types `zrange`'s stop arg as string-only (Redis coerces
|
|
218
|
+
// either way), so numeric literals no longer typecheck. '0'/'-1' are the first/last members.
|
|
219
|
+
.zrange(adapter.getQueueKey('prioritized'), '0', '0')
|
|
220
|
+
.zrange(adapter.getQueueKey('prioritized'), '-1', '-1')
|
|
221
|
+
.exec();
|
|
222
|
+
// A pipeline reports failures per command: a Redis error arrives in the entry's error
|
|
223
|
+
// slot next to a null result, rather than as a throw. Reading only the result slot turns
|
|
224
|
+
// a failed read into an empty backlog and records an age of 0, which is the most
|
|
225
|
+
// reassuring number this gauge can produce, at the moment it is least entitled to. A gap
|
|
226
|
+
// in the series reads as "not measured" and is recoverable; a zero is a wrong answer that
|
|
227
|
+
// looks like a healthy one, so a tick that could not read cleanly records nothing.
|
|
228
|
+
if (!candidates || candidates.some(([error]) => error)) {
|
|
170
229
|
return;
|
|
171
230
|
}
|
|
172
|
-
|
|
231
|
+
const ids = new Set();
|
|
232
|
+
for (const entry of candidates) {
|
|
233
|
+
for (const id of (_a = entry[1]) !== null && _a !== void 0 ? _a : []) {
|
|
234
|
+
ids.add(String(id));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (ids.size === 0) {
|
|
238
|
+
await this.store.recordQueueAge(name, hour, 0);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const stamps = this.redis.pipeline();
|
|
242
|
+
for (const id of ids) {
|
|
243
|
+
stamps.hget(adapter.getQueueKey(id), 'timestamp');
|
|
244
|
+
}
|
|
245
|
+
const rows = await stamps.exec();
|
|
246
|
+
// Same reasoning: a failed timestamp read does not zero the gauge, it understates it,
|
|
247
|
+
// which is the same wrong-but-reassuring answer in a quieter form.
|
|
248
|
+
if (!rows || rows.some(([error]) => error)) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const now = Date.now();
|
|
252
|
+
let oldest = 0;
|
|
253
|
+
for (const row of rows) {
|
|
254
|
+
const raw = row[1];
|
|
255
|
+
if (!raw) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const enqueuedAt = Number(raw);
|
|
259
|
+
if (!Number.isFinite(enqueuedAt)) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
oldest = Math.max(oldest, now - enqueuedAt);
|
|
263
|
+
}
|
|
264
|
+
await this.store.recordQueueAge(name, hour, Math.max(0, oldest));
|
|
173
265
|
}
|
|
174
266
|
}
|
|
175
267
|
exports.LatencySampler = LatencySampler;
|
|
@@ -181,4 +273,13 @@ function observe(byHour, hour, durationMs, ratio) {
|
|
|
181
273
|
}
|
|
182
274
|
vector[(0, histogram_1.bucketIndex)(durationMs)] += ratio;
|
|
183
275
|
}
|
|
276
|
+
/** Evenly spaced pick across the list, which preserves the distribution's shape. */
|
|
277
|
+
function sampleUniformly(ids, target) {
|
|
278
|
+
const stride = ids.length / target;
|
|
279
|
+
const out = [];
|
|
280
|
+
for (let i = 0; i < target; i++) {
|
|
281
|
+
out.push(ids[Math.floor(i * stride)]);
|
|
282
|
+
}
|
|
283
|
+
return out;
|
|
284
|
+
}
|
|
184
285
|
//# sourceMappingURL=LatencySampler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LatencySampler.js","sourceRoot":"","sources":["../src/LatencySampler.ts"],"names":[],"mappings":";;;AAEA,2CAAuD;
|
|
1
|
+
{"version":3,"file":"LatencySampler.js","sourceRoot":"","sources":["../src/LatencySampler.ts"],"names":[],"mappings":";;;AAEA,2CAAuD;AAIvD,MAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,MAAM,eAAe,GAAG,KAAK,CAAC;AAC9B,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC;;;;;;;;;;;;GAYG;AACH,MAAM,gBAAgB,GAAG,IAAI,CAAC;AA8B9B;;;;;;;;GAQG;AACH,MAAa,cAAc;IAWzB,YAAY,IAA2B;;QAHtB,OAAE,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,C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,CAAC,UAAU,CAAC,EAAE,CAAC;gBACjC,SAAS;YACX,CAAC;YACD,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,UAAU,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACnE,CAAC;CACF;AApSD,wCAoSC;AAED,SAAS,OAAO,CACd,MAA6B,EAC7B,IAAY,EACZ,UAAkB,EAClB,KAAa;IAEb,IAAI,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,IAAA,uBAAW,GAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,CAAC,IAAA,uBAAW,EAAC,UAAU,CAAC,CAAC,IAAI,KAAK,CAAC;AAC3C,CAAC;AAED,oFAAoF;AACpF,SAAS,eAAe,CAAC,GAAa,EAAE,MAAc;IACpD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;IACnC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/LatencyStore.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { MetricsClient } from './connection';
|
|
2
|
+
import type { Retention } from './HistoryStore';
|
|
2
3
|
import { type MetricsKeys } from './keys';
|
|
3
|
-
|
|
4
|
-
export type { LatencyMetric } from './store';
|
|
4
|
+
export type LatencyMetric = 'runtime' | 'waittime';
|
|
5
5
|
export declare const QUEUE_AGE_METRIC = "queueage";
|
|
6
|
-
|
|
7
|
-
export declare class LatencyStore implements LatencyStorage {
|
|
6
|
+
export declare class LatencyStore {
|
|
8
7
|
private readonly redis;
|
|
9
8
|
private readonly keys;
|
|
10
9
|
readonly retention: Retention;
|
|
@@ -17,10 +16,6 @@ export declare class LatencyStore implements LatencyStorage {
|
|
|
17
16
|
recordQueueAge(queue: string, hour: number, ms: number): Promise<void>;
|
|
18
17
|
readRange(queue: string, metric: LatencyMetric, granularity: 'hour' | 'day', days: string[]): Promise<Record<string, number[]>>;
|
|
19
18
|
readQueueAge(queue: string, granularity: 'hour' | 'day', days: string[]): Promise<Record<string, number>>;
|
|
20
|
-
acquireLease(queue: string, holder: string, ttlMs: number): Promise<boolean>;
|
|
21
|
-
releaseLease(queue: string, holder: string): Promise<void>;
|
|
22
|
-
readWatermark(queue: string): Promise<number | null>;
|
|
23
|
-
writeWatermark(queue: string, ms: number, ttlSeconds: number): Promise<void>;
|
|
24
19
|
/** Epoch ms for an absolute hour index, for building response timestamps. */
|
|
25
20
|
static hourToMs(hour: number): number;
|
|
26
21
|
}
|