@diia-inhouse/diia-queue 14.0.13 → 14.0.14
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.
|
@@ -32,6 +32,11 @@ type QueueConfigByQueueName = { [k in QueueName]: {
|
|
|
32
32
|
topics: ExchangeName[];
|
|
33
33
|
} };
|
|
34
34
|
type QueueConfig = Record<QueueConfigType.Internal, QueueConfigByQueueName>;
|
|
35
|
+
/**
|
|
36
|
+
* Under QueueConfigType.External, each key is auto-prefixed
|
|
37
|
+
* with 'TopicExternal' to form the broker exchange name (e.g.
|
|
38
|
+
* 'Auth' → 'TopicExternalAuth'). See ExternalEventBus.
|
|
39
|
+
*/
|
|
35
40
|
type TopicConfigByConfigType = { [k in ExchangeName]: {
|
|
36
41
|
events: EventName[];
|
|
37
42
|
} };
|
|
@@ -2,7 +2,7 @@ import { NackOptions } from "../interfaces/providers/rabbitmq/index.js";
|
|
|
2
2
|
import "../interfaces/index.js";
|
|
3
3
|
import { ApiError, ValidationError } from "@diia-inhouse/errors";
|
|
4
4
|
import { randomBytes } from "node:crypto";
|
|
5
|
-
import { isValidTraceId, trace } from "@opentelemetry/api";
|
|
5
|
+
import { context, isValidTraceId, propagation, trace } from "@opentelemetry/api";
|
|
6
6
|
import { utils } from "@diia-inhouse/utils";
|
|
7
7
|
//#region src/services/eventMessageHandler.ts
|
|
8
8
|
var EventMessageHandler = class {
|
|
@@ -107,17 +107,20 @@ var EventMessageHandler = class {
|
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
resolveTraceId(properties) {
|
|
110
|
-
const
|
|
110
|
+
const carrier = this.toPropagationCarrier(properties.headers);
|
|
111
|
+
const extractedTraceId = trace.getSpan(propagation.extract(context.active(), carrier))?.spanContext().traceId ?? "";
|
|
111
112
|
if (isValidTraceId(extractedTraceId)) return extractedTraceId;
|
|
112
113
|
const activeSpanTraceId = trace.getActiveSpan()?.spanContext().traceId ?? "";
|
|
113
114
|
if (isValidTraceId(activeSpanTraceId)) return activeSpanTraceId;
|
|
114
115
|
return properties.headers?.traceId || randomBytes(16).toString("hex");
|
|
115
116
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const [
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
toPropagationCarrier(headers) {
|
|
118
|
+
const carrier = {};
|
|
119
|
+
for (const [key, value] of Object.entries(headers ?? {})) {
|
|
120
|
+
if (value === void 0 || value === null) continue;
|
|
121
|
+
carrier[key] = Buffer.isBuffer(value) ? value.toString("utf8") : String(value);
|
|
122
|
+
}
|
|
123
|
+
return carrier;
|
|
121
124
|
}
|
|
122
125
|
};
|
|
123
126
|
//#endregion
|