@palmetto/pubsub 2.2.6 → 2.2.7
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/dist/bullmq/subscriber.js +2 -2
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -3
- package/dist/publisher.js +6 -4
- package/dist/rabbitmq/subscriber.js +3 -3
- package/package.json +3 -1
- package/dist/dd-trace.wrapper.d.ts +0 -75
- package/dist/dd-trace.wrapper.js +0 -45
|
@@ -14,7 +14,7 @@ const interfaces_js_1 = require("../interfaces.js");
|
|
|
14
14
|
const connection_js_1 = require("./connection.js");
|
|
15
15
|
const lazy_load_js_1 = require("../lazy-load.js");
|
|
16
16
|
const create_log_error_payload_js_1 = require("../create-log-error-payload.js");
|
|
17
|
-
const
|
|
17
|
+
const dd_trace_api_1 = require("dd-trace-api");
|
|
18
18
|
class SubscribedMessage {
|
|
19
19
|
constructor(owner, worker, logger) {
|
|
20
20
|
this.owner = owner;
|
|
@@ -65,7 +65,7 @@ class BullMqSubscriber {
|
|
|
65
65
|
context: "BullMqSubscriber",
|
|
66
66
|
});
|
|
67
67
|
const worker = new BullMqPackage.Worker(config.name, (job) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return yield
|
|
68
|
+
return yield dd_trace_api_1.tracer.trace("pubsub.bullmq.handle", {
|
|
69
69
|
resource: `handle ${config.name}`,
|
|
70
70
|
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
71
71
|
const context = {
|
package/dist/main.d.ts
CHANGED
package/dist/main.js
CHANGED
|
@@ -14,9 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.registerDdTrace = void 0;
|
|
18
|
-
var dd_trace_wrapper_js_1 = require("./dd-trace.wrapper.js");
|
|
19
|
-
Object.defineProperty(exports, "registerDdTrace", { enumerable: true, get: function () { return dd_trace_wrapper_js_1.registerDdTrace; } });
|
|
20
17
|
__exportStar(require("./errors.js"), exports);
|
|
21
18
|
__exportStar(require("./interfaces.js"), exports);
|
|
22
19
|
__exportStar(require("./publisher.js"), exports);
|
package/dist/publisher.js
CHANGED
|
@@ -15,7 +15,7 @@ const uuid_1 = require("uuid");
|
|
|
15
15
|
const crypto_1 = require("crypto");
|
|
16
16
|
const errors_js_1 = require("./errors.js");
|
|
17
17
|
const message_logger_js_1 = require("./message-logger.js");
|
|
18
|
-
const
|
|
18
|
+
const dd_trace_api_1 = require("dd-trace-api");
|
|
19
19
|
class Publisher {
|
|
20
20
|
constructor(logger, providers) {
|
|
21
21
|
var _a, _b;
|
|
@@ -57,7 +57,7 @@ class Publisher {
|
|
|
57
57
|
if (messages.length === 0) {
|
|
58
58
|
return Promise.resolve();
|
|
59
59
|
}
|
|
60
|
-
return
|
|
60
|
+
return dd_trace_api_1.tracer.trace("pubsub.publish", {
|
|
61
61
|
resource: `publish ${config.transport} ${config.name}`,
|
|
62
62
|
}, (span) => {
|
|
63
63
|
return this.publishImpl(config, messages, span);
|
|
@@ -113,8 +113,10 @@ class Publisher {
|
|
|
113
113
|
extra: Object.assign({ transport: provider.transport, name: config.name, durationMs: duration, batchSize: messages.length }, provider.enrichPublishedMesssageLog(config)),
|
|
114
114
|
});
|
|
115
115
|
});
|
|
116
|
-
span
|
|
117
|
-
|
|
116
|
+
if (span) {
|
|
117
|
+
span.setTag("pubsub.duration_ms", duration);
|
|
118
|
+
span.setTag("pubsub.message_count", messages.length);
|
|
119
|
+
}
|
|
118
120
|
});
|
|
119
121
|
}
|
|
120
122
|
close() {
|
|
@@ -15,7 +15,7 @@ const errors_js_1 = require("../errors.js");
|
|
|
15
15
|
const config_js_1 = require("./config.js");
|
|
16
16
|
const connection_js_1 = require("./connection.js");
|
|
17
17
|
const create_log_error_payload_js_1 = require("../create-log-error-payload.js");
|
|
18
|
-
const
|
|
18
|
+
const dd_trace_api_1 = require("dd-trace-api");
|
|
19
19
|
class SubscribedMessage {
|
|
20
20
|
constructor(owner, logger, config, onMessage, stop) {
|
|
21
21
|
this.owner = owner;
|
|
@@ -123,7 +123,7 @@ class RabbitMqSubscriber {
|
|
|
123
123
|
? setupResult.dlQueueName
|
|
124
124
|
: setupResult.queueName;
|
|
125
125
|
const onRabbitMessage = (msg) => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
yield
|
|
126
|
+
yield dd_trace_api_1.tracer.trace("pubsub.rabbit.consume", {
|
|
127
127
|
resource: `consume ${config.transport} ${queueName}`,
|
|
128
128
|
}, (span) => __awaiter(this, void 0, void 0, function* () {
|
|
129
129
|
try {
|
|
@@ -135,7 +135,7 @@ class RabbitMqSubscriber {
|
|
|
135
135
|
message: "Unexpected error handling RabbitMq message",
|
|
136
136
|
error: (0, create_log_error_payload_js_1.createLogErrorPayload)(err),
|
|
137
137
|
});
|
|
138
|
-
span.setTag("error", err);
|
|
138
|
+
span === null || span === void 0 ? void 0 : span.setTag("error", err);
|
|
139
139
|
try {
|
|
140
140
|
channel.nack(msg, undefined, true);
|
|
141
141
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@palmetto/pubsub",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"main": "./dist/main.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "yarn run -T eslint --fix ./src",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"amqp-connection-manager": "^4.1.14",
|
|
26
26
|
"amqplib": "^0.10.8",
|
|
27
27
|
"bullmq": "^5.58.0",
|
|
28
|
+
"opentracing": "^0.14.7",
|
|
28
29
|
"ts-node": "^10.9.2",
|
|
29
30
|
"typescript": "^5.8.3",
|
|
30
31
|
"vitest": "^3.2.4",
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"access": "public"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
45
|
+
"dd-trace-api": "^1.0.0",
|
|
44
46
|
"uuid": "^11.1.0"
|
|
45
47
|
},
|
|
46
48
|
"peerDependencies": {
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
export interface Span {
|
|
2
|
-
/**
|
|
3
|
-
* Adds a single tag to the span. See `addTags()` for details.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} key
|
|
6
|
-
* @param {any} value
|
|
7
|
-
*/
|
|
8
|
-
setTag(key: string, value: unknown): this;
|
|
9
|
-
}
|
|
10
|
-
interface SpanOptions {
|
|
11
|
-
/**
|
|
12
|
-
* set of key-value pairs which will be set as tags on the newly created
|
|
13
|
-
* Span. Ownership of the object is passed to the created span for
|
|
14
|
-
* efficiency reasons (the caller should not modify this object after
|
|
15
|
-
* calling startSpan).
|
|
16
|
-
*/
|
|
17
|
-
tags?: {
|
|
18
|
-
[key: string]: unknown;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The Datadog Scope Manager. This is used for context propagation.
|
|
23
|
-
*/
|
|
24
|
-
interface Scope {
|
|
25
|
-
/**
|
|
26
|
-
* Get the current active span or null if there is none.
|
|
27
|
-
*
|
|
28
|
-
* @returns {Span} The active span.
|
|
29
|
-
*/
|
|
30
|
-
active(): Span | null;
|
|
31
|
-
}
|
|
32
|
-
interface TraceOptions {
|
|
33
|
-
/**
|
|
34
|
-
* The resource you are tracing. The resource name must not be longer than
|
|
35
|
-
* 5000 characters.
|
|
36
|
-
*/
|
|
37
|
-
resource?: string;
|
|
38
|
-
/**
|
|
39
|
-
* The type of request.
|
|
40
|
-
*/
|
|
41
|
-
type?: string;
|
|
42
|
-
}
|
|
43
|
-
interface Tracer {
|
|
44
|
-
/**
|
|
45
|
-
* Instruments a function by automatically creating a span activated on its
|
|
46
|
-
* scope.
|
|
47
|
-
*
|
|
48
|
-
* The span will automatically be finished when one of these conditions is
|
|
49
|
-
* met:
|
|
50
|
-
*
|
|
51
|
-
* * The function returns a promise, in which case the span will finish when
|
|
52
|
-
* the promise is resolved or rejected.
|
|
53
|
-
* * The function takes a callback as its second parameter, in which case the
|
|
54
|
-
* span will finish when that callback is called.
|
|
55
|
-
* * The function doesn't accept a callback and doesn't return a promise, in
|
|
56
|
-
* which case the span will finish at the end of the function execution.
|
|
57
|
-
*/
|
|
58
|
-
trace<T>(name: string, options: TraceOptions & SpanOptions, fn: (span: Span) => Promise<T>): Promise<T>;
|
|
59
|
-
/**
|
|
60
|
-
* Returns a reference to the current scope.
|
|
61
|
-
*/
|
|
62
|
-
scope(): Scope;
|
|
63
|
-
}
|
|
64
|
-
export declare function getTracer(): Tracer;
|
|
65
|
-
/**
|
|
66
|
-
* Registers the dd-trace tracer instance to be used by the pubsub package.
|
|
67
|
-
*
|
|
68
|
-
* Usage:
|
|
69
|
-
* import trace from 'dd-trace';
|
|
70
|
-
* registerDdTrace(trace.init());
|
|
71
|
-
*
|
|
72
|
-
* @param tracer the tracer instance
|
|
73
|
-
*/
|
|
74
|
-
export declare function registerDdTrace(tracer: unknown): void;
|
|
75
|
-
export {};
|
package/dist/dd-trace.wrapper.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTracer = getTracer;
|
|
4
|
-
exports.registerDdTrace = registerDdTrace;
|
|
5
|
-
class NoOpSpan {
|
|
6
|
-
finish() {
|
|
7
|
-
// no-op
|
|
8
|
-
}
|
|
9
|
-
setTag(_key, _value) {
|
|
10
|
-
return this;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
class NoOpScope {
|
|
14
|
-
active() {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
class NoOpTracer {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.noOpSpan = new NoOpSpan();
|
|
21
|
-
this.noOpScope = new NoOpScope();
|
|
22
|
-
}
|
|
23
|
-
trace(_name, _options, fn) {
|
|
24
|
-
return fn(this.noOpSpan);
|
|
25
|
-
}
|
|
26
|
-
scope() {
|
|
27
|
-
return this.noOpScope;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
let tracerInstance = new NoOpTracer();
|
|
31
|
-
function getTracer() {
|
|
32
|
-
return tracerInstance;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Registers the dd-trace tracer instance to be used by the pubsub package.
|
|
36
|
-
*
|
|
37
|
-
* Usage:
|
|
38
|
-
* import trace from 'dd-trace';
|
|
39
|
-
* registerDdTrace(trace.init());
|
|
40
|
-
*
|
|
41
|
-
* @param tracer the tracer instance
|
|
42
|
-
*/
|
|
43
|
-
function registerDdTrace(tracer) {
|
|
44
|
-
tracerInstance = tracer;
|
|
45
|
-
}
|