@drawbridge/drawbridge-telemetry 0.0.2 → 0.0.3
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 +3 -5
- package/dist/bullmq.cjs +4 -3
- package/dist/bullmq.d.cts +11 -8
- package/dist/bullmq.d.ts +11 -8
- package/dist/bullmq.js +4 -3
- package/package.json +4 -6
package/README.md
CHANGED
|
@@ -21,8 +21,6 @@ Requires `@sentry/core` >= 10 as a peer dependency. Backend services satisfy thi
|
|
|
21
21
|
|
|
22
22
|
## Naming conventions
|
|
23
23
|
|
|
24
|
-
Codified in the plan at `~/.claude/plans/yes-lets-see-it-enumerated-bumblebee.md`. Summary:
|
|
25
|
-
|
|
26
24
|
- **Event names** — `<noun>.<verb>` past tense, lowercase, dot-separated. Verbs match drawbridge-api's action status vocabulary (`processing` / `succeeded` / `failed`; never `pending` / `completed`). Nouns are singular and match Mongo collection names.
|
|
27
25
|
- **Tag keys** — camelCase. Canonical `traceId` everywhere; `X-Request-Id` header stays for wire compat.
|
|
28
26
|
- **Event envelope** — `{ name, traceId, userId, organizationId, data: {...}, createdAt }`.
|
|
@@ -52,10 +50,10 @@ Sentry events for request BullMQ worker
|
|
|
52
50
|
|
|
53
51
|
For cron-style repeatable BullMQ jobs (no parent request or change event), synthesize a `__traceId` at enqueue time — pass it via `data.__traceId` to `enqueueFromWorker`.
|
|
54
52
|
|
|
55
|
-
## Build
|
|
53
|
+
## Build & publish
|
|
56
54
|
|
|
57
55
|
```sh
|
|
58
|
-
npm run build
|
|
56
|
+
npm run build # tsup + npm publish
|
|
59
57
|
```
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
Bump `version` in `package.json` before publishing.
|
package/dist/bullmq.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(bullmq_exports, {
|
|
|
34
34
|
wrapWorkerHandler: () => wrapWorkerHandler
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(bullmq_exports);
|
|
37
|
+
var import_crypto = require("crypto");
|
|
37
38
|
var Sentry2 = __toESM(require("@sentry/core"), 1);
|
|
38
39
|
|
|
39
40
|
// index.js
|
|
@@ -50,9 +51,9 @@ var currentTraceId = () => {
|
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
// bullmq.js
|
|
53
|
-
var wrapWorkerHandler = (handler) => async (
|
|
54
|
+
var wrapWorkerHandler = (handler) => async (job) => {
|
|
54
55
|
var _a;
|
|
55
|
-
const traceId = (_a = job == null ? void 0 : job.data) == null ? void 0 : _a.__traceId;
|
|
56
|
+
const traceId = ((_a = job == null ? void 0 : job.data) == null ? void 0 : _a.__traceId) || (0, import_crypto.randomUUID)();
|
|
56
57
|
return withTraceScope(traceId, (scope) => {
|
|
57
58
|
if (job == null ? void 0 : job.queueName) {
|
|
58
59
|
scope.setTag("queue", job.queueName);
|
|
@@ -62,7 +63,7 @@ var wrapWorkerHandler = (handler) => async (jobData, job) => {
|
|
|
62
63
|
scope.setTag("jobName", job.name);
|
|
63
64
|
}
|
|
64
65
|
;
|
|
65
|
-
return handler(
|
|
66
|
+
return handler(job);
|
|
66
67
|
});
|
|
67
68
|
};
|
|
68
69
|
var enqueueFromWorker = async (queue, name, data, options = {}) => {
|
package/dist/bullmq.d.cts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
1
2
|
import { currentTraceId, withTraceScope } from './index.cjs';
|
|
2
3
|
import '@sentry/core';
|
|
3
4
|
|
|
4
5
|
// Wrap a BullMQ worker handler so it runs inside a Sentry scope tagged
|
|
5
|
-
// with the job's traceId, queue name, and job name.
|
|
6
|
-
//
|
|
7
|
-
//
|
|
6
|
+
// with the job's traceId, queue name, and job name. Matches BullMQ's
|
|
7
|
+
// native single-arg `( job )` callback shape — pass it directly to
|
|
8
|
+
// `new Worker( name, wrapWorkerHandler( handler ), ... )`.
|
|
8
9
|
//
|
|
9
|
-
// The traceId originates from one of
|
|
10
|
+
// The traceId originates from one of three places:
|
|
10
11
|
// - HTTP request: the API's req.id is forwarded as job.data.__traceId
|
|
11
12
|
// - Change stream: the Mongo resume token (_id._data) is forwarded
|
|
12
|
-
//
|
|
13
|
+
// - Synthesized: any job arriving with no __traceId gets a fresh UUID,
|
|
14
|
+
// so cron / repeatable jobs (no parent context) still produce
|
|
15
|
+
// correlated downstream events.
|
|
13
16
|
|
|
14
|
-
const wrapWorkerHandler = ( handler ) => async (
|
|
17
|
+
const wrapWorkerHandler = ( handler ) => async ( job ) => {
|
|
15
18
|
|
|
16
|
-
const traceId = job?.data?.__traceId;
|
|
19
|
+
const traceId = job?.data?.__traceId || randomUUID();
|
|
17
20
|
|
|
18
21
|
return withTraceScope( traceId, ( scope ) => {
|
|
19
22
|
|
|
@@ -27,7 +30,7 @@ const wrapWorkerHandler = ( handler ) => async ( jobData, job ) => {
|
|
|
27
30
|
scope.setTag( 'jobName', job.name );
|
|
28
31
|
|
|
29
32
|
}
|
|
30
|
-
return handler(
|
|
33
|
+
return handler( job );
|
|
31
34
|
|
|
32
35
|
} );
|
|
33
36
|
|
package/dist/bullmq.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
1
2
|
import { currentTraceId, withTraceScope } from './index.js';
|
|
2
3
|
import '@sentry/core';
|
|
3
4
|
|
|
4
5
|
// Wrap a BullMQ worker handler so it runs inside a Sentry scope tagged
|
|
5
|
-
// with the job's traceId, queue name, and job name.
|
|
6
|
-
//
|
|
7
|
-
//
|
|
6
|
+
// with the job's traceId, queue name, and job name. Matches BullMQ's
|
|
7
|
+
// native single-arg `( job )` callback shape — pass it directly to
|
|
8
|
+
// `new Worker( name, wrapWorkerHandler( handler ), ... )`.
|
|
8
9
|
//
|
|
9
|
-
// The traceId originates from one of
|
|
10
|
+
// The traceId originates from one of three places:
|
|
10
11
|
// - HTTP request: the API's req.id is forwarded as job.data.__traceId
|
|
11
12
|
// - Change stream: the Mongo resume token (_id._data) is forwarded
|
|
12
|
-
//
|
|
13
|
+
// - Synthesized: any job arriving with no __traceId gets a fresh UUID,
|
|
14
|
+
// so cron / repeatable jobs (no parent context) still produce
|
|
15
|
+
// correlated downstream events.
|
|
13
16
|
|
|
14
|
-
const wrapWorkerHandler = ( handler ) => async (
|
|
17
|
+
const wrapWorkerHandler = ( handler ) => async ( job ) => {
|
|
15
18
|
|
|
16
|
-
const traceId = job?.data?.__traceId;
|
|
19
|
+
const traceId = job?.data?.__traceId || randomUUID();
|
|
17
20
|
|
|
18
21
|
return withTraceScope( traceId, ( scope ) => {
|
|
19
22
|
|
|
@@ -27,7 +30,7 @@ const wrapWorkerHandler = ( handler ) => async ( jobData, job ) => {
|
|
|
27
30
|
scope.setTag( 'jobName', job.name );
|
|
28
31
|
|
|
29
32
|
}
|
|
30
|
-
return handler(
|
|
33
|
+
return handler( job );
|
|
31
34
|
|
|
32
35
|
} );
|
|
33
36
|
|
package/dist/bullmq.js
CHANGED
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-SRV5HFQT.js";
|
|
5
5
|
|
|
6
6
|
// bullmq.js
|
|
7
|
+
import { randomUUID } from "crypto";
|
|
7
8
|
import * as Sentry from "@sentry/core";
|
|
8
|
-
var wrapWorkerHandler = (handler) => async (
|
|
9
|
+
var wrapWorkerHandler = (handler) => async (job) => {
|
|
9
10
|
var _a;
|
|
10
|
-
const traceId = (_a = job == null ? void 0 : job.data) == null ? void 0 : _a.__traceId;
|
|
11
|
+
const traceId = ((_a = job == null ? void 0 : job.data) == null ? void 0 : _a.__traceId) || randomUUID();
|
|
11
12
|
return withTraceScope(traceId, (scope) => {
|
|
12
13
|
if (job == null ? void 0 : job.queueName) {
|
|
13
14
|
scope.setTag("queue", job.queueName);
|
|
@@ -17,7 +18,7 @@ var wrapWorkerHandler = (handler) => async (jobData, job) => {
|
|
|
17
18
|
scope.setTag("jobName", job.name);
|
|
18
19
|
}
|
|
19
20
|
;
|
|
20
|
-
return handler(
|
|
21
|
+
return handler(job);
|
|
21
22
|
});
|
|
22
23
|
};
|
|
23
24
|
var enqueueFromWorker = async (queue, name, data, options = {}) => {
|
package/package.json
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
|
-
"dependencies": {
|
|
4
|
-
"tsup": "8.5.1",
|
|
5
|
-
"typescript": "5.9.3"
|
|
6
|
-
},
|
|
7
3
|
"peerDependencies": {
|
|
8
4
|
"@sentry/core": ">=10"
|
|
9
5
|
},
|
|
@@ -13,7 +9,9 @@
|
|
|
13
9
|
}
|
|
14
10
|
},
|
|
15
11
|
"devDependencies": {
|
|
16
|
-
"@sentry/core": "10.27.0"
|
|
12
|
+
"@sentry/core": "10.27.0",
|
|
13
|
+
"tsup": "8.5.1",
|
|
14
|
+
"typescript": "5.9.3"
|
|
17
15
|
},
|
|
18
16
|
"exports": {
|
|
19
17
|
".": {
|
|
@@ -52,5 +50,5 @@
|
|
|
52
50
|
"build": "tsup && npm publish"
|
|
53
51
|
},
|
|
54
52
|
"types": "dist/index.d.ts",
|
|
55
|
-
"version": "0.0.
|
|
53
|
+
"version": "0.0.3"
|
|
56
54
|
}
|