@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.
Files changed (62) hide show
  1. package/README.md +6 -86
  2. package/dist/HistoryAdmin.d.ts +87 -23
  3. package/dist/HistoryAdmin.js +330 -21
  4. package/dist/HistoryAdmin.js.map +1 -1
  5. package/dist/HistoryStore.d.ts +9 -9
  6. package/dist/HistoryStore.js +0 -22
  7. package/dist/HistoryStore.js.map +1 -1
  8. package/dist/LatencySampler.d.ts +32 -27
  9. package/dist/LatencySampler.js +156 -55
  10. package/dist/LatencySampler.js.map +1 -1
  11. package/dist/LatencyStore.d.ts +3 -8
  12. package/dist/LatencyStore.js +0 -18
  13. package/dist/LatencyStore.js.map +1 -1
  14. package/dist/MetricsRecorder.d.ts +10 -34
  15. package/dist/MetricsRecorder.js +20 -30
  16. package/dist/MetricsRecorder.js.map +1 -1
  17. package/dist/RedisMetricsHistoryProvider.d.ts +17 -7
  18. package/dist/RedisMetricsHistoryProvider.js +136 -9
  19. package/dist/RedisMetricsHistoryProvider.js.map +1 -1
  20. package/dist/index.d.ts +2 -10
  21. package/dist/index.js +1 -10
  22. package/dist/index.js.map +1 -1
  23. package/dist/keys.d.ts +0 -7
  24. package/dist/keys.js +1 -23
  25. package/dist/keys.js.map +1 -1
  26. package/package.json +4 -14
  27. package/dist/RedisHistoryAdmin.d.ts +0 -95
  28. package/dist/RedisHistoryAdmin.js +0 -328
  29. package/dist/RedisHistoryAdmin.js.map +0 -1
  30. package/dist/RedisMetricsStore.d.ts +0 -27
  31. package/dist/RedisMetricsStore.js +0 -42
  32. package/dist/RedisMetricsStore.js.map +0 -1
  33. package/dist/StoreHistoryProvider.d.ts +0 -27
  34. package/dist/StoreHistoryProvider.js +0 -127
  35. package/dist/StoreHistoryProvider.js.map +0 -1
  36. package/dist/jobSources.d.ts +0 -97
  37. package/dist/jobSources.js +0 -248
  38. package/dist/jobSources.js.map +0 -1
  39. package/dist/postgres/PostgresMetricsHistoryProvider.d.ts +0 -37
  40. package/dist/postgres/PostgresMetricsHistoryProvider.js +0 -30
  41. package/dist/postgres/PostgresMetricsHistoryProvider.js.map +0 -1
  42. package/dist/postgres/PostgresMetricsStore.d.ts +0 -65
  43. package/dist/postgres/PostgresMetricsStore.js +0 -88
  44. package/dist/postgres/PostgresMetricsStore.js.map +0 -1
  45. package/dist/postgres/admin.d.ts +0 -31
  46. package/dist/postgres/admin.js +0 -178
  47. package/dist/postgres/admin.js.map +0 -1
  48. package/dist/postgres/connection.d.ts +0 -53
  49. package/dist/postgres/connection.js +0 -54
  50. package/dist/postgres/connection.js.map +0 -1
  51. package/dist/postgres/context.d.ts +0 -29
  52. package/dist/postgres/context.js +0 -76
  53. package/dist/postgres/context.js.map +0 -1
  54. package/dist/postgres/schema.d.ts +0 -26
  55. package/dist/postgres/schema.js +0 -148
  56. package/dist/postgres/schema.js.map +0 -1
  57. package/dist/postgres/stores.d.ts +0 -51
  58. package/dist/postgres/stores.js +0 -252
  59. package/dist/postgres/stores.js.map +0 -1
  60. package/dist/store.d.ts +0 -80
  61. package/dist/store.js +0 -3
  62. package/dist/store.js.map +0 -1
package/dist/keys.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";;;AAeA,0BAGC;AAED,kCAEC;AAGD,oCAEC;AAED,4BAEC;AAED,oCAGC;AAGD,gCAEC;AAED,gCAEC;AAED,4BAaC;AAgBD,4CAGC;AAYD,kCAUC;AAGD,sBAQC;AAhHY,QAAA,iBAAiB,GAAG,oBAAoB,CAAC;AACzC,QAAA,YAAY,GAAG,YAAY,CAAC;AACzC,uFAAuF;AAC1E,QAAA,SAAS,GAAG,MAAM,CAAC;AAEnB,QAAA,WAAW,GAAG,qBAAqB,CAAC;AAEjD,MAAM,aAAa,GAAG,KAAK,CAAC;AAC5B,MAAM,UAAU,GAAG,QAAQ,CAAC;AAC5B,M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AAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,yFAAyF;AACzF,SAAgB,gBAAgB,CAAC,MAA0B,EAAE,SAAkB;IAC7E,MAAM,IAAI,GAAG,kBAAkB,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,yBAAiB,CAAC,IAAI,yBAAiB,CAAC;IAClF,OAAO,SAAS,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7D,CAAC;AAYD,SAAgB,WAAW,CAAC,SAAiB;IAC3C,OAAO;QACL,SAAS;QACT,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,SAAS,IAAI,KAAK,IAAI,MAAM,IAAI,GAAG,EAAE;QACrE,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,SAAS,IAAI,KAAK,IAAI,MAAM,IAAI,iBAAS,IAAI,GAAG,EAAE;QACnF,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,SAAS,IAAI,KAAK,IAAI,MAAM,SAAS;QACnE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,SAAS,IAAI,KAAK,gBAAgB;QACvD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,SAAS,IAAI,KAAK,oBAAoB;QAC/D,WAAW,EAAE,GAAG,SAAS,IAAI;KAC9B,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,15 +1,13 @@
1
1
  {
2
2
  "name": "@worker-manager/metrics",
3
- "version": "1.1.0",
4
- "description": "Opt-in long-retention historical job metrics recorder and provider for Worker Manager.",
3
+ "version": "9.10.1",
4
+ "description": "Opt-in long-retention historical job metrics recorder and provider for bull-board.",
5
5
  "keywords": [
6
6
  "bull",
7
7
  "bullmq",
8
8
  "dashboard",
9
9
  "history",
10
10
  "metrics",
11
- "postgres",
12
- "postgresql",
13
11
  "queue",
14
12
  "redis"
15
13
  ],
@@ -34,30 +32,22 @@
34
32
  "test": "jest"
35
33
  },
36
34
  "dependencies": {
37
- "@worker-manager/api": "1.1.0"
35
+ "@worker-manager/api": "9.10.1"
38
36
  },
39
37
  "devDependencies": {
40
38
  "@types/jest": "^30.0.0",
41
39
  "@types/node": "^22.20.1",
42
- "@types/pg": "^8.23.1",
43
40
  "bullmq": "^5.81.3",
44
41
  "bullmq-v6": "npm:bullmq@^6",
45
42
  "ioredis": "^6.0.0",
46
43
  "jest": "^30.4.2",
47
- "pg": "^8.23.0",
48
44
  "ts-jest": "^29.4.12",
49
45
  "typescript": "^5.9.3"
50
46
  },
51
47
  "peerDependencies": {
52
- "ioredis": "^5.0.0 || ^6.0.0",
53
- "pg": "^8.11.0"
48
+ "ioredis": "^5.0.0 || ^6.0.0"
54
49
  },
55
50
  "engines": {
56
51
  "node": ">=20"
57
- },
58
- "peerDependenciesMeta": {
59
- "pg": {
60
- "optional": true
61
- }
62
52
  }
63
53
  }
@@ -1,95 +0,0 @@
1
- import { type MetricsClient } from './connection';
2
- import type { HistoryStats, HistoryTier, PurgeOptions, PurgeResult } from './HistoryAdmin';
3
- import { type MetricsKeys } from './keys';
4
- import type { HistoryAdministration } from './store';
5
- interface ParsedKey {
6
- queue: string;
7
- metric: string;
8
- tier: HistoryTier;
9
- /** ISO day the key covers, `null` for the daily totals hash. */
10
- day: string | null;
11
- }
12
- /**
13
- * Parses the three key shapes from the right, because queue names may themselves contain
14
- * colons:
15
- *
16
- * <ns>:<queue>:<metric>:<day> minute buckets
17
- * <ns>:<queue>:<metric>:hour:<day> hourly rollup
18
- * <ns>:<queue>:<metric>:totals daily totals
19
- *
20
- * The metric segment is checked against the known set, so a queue named `hour` or one
21
- * ending in `:completed` still resolves correctly. Anything that doesn't fit returns null
22
- * and is then reported but never deleted, so a stray key can't be destroyed by accident.
23
- */
24
- export declare function parseHistoryKey(key: string, namespace: string): ParsedKey | null;
25
- /**
26
- * Inspection and cleanup for the Redis keys written by `MetricsRecorder`.
27
- *
28
- * Every operation is confined to the recorder's namespace and driven by SCAN, so it never
29
- * blocks Redis and never touches BullMQ's own keys. Deletes use UNLINK.
30
- */
31
- export declare class RedisHistoryAdmin implements HistoryAdministration {
32
- private readonly redis;
33
- private readonly keys;
34
- constructor(opts: {
35
- redis: MetricsClient;
36
- keys: MetricsKeys;
37
- });
38
- /**
39
- * Per-queue footprint of the stored history.
40
- *
41
- * Every key has to be measured individually, since only `MEMORY USAGE` knows what a hash
42
- * really costs. Issuing those one at a time would mean a round trip per key, which at a
43
- * 90-day retention across a dozen queues runs into the thousands, so the measurements go
44
- * out in pipelined batches instead. Still an ops-scale call rather than a hot path: it
45
- * reads the whole namespace, so it belongs behind a debug endpoint, not a poll.
46
- */
47
- stats(): Promise<HistoryStats>;
48
- /**
49
- * Size and entry count for each key, in pipelined batches so the cost is a handful of
50
- * round trips rather than one per key. A key that expires between the scan and the
51
- * measurement simply reads as zero rather than failing the whole call.
52
- */
53
- private measure;
54
- /**
55
- * Deletes recorded history. Purging a single queue also subtracts that queue's minutes
56
- * from the global rollup, so the cross-queue chart stays correct instead of keeping the
57
- * removed queue's throughput folded into it forever.
58
- *
59
- * That correction covers the counter metrics only. The global runtime, waittime and
60
- * queueage rollups keep the purged queue's contribution until their own retention drops
61
- * it: a packed bucket vector cannot be decremented field by field, and a max gauge has no
62
- * record of which queue produced the maximum, so there is nothing to subtract. The
63
- * per-queue keys are still deleted either way. See SUMMABLE_METRICS.
64
- */
65
- purge(opts?: PurgeOptions): Promise<PurgeResult>;
66
- /**
67
- * Removes one queue's buckets from the matching global key, so the cross-queue series
68
- * reflects the queues that are left rather than keeping the removed queue folded in.
69
- * Each tier is corrected from its own source key, because the tiers have independent
70
- * retention and the minute hash may already be gone while the hourly one survives.
71
- * Fields that drain to zero are dropped: the recorder never writes a zero bucket, so a
72
- * leftover zero would read as recorded-but-idle instead of not recorded.
73
- * Returns the number of global keys it deleted.
74
- *
75
- * Only the summable metrics are touched; the latency ones are skipped outright rather than
76
- * silently producing a no-op subtraction of their packed values. See SUMMABLE_METRICS.
77
- */
78
- private subtractDayFromGlobal;
79
- /**
80
- * Same idea for the daily rollup: the global totals hash is the sum of the per-queue
81
- * totals hashes, so it is corrected from those rather than re-derived from day hashes,
82
- * which may already have expired. Returns the number of global fields it removed.
83
- *
84
- * Skips the latency metrics for the same reason as subtractDayFromGlobal.
85
- */
86
- private subtractTotalsFromGlobal;
87
- /**
88
- * SCAN over the namespace, once per master: SCAN carries no key, so a cluster client has
89
- * no slot to route by and would answer from one arbitrary node. SCAN may also hand back the
90
- * same key on more than one cursor iteration, which would double-count in `stats()`, so
91
- * emissions are de-duped here. The set is bounded by queues x metrics x retention days.
92
- */
93
- private scan;
94
- }
95
- export {};
@@ -1,328 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedisHistoryAdmin = void 0;
4
- exports.parseHistoryKey = parseHistoryKey;
5
- const connection_1 = require("./connection");
6
- const keys_1 = require("./keys");
7
- const SCAN_COUNT = 500;
8
- const BATCH = 256;
9
- /** Keys per pipelined `stats()` batch. Each key costs two commands. */
10
- const MEASURE_BATCH = 250;
11
- const METRICS = ['completed', 'failed', 'runtime', 'waittime', 'queueage'];
12
- /**
13
- * Metrics whose global rollup is a plain summable counter, so one queue's share can be taken
14
- * back out of it with HINCRBY. The latency metrics are deliberately absent: runtime and
15
- * waittime pack a whole bucket vector into a single field and queueage holds a max gauge,
16
- * and neither can be corrected by a scalar decrement. See `purge`.
17
- */
18
- const SUMMABLE_METRICS = ['completed', 'failed'];
19
- /**
20
- * Parses the three key shapes from the right, because queue names may themselves contain
21
- * colons:
22
- *
23
- * <ns>:<queue>:<metric>:<day> minute buckets
24
- * <ns>:<queue>:<metric>:hour:<day> hourly rollup
25
- * <ns>:<queue>:<metric>:totals daily totals
26
- *
27
- * The metric segment is checked against the known set, so a queue named `hour` or one
28
- * ending in `:completed` still resolves correctly. Anything that doesn't fit returns null
29
- * and is then reported but never deleted, so a stray key can't be destroyed by accident.
30
- */
31
- function parseHistoryKey(key, namespace) {
32
- const prefix = `${namespace}:`;
33
- if (!key.startsWith(prefix)) {
34
- return null;
35
- }
36
- const parts = key.slice(prefix.length).split(':');
37
- if (parts.length < 3) {
38
- return null;
39
- }
40
- const last = parts[parts.length - 1];
41
- if (last === 'totals' && METRICS.includes(parts[parts.length - 2])) {
42
- const queue = parts.slice(0, -2).join(':');
43
- return queue ? { queue, metric: parts[parts.length - 2], tier: 'day', day: null } : null;
44
- }
45
- if (!keys_1.DAY_PATTERN.test(last)) {
46
- return null;
47
- }
48
- if (parts.length >= 4 && parts[parts.length - 2] === keys_1.HOUR_TIER) {
49
- const metric = parts[parts.length - 3];
50
- const queue = parts.slice(0, -3).join(':');
51
- return queue && METRICS.includes(metric) ? { queue, metric, tier: 'hour', day: last } : null;
52
- }
53
- const metric = parts[parts.length - 2];
54
- const queue = parts.slice(0, -2).join(':');
55
- return queue && METRICS.includes(metric) ? { queue, metric, tier: 'minute', day: last } : null;
56
- }
57
- function emptyTiers() {
58
- return {
59
- minute: { keys: 0, bytes: 0 },
60
- hour: { keys: 0, bytes: 0 },
61
- day: { keys: 0, bytes: 0 },
62
- };
63
- }
64
- /** The global rollup key mirroring a per-queue key, same tier and same day. */
65
- function globalKeyFor(keys, parsed) {
66
- if (parsed.day === null) {
67
- return keys.totals(keys_1.GLOBAL_QUEUE, parsed.metric);
68
- }
69
- return parsed.tier === 'hour'
70
- ? keys.hour(keys_1.GLOBAL_QUEUE, parsed.metric, parsed.day)
71
- : keys.day(keys_1.GLOBAL_QUEUE, parsed.metric, parsed.day);
72
- }
73
- /**
74
- * Inspection and cleanup for the Redis keys written by `MetricsRecorder`.
75
- *
76
- * Every operation is confined to the recorder's namespace and driven by SCAN, so it never
77
- * blocks Redis and never touches BullMQ's own keys. Deletes use UNLINK.
78
- */
79
- class RedisHistoryAdmin {
80
- constructor(opts) {
81
- this.redis = opts.redis;
82
- this.keys = opts.keys;
83
- }
84
- /**
85
- * Per-queue footprint of the stored history.
86
- *
87
- * Every key has to be measured individually, since only `MEMORY USAGE` knows what a hash
88
- * really costs. Issuing those one at a time would mean a round trip per key, which at a
89
- * 90-day retention across a dozen queues runs into the thousands, so the measurements go
90
- * out in pipelined batches instead. Still an ops-scale call rather than a hot path: it
91
- * reads the whole namespace, so it belongs behind a debug endpoint, not a poll.
92
- */
93
- async stats() {
94
- var _a;
95
- const byQueue = new Map();
96
- const tiers = emptyTiers();
97
- let keys = 0;
98
- let bytes = 0;
99
- let minutes = 0;
100
- let oldestDay = null;
101
- let newestDay = null;
102
- const found = [];
103
- for await (const key of this.scan()) {
104
- const parsed = parseHistoryKey(key, this.keys.namespace);
105
- if (parsed) {
106
- found.push({ key, parsed });
107
- }
108
- }
109
- const measurements = await this.measure(found.map((item) => item.key));
110
- for (const [index, { parsed }] of found.entries()) {
111
- const { size, len } = measurements[index];
112
- const entry = (_a = byQueue.get(parsed.queue)) !== null && _a !== void 0 ? _a : {
113
- queue: parsed.queue,
114
- keys: 0,
115
- bytes: 0,
116
- minutes: 0,
117
- days: [],
118
- tiers: emptyTiers(),
119
- };
120
- entry.keys += 1;
121
- entry.bytes += size;
122
- entry.tiers[parsed.tier].keys += 1;
123
- entry.tiers[parsed.tier].bytes += size;
124
- keys += 1;
125
- bytes += size;
126
- tiers[parsed.tier].keys += 1;
127
- tiers[parsed.tier].bytes += size;
128
- if (parsed.tier === 'minute') {
129
- entry.minutes += len;
130
- minutes += len;
131
- }
132
- if (parsed.day) {
133
- entry.days.push(parsed.day);
134
- if (oldestDay === null || parsed.day < oldestDay) {
135
- oldestDay = parsed.day;
136
- }
137
- if (newestDay === null || parsed.day > newestDay) {
138
- newestDay = parsed.day;
139
- }
140
- }
141
- byQueue.set(parsed.queue, entry);
142
- }
143
- const queues = [...byQueue.values()].sort((a, b) => b.bytes - a.bytes);
144
- for (const queue of queues) {
145
- queue.days = [...new Set(queue.days)].sort();
146
- }
147
- return { keys, bytes, minutes, oldestDay, newestDay, tiers, queues };
148
- }
149
- /**
150
- * Size and entry count for each key, in pipelined batches so the cost is a handful of
151
- * round trips rather than one per key. A key that expires between the scan and the
152
- * measurement simply reads as zero rather than failing the whole call.
153
- */
154
- async measure(keys) {
155
- var _a, _b, _c, _d;
156
- const out = [];
157
- for (let i = 0; i < keys.length; i += MEASURE_BATCH) {
158
- const chunk = keys.slice(i, i + MEASURE_BATCH);
159
- const pipeline = this.redis.pipeline();
160
- for (const key of chunk) {
161
- pipeline.memory('USAGE', key);
162
- pipeline.hlen(key);
163
- }
164
- const res = await pipeline.exec();
165
- for (let j = 0; j < chunk.length; j++) {
166
- out.push({
167
- size: Number((_b = (_a = res === null || res === void 0 ? void 0 : res[j * 2]) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0) || 0,
168
- len: Number((_d = (_c = res === null || res === void 0 ? void 0 : res[j * 2 + 1]) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : 0) || 0,
169
- });
170
- }
171
- }
172
- return out;
173
- }
174
- /**
175
- * Deletes recorded history. Purging a single queue also subtracts that queue's minutes
176
- * from the global rollup, so the cross-queue chart stays correct instead of keeping the
177
- * removed queue's throughput folded into it forever.
178
- *
179
- * That correction covers the counter metrics only. The global runtime, waittime and
180
- * queueage rollups keep the purged queue's contribution until their own retention drops
181
- * it: a packed bucket vector cannot be decremented field by field, and a max gauge has no
182
- * record of which queue produced the maximum, so there is nothing to subtract. The
183
- * per-queue keys are still deleted either way. See SUMMABLE_METRICS.
184
- */
185
- async purge(opts = {}) {
186
- const before = opts.before === undefined ? null : (0, keys_1.toDay)(opts.before);
187
- const result = { keysDeleted: 0, fieldsDeleted: 0 };
188
- const dayKeys = [];
189
- const totalsKeys = [];
190
- for await (const key of this.scan()) {
191
- const parsed = parseHistoryKey(key, this.keys.namespace);
192
- if (!parsed) {
193
- continue;
194
- }
195
- if (opts.queue !== undefined && parsed.queue !== opts.queue) {
196
- continue;
197
- }
198
- if (parsed.day === null) {
199
- totalsKeys.push({ key, parsed });
200
- }
201
- else if (before === null || parsed.day < before) {
202
- dayKeys.push({ key, parsed });
203
- }
204
- }
205
- // Rewriting the global rollup only makes sense when a single queue is being removed:
206
- // a full purge drops the global keys outright, along with everything else.
207
- const adjustGlobal = opts.queue !== undefined && opts.queue !== keys_1.GLOBAL_QUEUE;
208
- for (const { key, parsed } of dayKeys) {
209
- if (adjustGlobal) {
210
- result.keysDeleted += await this.subtractDayFromGlobal(key, parsed);
211
- }
212
- result.keysDeleted += await this.redis.unlink(key);
213
- }
214
- for (const { key, parsed } of totalsKeys) {
215
- const stale = (await this.redis.hkeys(key)).filter((day) => before === null || day < before);
216
- if (adjustGlobal && stale.length > 0) {
217
- const totals = await this.redis.hmget(key, ...stale);
218
- result.fieldsDeleted += await this.subtractTotalsFromGlobal(parsed.metric, stale, totals);
219
- }
220
- if (before === null) {
221
- result.keysDeleted += await this.redis.unlink(key);
222
- continue;
223
- }
224
- for (let i = 0; i < stale.length; i += BATCH) {
225
- result.fieldsDeleted += await this.redis.hdel(key, ...stale.slice(i, i + BATCH));
226
- }
227
- if ((await this.redis.hlen(key)) === 0) {
228
- result.keysDeleted += await this.redis.unlink(key);
229
- }
230
- }
231
- return result;
232
- }
233
- /**
234
- * Removes one queue's buckets from the matching global key, so the cross-queue series
235
- * reflects the queues that are left rather than keeping the removed queue folded in.
236
- * Each tier is corrected from its own source key, because the tiers have independent
237
- * retention and the minute hash may already be gone while the hourly one survives.
238
- * Fields that drain to zero are dropped: the recorder never writes a zero bucket, so a
239
- * leftover zero would read as recorded-but-idle instead of not recorded.
240
- * Returns the number of global keys it deleted.
241
- *
242
- * Only the summable metrics are touched; the latency ones are skipped outright rather than
243
- * silently producing a no-op subtraction of their packed values. See SUMMABLE_METRICS.
244
- */
245
- async subtractDayFromGlobal(key, parsed) {
246
- if (parsed.day === null || !SUMMABLE_METRICS.includes(parsed.metric)) {
247
- return 0;
248
- }
249
- const minutes = await this.redis.hgetall(key);
250
- const globalDay = globalKeyFor(this.keys, parsed);
251
- const pipeline = this.redis.multi();
252
- const touched = [];
253
- for (const field of Object.keys(minutes)) {
254
- const value = Number(minutes[field]) || 0;
255
- if (value === 0) {
256
- continue;
257
- }
258
- touched.push(field);
259
- pipeline.hincrby(globalDay, field, -value);
260
- }
261
- if (touched.length === 0) {
262
- return 0;
263
- }
264
- const res = await pipeline.exec();
265
- const drained = touched.filter((_, i) => { var _a, _b; return Number((_b = (_a = res === null || res === void 0 ? void 0 : res[i]) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0) <= 0; });
266
- for (let i = 0; i < drained.length; i += BATCH) {
267
- await this.redis.hdel(globalDay, ...drained.slice(i, i + BATCH));
268
- }
269
- return (await this.redis.hlen(globalDay)) === 0 ? await this.redis.unlink(globalDay) : 0;
270
- }
271
- /**
272
- * Same idea for the daily rollup: the global totals hash is the sum of the per-queue
273
- * totals hashes, so it is corrected from those rather than re-derived from day hashes,
274
- * which may already have expired. Returns the number of global fields it removed.
275
- *
276
- * Skips the latency metrics for the same reason as subtractDayFromGlobal.
277
- */
278
- async subtractTotalsFromGlobal(metric, days, values) {
279
- if (!SUMMABLE_METRICS.includes(metric)) {
280
- return 0;
281
- }
282
- const globalTotals = this.keys.totals(keys_1.GLOBAL_QUEUE, metric);
283
- const pipeline = this.redis.multi();
284
- const touched = [];
285
- days.forEach((day, i) => {
286
- const value = Number(values[i]) || 0;
287
- if (value === 0) {
288
- return;
289
- }
290
- touched.push(day);
291
- pipeline.hincrby(globalTotals, day, -value);
292
- });
293
- if (touched.length === 0) {
294
- return 0;
295
- }
296
- const res = await pipeline.exec();
297
- const drained = touched.filter((_, i) => { var _a, _b; return Number((_b = (_a = res === null || res === void 0 ? void 0 : res[i]) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : 0) <= 0; });
298
- let removed = 0;
299
- for (let i = 0; i < drained.length; i += BATCH) {
300
- removed += await this.redis.hdel(globalTotals, ...drained.slice(i, i + BATCH));
301
- }
302
- return removed;
303
- }
304
- /**
305
- * SCAN over the namespace, once per master: SCAN carries no key, so a cluster client has
306
- * no slot to route by and would answer from one arbitrary node. SCAN may also hand back the
307
- * same key on more than one cursor iteration, which would double-count in `stats()`, so
308
- * emissions are de-duped here. The set is bounded by queues x metrics x retention days.
309
- */
310
- async *scan() {
311
- const seen = new Set();
312
- for (const target of (0, connection_1.scanTargets)(this.redis)) {
313
- let cursor = '0';
314
- do {
315
- const [next, batch] = await target.scan(cursor, 'MATCH', this.keys.scanPattern, 'COUNT', SCAN_COUNT);
316
- cursor = next;
317
- for (const key of batch) {
318
- if (!seen.has(key)) {
319
- seen.add(key);
320
- yield key;
321
- }
322
- }
323
- } while (cursor !== '0');
324
- }
325
- }
326
- }
327
- exports.RedisHistoryAdmin = RedisHistoryAdmin;
328
- //# sourceMappingURL=RedisHistoryAdmin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RedisHistoryAdmin.js","sourceRoot":"","sources":["../src/RedisHistoryAdmin.ts"],"names":[],"mappings":";;;AA6CA,0CA0BC;AAvED,6CAA+D;AAS/D,iCAAuF;AAGvF,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,uEAAuE;AACvE,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,OAAO,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AAC3E;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AAUjD;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,GAAW,EAAE,SAAiB;IAC5D,MAAM,MAAM,GAAG,GAAG,SAAS,GAAG,CAAC;IAC/B,IA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AAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;YAC/C,OAAO,IAAI,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,CAAC,IAAI;QACjB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,KAAK,MAAM,MAAM,IAAI,IAAA,wBAAW,EAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,IAAI,MAAM,GAAG,GAAG,CAAC;YACjB,GAAG,CAAC;gBACF,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,MAAM,MAAM,CAAC,IAAI,CACrC,MAAM,EACN,OAAO,EACP,IAAI,CAAC,IAAI,CAAC,WAAW,EACrB,OAAO,EACP,UAAU,CACX,CAAC;gBACF,MAAM,GAAG,IAAI,CAAC;gBACd,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;oBACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;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;AAjRD,8CAiRC"}
@@ -1,27 +0,0 @@
1
- import { type MetricsClient, type MetricsConnection } from './connection';
2
- import { type MetricsKeys } from './keys';
3
- import type { CounterStore, HistoryAdministration, LatencyStorage, MetricsStore, Retention } from './store';
4
- export interface RedisMetricsStoreOptions {
5
- /** An ioredis client (or Cluster), or options to open one. */
6
- connection: MetricsConnection;
7
- /** Key namespace. See `MetricsRecorderOptions.prefix`. */
8
- prefix?: string;
9
- }
10
- /**
11
- * History in Redis: hashes under one key namespace, expired by TTL. The default store,
12
- * which `connection` on the recorder, provider and admin is shorthand for.
13
- */
14
- export declare class RedisMetricsStore implements MetricsStore {
15
- readonly redis: MetricsClient;
16
- readonly keys: MetricsKeys;
17
- /** Whether `redis` was opened here from options, and so is closed by `close()`. */
18
- readonly ownsClient: boolean;
19
- private closed;
20
- constructor(opts: RedisMetricsStoreOptions);
21
- get jobClient(): MetricsClient;
22
- counterStore(retention: Retention): CounterStore;
23
- latencyStore(retention: Retention): LatencyStorage;
24
- administration(): HistoryAdministration;
25
- /** Disconnects a client this store opened; synchronous in effect, like `redis.disconnect()`. */
26
- close(): Promise<void>;
27
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RedisMetricsStore = void 0;
4
- const connection_1 = require("./connection");
5
- const HistoryStore_1 = require("./HistoryStore");
6
- const keys_1 = require("./keys");
7
- const LatencyStore_1 = require("./LatencyStore");
8
- const RedisHistoryAdmin_1 = require("./RedisHistoryAdmin");
9
- /**
10
- * History in Redis: hashes under one key namespace, expired by TTL. The default store,
11
- * which `connection` on the recorder, provider and admin is shorthand for.
12
- */
13
- class RedisMetricsStore {
14
- constructor(opts) {
15
- this.closed = false;
16
- const { client, owned } = (0, connection_1.resolveClient)(opts.connection);
17
- this.redis = client;
18
- this.ownsClient = owned;
19
- this.keys = (0, keys_1.metricsKeys)((0, keys_1.resolveNamespace)(opts.prefix, (0, connection_1.isCluster)(client)));
20
- }
21
- get jobClient() {
22
- return this.redis;
23
- }
24
- counterStore(retention) {
25
- return new HistoryStore_1.HistoryStore({ redis: this.redis, keys: this.keys, retention });
26
- }
27
- latencyStore(retention) {
28
- return new LatencyStore_1.LatencyStore({ redis: this.redis, keys: this.keys, retention });
29
- }
30
- administration() {
31
- return new RedisHistoryAdmin_1.RedisHistoryAdmin({ redis: this.redis, keys: this.keys });
32
- }
33
- /** Disconnects a client this store opened; synchronous in effect, like `redis.disconnect()`. */
34
- async close() {
35
- if (this.ownsClient && !this.closed) {
36
- this.redis.disconnect();
37
- }
38
- this.closed = true;
39
- }
40
- }
41
- exports.RedisMetricsStore = RedisMetricsStore;
42
- //# sourceMappingURL=RedisMetricsStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RedisMetricsStore.js","sourceRoot":"","sources":["../src/RedisMetricsStore.ts"],"names":[],"mappings":";;;AAAA,6CAAoG;AACpG,iDAA8C;AAC9C,iCAAyE;AACzE,iDAA8C;AAC9C,2DAAwD;AAgBxD;;;GAGG;AACH,MAAa,iBAAiB;IAO5B,YAAY,IAA8B;QAFlC,WAAM,GAAG,KAAK,CAAC;QAGrB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,0BAAa,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAA,kBAAW,EAAC,IAAA,uBAAgB,EAAC,IAAI,CAAC,MAAM,EAAE,IAAA,sBAAS,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,YAAY,CAAC,SAAoB;QAC/B,OAAO,IAAI,2BAAY,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,YAAY,CAAC,SAAoB;QAC/B,OAAO,IAAI,2BAAY,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,qCAAiB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,gGAAgG;IAChG,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACpC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;CACF;AArCD,8CAqCC"}
@@ -1,27 +0,0 @@
1
- import type { MetricsHistoryPoint, MetricsHistoryProvider, MetricsHistoryQuery, MetricsLatencyPoint, MetricsLatencyQuery } from '@worker-manager/api/typings/app';
2
- import type { HistoryStats, PurgeOptions, PurgeResult } from './HistoryAdmin';
3
- import type { MetricsStore, Retention } from './store';
4
- /**
5
- * The `MetricsHistoryProvider` contract over any `MetricsStore`. Everything that decides what
6
- * a chart receives lives here, once: span clamping, day-start alignment, the empty-history
7
- * rule and percentile merging. The stores only fetch buckets, so a Redis and a PostgreSQL
8
- * board answer the same query with the same points.
9
- */
10
- export declare class StoreHistoryProvider implements MetricsHistoryProvider {
11
- private readonly counters;
12
- private readonly latency;
13
- private readonly admin;
14
- private readonly retentionDays;
15
- constructor(store: MetricsStore, retention: Retention);
16
- /** Backs the board's storage panel. See MetricsHistoryAdmin.stats. */
17
- getUsage(): Promise<HistoryStats>;
18
- /** Backs the board's "clear history" action. See MetricsHistoryAdmin.purge. */
19
- purge(options?: PurgeOptions): Promise<PurgeResult>;
20
- getHistory(query: MetricsHistoryQuery): Promise<MetricsHistoryPoint[]>;
21
- getLatency(query: MetricsLatencyQuery): Promise<MetricsLatencyPoint[]>;
22
- /**
23
- * Clamps the span to the retention window so an unbounded `from` (e.g. 0) can't make
24
- * dayRange produce an unbounded number of day buckets -- older data doesn't exist anyway.
25
- */
26
- private daysFor;
27
- }