@autofleet/rabbit 3.0.1-beta3 → 3.0.1-beta5
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/index.js +10 -3
- package/package.json +1 -1
- package/src/index.ts +10 -5
package/dist/index.js
CHANGED
|
@@ -139,7 +139,7 @@ class RabbitMq {
|
|
|
139
139
|
creationTimestamp: moment_1.default().valueOf(),
|
|
140
140
|
...customHeaders,
|
|
141
141
|
[consts_1.USER_TRACING_HEADER]: user?.id,
|
|
142
|
-
[consts_1.TRACING_HEADER]: traceId || outbreakTrace?.context?.get(consts_1.TRACING_HEADER),
|
|
142
|
+
[consts_1.TRACING_HEADER]: user?.traceId || outbreakTrace?.context?.get(consts_1.TRACING_HEADER),
|
|
143
143
|
},
|
|
144
144
|
};
|
|
145
145
|
}
|
|
@@ -350,7 +350,7 @@ class RabbitMq {
|
|
|
350
350
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
351
351
|
const trace = zehut_1.newTrace(zehut_1.traceTypes.RABBIT);
|
|
352
352
|
const outbreakTrace = zehut_1.newTrace(zehut_1.traceTypes.RABBIT);
|
|
353
|
-
if (userId
|
|
353
|
+
if (userId) {
|
|
354
354
|
try {
|
|
355
355
|
await zehut_1.createOrSetRabbitTrace(trace, userId);
|
|
356
356
|
}
|
|
@@ -359,9 +359,16 @@ class RabbitMq {
|
|
|
359
359
|
await this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }, msg, releaseLock)(msg);
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
|
-
if (traceId) {
|
|
362
|
+
else if (traceId) {
|
|
363
363
|
trace?.context?.set(consts_1.TRACING_HEADER, traceId);
|
|
364
364
|
outbreakTrace?.context.set(consts_1.TRACING_HEADER, traceId);
|
|
365
|
+
logger_1.default.info('rabbit consume - second trace', {
|
|
366
|
+
trace,
|
|
367
|
+
outbreakTrace,
|
|
368
|
+
user: trace?.context?.get(consts_1.USER_OBJECT),
|
|
369
|
+
traceId: trace?.context?.get(consts_1.TRACING_HEADER),
|
|
370
|
+
traceId2: outbreakTrace?.context?.get(consts_1.TRACING_HEADER),
|
|
371
|
+
});
|
|
365
372
|
}
|
|
366
373
|
if (auditContext) {
|
|
367
374
|
await auditContext(queue);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -127,7 +127,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
127
127
|
creationTimestamp: moment().valueOf(),
|
|
128
128
|
...customHeaders,
|
|
129
129
|
[USER_TRACING_HEADER]: user?.id,
|
|
130
|
-
[TRACING_HEADER]: traceId || outbreakTrace?.context?.get(TRACING_HEADER),
|
|
130
|
+
[TRACING_HEADER]: user?.traceId || outbreakTrace?.context?.get(TRACING_HEADER),
|
|
131
131
|
},
|
|
132
132
|
};
|
|
133
133
|
}
|
|
@@ -494,18 +494,23 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
494
494
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
495
495
|
const trace = newTrace(traceTypes.RABBIT);
|
|
496
496
|
const outbreakTrace = newTrace(traceTypes.RABBIT);
|
|
497
|
-
if (userId
|
|
497
|
+
if (userId) {
|
|
498
498
|
try {
|
|
499
499
|
await createOrSetRabbitTrace(trace, userId);
|
|
500
500
|
} catch (e) {
|
|
501
501
|
logger.error('rabbit: failed to setRabbitTrace', { userId, e });
|
|
502
502
|
await this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }, msg, releaseLock)(msg);
|
|
503
503
|
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
if (traceId) {
|
|
504
|
+
} else if (traceId) {
|
|
507
505
|
(trace as any)?.context?.set(TRACING_HEADER, traceId);
|
|
508
506
|
(outbreakTrace as any)?.context.set(TRACING_HEADER, traceId);
|
|
507
|
+
logger.info('rabbit consume - second trace', {
|
|
508
|
+
trace,
|
|
509
|
+
outbreakTrace,
|
|
510
|
+
user: trace?.context?.get(USER_OBJECT),
|
|
511
|
+
traceId: trace?.context?.get(TRACING_HEADER),
|
|
512
|
+
traceId2: outbreakTrace?.context?.get(TRACING_HEADER),
|
|
513
|
+
});
|
|
509
514
|
}
|
|
510
515
|
|
|
511
516
|
if (auditContext) {
|