@rudderjs/pulse 6.0.0 → 6.1.0
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.
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import type { Recorder, PulseStorage } from '../types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Tracks queue throughput, wait time, and failed jobs
|
|
4
|
-
*
|
|
3
|
+
* Tracks queue throughput, wait time, and failed jobs by subscribing to
|
|
4
|
+
* `@rudderjs/queue/observers`. Replaces the legacy `dispatch()`
|
|
5
|
+
* monkey-patch which only fired in the dispatching process — under
|
|
6
|
+
* BullMQ, worker-side completion and failure events were never recorded
|
|
7
|
+
* and `queue_wait_time` was actually the enqueue duration, not the
|
|
8
|
+
* queue-to-active wait.
|
|
5
9
|
*/
|
|
6
10
|
export declare class QueueRecorder implements Recorder {
|
|
7
11
|
private readonly storage;
|
|
8
12
|
readonly name = "Queue Recorder";
|
|
13
|
+
private unsubscribe;
|
|
9
14
|
constructor(storage: PulseStorage);
|
|
10
|
-
register():
|
|
15
|
+
register(): void;
|
|
16
|
+
/** @internal — used in tests + provider shutdown. */
|
|
17
|
+
unregister(): void;
|
|
11
18
|
}
|
|
12
19
|
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/recorders/queue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/recorders/queue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEzD;;;;;;;GAOG;AACH,qBAAa,aAAc,YAAW,QAAQ;IAIhC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,QAAQ,CAAC,IAAI,oBAAmB;IAChC,OAAO,CAAC,WAAW,CAA4B;gBAElB,OAAO,EAAE,YAAY;IAElD,QAAQ,IAAI,IAAI;IA6BhB,qDAAqD;IACrD,UAAU,IAAI,IAAI;CAInB"}
|
package/dist/recorders/queue.js
CHANGED
|
@@ -1,43 +1,52 @@
|
|
|
1
|
+
import { queueObservers } from '@rudderjs/queue/observers';
|
|
1
2
|
/**
|
|
2
|
-
* Tracks queue throughput, wait time, and failed jobs
|
|
3
|
-
*
|
|
3
|
+
* Tracks queue throughput, wait time, and failed jobs by subscribing to
|
|
4
|
+
* `@rudderjs/queue/observers`. Replaces the legacy `dispatch()`
|
|
5
|
+
* monkey-patch which only fired in the dispatching process — under
|
|
6
|
+
* BullMQ, worker-side completion and failure events were never recorded
|
|
7
|
+
* and `queue_wait_time` was actually the enqueue duration, not the
|
|
8
|
+
* queue-to-active wait.
|
|
4
9
|
*/
|
|
5
10
|
export class QueueRecorder {
|
|
6
11
|
storage;
|
|
7
12
|
name = 'Queue Recorder';
|
|
13
|
+
unsubscribe = null;
|
|
8
14
|
constructor(storage) {
|
|
9
15
|
this.storage = storage;
|
|
10
16
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
register() {
|
|
18
|
+
this.unsubscribe = queueObservers.subscribe((event) => {
|
|
19
|
+
try {
|
|
20
|
+
switch (event.kind) {
|
|
21
|
+
case 'job.active': {
|
|
22
|
+
const wait = event.startedAt.getTime() - event.dispatchedAt.getTime();
|
|
23
|
+
void this.storage.record('queue_wait_time', wait);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case 'job.completed':
|
|
27
|
+
void this.storage.record('queue_throughput', 1);
|
|
28
|
+
break;
|
|
29
|
+
case 'job.failed':
|
|
30
|
+
void this.storage.record('queue_throughput', 1);
|
|
31
|
+
void this.storage.storeEntry('failed_job', {
|
|
32
|
+
class: event.name,
|
|
33
|
+
queue: event.queue,
|
|
34
|
+
jobId: event.jobId,
|
|
35
|
+
attempts: event.attempts,
|
|
36
|
+
exception: event.error,
|
|
37
|
+
});
|
|
38
|
+
break;
|
|
26
39
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
// @rudderjs/queue not installed — skip
|
|
40
|
-
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// observer errors must not break the queue layer
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** @internal — used in tests + provider shutdown. */
|
|
47
|
+
unregister() {
|
|
48
|
+
this.unsubscribe?.();
|
|
49
|
+
this.unsubscribe = null;
|
|
41
50
|
}
|
|
42
51
|
}
|
|
43
52
|
//# sourceMappingURL=queue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/recorders/queue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/recorders/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAG1D;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IAIK;IAHpB,IAAI,GAAG,gBAAgB,CAAA;IACxB,WAAW,GAAwB,IAAI,CAAA;IAE/C,YAA6B,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAG,CAAC;IAEtD,QAAQ;QACN,IAAI,CAAC,WAAW,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YACpD,IAAI,CAAC;gBACH,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;oBACnB,KAAK,YAAY,CAAC,CAAC,CAAC;wBAClB,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,CAAA;wBACrE,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAA;wBACjD,MAAK;oBACP,CAAC;oBACD,KAAK,eAAe;wBAClB,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAA;wBAC/C,MAAK;oBACP,KAAK,YAAY;wBACf,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAA;wBAC/C,KAAK,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,EAAE;4BACzC,KAAK,EAAM,KAAK,CAAC,IAAI;4BACrB,KAAK,EAAM,KAAK,CAAC,KAAK;4BACtB,KAAK,EAAM,KAAK,CAAC,KAAK;4BACtB,QAAQ,EAAG,KAAK,CAAC,QAAQ;4BACzB,SAAS,EAAE,KAAK,CAAC,KAAK;yBACvB,CAAC,CAAA;wBACF,MAAK;gBACT,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,iDAAiD;YACnD,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,qDAAqD;IACrD,UAAU;QACR,IAAI,CAAC,WAAW,EAAE,EAAE,CAAA;QACpB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rudderjs/pulse",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"rudderjs": {
|
|
5
5
|
"provider": "PulseProvider",
|
|
6
6
|
"stage": "monitoring"
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@rudderjs/
|
|
29
|
-
"@rudderjs/
|
|
28
|
+
"@rudderjs/contracts": "^1.1.0",
|
|
29
|
+
"@rudderjs/core": "^1.0.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@rudderjs/router": "^1.0.0",
|
|
33
32
|
"@rudderjs/middleware": "^1.0.0",
|
|
34
|
-
"@rudderjs/
|
|
33
|
+
"@rudderjs/router": "^1.0.0",
|
|
35
34
|
"@rudderjs/orm": "^1.3.0",
|
|
36
35
|
"@rudderjs/cache": "^1.0.0",
|
|
37
|
-
"@rudderjs/
|
|
36
|
+
"@rudderjs/log": "^1.0.0",
|
|
37
|
+
"@rudderjs/queue": "^4.1.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@rudderjs/log": {
|
|
@@ -56,7 +56,8 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^20.0.0",
|
|
58
58
|
"@types/better-sqlite3": "^7.6.0",
|
|
59
|
-
"typescript": "^5.4.0"
|
|
59
|
+
"typescript": "^5.4.0",
|
|
60
|
+
"@rudderjs/queue": "^4.1.0"
|
|
60
61
|
},
|
|
61
62
|
"author": "Suleiman Shahbari",
|
|
62
63
|
"scripts": {
|