@autofleet/rabbit 3.1.0 → 3.1.1
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 +3 -24
- package/package.json +1 -1
- package/src/index.ts +3 -26
package/dist/index.js
CHANGED
|
@@ -128,15 +128,6 @@ class RabbitMq {
|
|
|
128
128
|
const user = trace?.context?.get(consts_1.USER_OBJECT);
|
|
129
129
|
const traceId = trace?.context?.get(consts_1.TRACING_HEADER);
|
|
130
130
|
const outbreakTrace = zehut_1.outbreak.getCurrentContext();
|
|
131
|
-
const obj = Object.fromEntries(trace?.context);
|
|
132
|
-
const jsonString = JSON.stringify(obj);
|
|
133
|
-
logger_1.default.info('getPublishOptions', {
|
|
134
|
-
traceId,
|
|
135
|
-
user,
|
|
136
|
-
traceId2: outbreakTrace?.context?.get(consts_1.TRACING_HEADER),
|
|
137
|
-
traceContextSize: trace?.context?.size,
|
|
138
|
-
jsonString,
|
|
139
|
-
});
|
|
140
131
|
return {
|
|
141
132
|
timestamp: moment_1.default().unix(),
|
|
142
133
|
headers: {
|
|
@@ -349,11 +340,13 @@ class RabbitMq {
|
|
|
349
340
|
}
|
|
350
341
|
const traceId = msg.properties.headers[consts_1.TRACING_HEADER];
|
|
351
342
|
const userId = msg.properties.headers[consts_1.USER_TRACING_HEADER];
|
|
352
|
-
logger_1.default.info('rabbit: consume', { traceId, userId, enableRabbitTrace });
|
|
353
343
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
354
344
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
355
345
|
const trace = zehut_1.newTrace(zehut_1.traceTypes.RABBIT);
|
|
346
|
+
// setting also outbreak trace as part of legacy code
|
|
356
347
|
const outbreakTrace = zehut_1.outbreak.newTrace(zehut_1.traceTypes.RABBIT);
|
|
348
|
+
// enableRabbitTrace is a flag to protect from different flows that doesn't work with permission
|
|
349
|
+
// and we don't want to fail the flow because of it
|
|
357
350
|
if (userId && enableRabbitTrace) {
|
|
358
351
|
try {
|
|
359
352
|
await Promise.all([
|
|
@@ -366,24 +359,10 @@ class RabbitMq {
|
|
|
366
359
|
await this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }, msg, releaseLock)(msg);
|
|
367
360
|
}
|
|
368
361
|
}
|
|
369
|
-
logger_1.default.info('rabbit consume - first trace', {
|
|
370
|
-
trace,
|
|
371
|
-
outbreakTrace,
|
|
372
|
-
user: trace?.context?.get(consts_1.USER_OBJECT),
|
|
373
|
-
});
|
|
374
362
|
if (traceId) {
|
|
375
363
|
trace?.context?.set(consts_1.TRACING_HEADER, traceId);
|
|
376
364
|
outbreakTrace?.context.set(consts_1.TRACING_HEADER, traceId);
|
|
377
|
-
logger_1.default.info('rabbit consume - second trace', {
|
|
378
|
-
trace,
|
|
379
|
-
outbreakTrace,
|
|
380
|
-
user: trace?.context?.get(consts_1.USER_OBJECT),
|
|
381
|
-
traceId: trace?.context?.get(consts_1.TRACING_HEADER),
|
|
382
|
-
});
|
|
383
365
|
}
|
|
384
|
-
logger_1.default.info('rabbit consume - third trace', {
|
|
385
|
-
trace: zehut_1.getCurrentPayload(),
|
|
386
|
-
});
|
|
387
366
|
if (auditContext) {
|
|
388
367
|
await auditContext(queue);
|
|
389
368
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -116,15 +116,6 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
116
116
|
const user = trace?.context?.get(USER_OBJECT);
|
|
117
117
|
const traceId = trace?.context?.get(TRACING_HEADER);
|
|
118
118
|
const outbreakTrace = outbreak.getCurrentContext();
|
|
119
|
-
const obj = Object.fromEntries(trace?.context);
|
|
120
|
-
const jsonString = JSON.stringify(obj);
|
|
121
|
-
logger.info('getPublishOptions', {
|
|
122
|
-
traceId,
|
|
123
|
-
user,
|
|
124
|
-
traceId2: outbreakTrace?.context?.get(TRACING_HEADER),
|
|
125
|
-
traceContextSize: trace?.context?.size,
|
|
126
|
-
jsonString,
|
|
127
|
-
});
|
|
128
119
|
return {
|
|
129
120
|
timestamp: moment().unix(),
|
|
130
121
|
headers: {
|
|
@@ -493,11 +484,13 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
493
484
|
|
|
494
485
|
const traceId = msg.properties.headers[TRACING_HEADER];
|
|
495
486
|
const userId = msg.properties.headers[USER_TRACING_HEADER];
|
|
496
|
-
logger.info('rabbit: consume', { traceId, userId, enableRabbitTrace });
|
|
497
487
|
const parsedMessage = RabbitMq.parseMsg(msg);
|
|
498
488
|
const releaseLock = await this.lockRedisIfNeeded(parsedMessage, optionsWithDefaults);
|
|
499
489
|
const trace = newTrace(traceTypes.RABBIT);
|
|
490
|
+
// setting also outbreak trace as part of legacy code
|
|
500
491
|
const outbreakTrace = outbreak.newTrace(traceTypes.RABBIT);
|
|
492
|
+
// enableRabbitTrace is a flag to protect from different flows that doesn't work with permission
|
|
493
|
+
// and we don't want to fail the flow because of it
|
|
501
494
|
if (userId && enableRabbitTrace) {
|
|
502
495
|
try {
|
|
503
496
|
await Promise.all([
|
|
@@ -510,27 +503,11 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
510
503
|
}
|
|
511
504
|
}
|
|
512
505
|
|
|
513
|
-
logger.info('rabbit consume - first trace', {
|
|
514
|
-
trace,
|
|
515
|
-
outbreakTrace,
|
|
516
|
-
user: trace?.context?.get(USER_OBJECT),
|
|
517
|
-
});
|
|
518
|
-
|
|
519
506
|
if (traceId) {
|
|
520
507
|
(trace as any)?.context?.set(TRACING_HEADER, traceId);
|
|
521
508
|
(outbreakTrace as any)?.context.set(TRACING_HEADER, traceId);
|
|
522
|
-
logger.info('rabbit consume - second trace', {
|
|
523
|
-
trace,
|
|
524
|
-
outbreakTrace,
|
|
525
|
-
user: trace?.context?.get(USER_OBJECT),
|
|
526
|
-
traceId: trace?.context?.get(TRACING_HEADER),
|
|
527
|
-
// traceId2: outbreakTrace?.context?.get(TRACING_HEADER),
|
|
528
|
-
});
|
|
529
509
|
}
|
|
530
510
|
|
|
531
|
-
logger.info('rabbit consume - third trace', {
|
|
532
|
-
trace: getCurrentPayload(),
|
|
533
|
-
});
|
|
534
511
|
if (auditContext) {
|
|
535
512
|
await auditContext(queue);
|
|
536
513
|
}
|