@ngn-net/nestjs-telescope 0.3.13 → 0.3.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.
package/dist/ui/manifest.json
CHANGED
|
@@ -69,35 +69,72 @@ try {
|
|
|
69
69
|
return result;
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
// Patch
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
AmqpConnection.prototype.
|
|
76
|
-
const
|
|
77
|
-
|
|
72
|
+
// Patch setupSubscriberChannel for incoming (subscribe handlers)
|
|
73
|
+
const origSetupSubscriber = AmqpConnection.prototype.setupSubscriberChannel;
|
|
74
|
+
if (origSetupSubscriber) {
|
|
75
|
+
AmqpConnection.prototype.setupSubscriberChannel = async function (handler, msgOptions, channel, originalHandlerName) {
|
|
76
|
+
const queue = msgOptions?.queue || '';
|
|
77
|
+
const exchange = msgOptions?.exchange || '';
|
|
78
|
+
const routingKey = msgOptions?.routingKey || '';
|
|
79
|
+
const wrappedHandler = async (msg, rawMsg, headers) => {
|
|
80
|
+
if (rawMsg && rawMsg.content && telescopeRef) {
|
|
78
81
|
let parsed;
|
|
79
82
|
try {
|
|
80
|
-
parsed = JSON.parse(
|
|
83
|
+
parsed = JSON.parse(rawMsg.content.toString());
|
|
81
84
|
}
|
|
82
85
|
catch {
|
|
83
|
-
parsed =
|
|
86
|
+
parsed = rawMsg.content.toString();
|
|
84
87
|
}
|
|
85
88
|
telescopeRef.record({
|
|
86
89
|
type: entry_type_enum_1.EntryType.RABBITMQ,
|
|
87
90
|
content: {
|
|
88
91
|
direction: 'incoming',
|
|
89
92
|
queue,
|
|
90
|
-
exchange:
|
|
91
|
-
routingKey:
|
|
93
|
+
exchange: rawMsg.fields?.exchange || exchange,
|
|
94
|
+
routingKey: rawMsg.fields?.routingKey || routingKey,
|
|
92
95
|
message: sanitizeMessage(parsed),
|
|
93
|
-
deliveryTag:
|
|
96
|
+
deliveryTag: rawMsg.fields?.deliveryTag,
|
|
97
|
+
handler: originalHandlerName,
|
|
94
98
|
timestamp: new Date().toISOString(),
|
|
95
99
|
},
|
|
96
100
|
}).catch(() => { });
|
|
97
101
|
}
|
|
98
|
-
return handler(msg);
|
|
102
|
+
return handler(msg, rawMsg, headers);
|
|
99
103
|
};
|
|
100
|
-
return
|
|
104
|
+
return origSetupSubscriber.call(this, wrappedHandler, msgOptions, channel, originalHandlerName);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// Patch setupBatchSubscriberChannel for incoming (batch subscribe handlers)
|
|
108
|
+
const origSetupBatch = AmqpConnection.prototype.setupBatchSubscriberChannel;
|
|
109
|
+
if (origSetupBatch) {
|
|
110
|
+
AmqpConnection.prototype.setupBatchSubscriberChannel = async function (handler, msgOptions, channel) {
|
|
111
|
+
const queue = msgOptions?.queue || '';
|
|
112
|
+
const wrappedHandler = async (msgs, rawMsgs, headers) => {
|
|
113
|
+
if (telescopeRef && rawMsgs && rawMsgs.length > 0) {
|
|
114
|
+
const firstMsg = rawMsgs[0];
|
|
115
|
+
let parsed;
|
|
116
|
+
try {
|
|
117
|
+
parsed = JSON.parse(firstMsg.content.toString());
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
parsed = firstMsg.content.toString();
|
|
121
|
+
}
|
|
122
|
+
telescopeRef.record({
|
|
123
|
+
type: entry_type_enum_1.EntryType.RABBITMQ,
|
|
124
|
+
content: {
|
|
125
|
+
direction: 'incoming',
|
|
126
|
+
queue,
|
|
127
|
+
exchange: firstMsg.fields?.exchange || '',
|
|
128
|
+
routingKey: firstMsg.fields?.routingKey || queue,
|
|
129
|
+
message: sanitizeMessage(parsed),
|
|
130
|
+
batchSize: msgs.length,
|
|
131
|
+
timestamp: new Date().toISOString(),
|
|
132
|
+
},
|
|
133
|
+
}).catch(() => { });
|
|
134
|
+
}
|
|
135
|
+
return handler(msgs, rawMsgs, headers);
|
|
136
|
+
};
|
|
137
|
+
return origSetupBatch.call(this, wrappedHandler, msgOptions, channel);
|
|
101
138
|
};
|
|
102
139
|
}
|
|
103
140
|
}
|