@zintrust/queue-monitor 2.1.9 → 2.2.0

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/driver.js CHANGED
@@ -97,30 +97,37 @@ export const createBullMQDriver = (config) => {
97
97
  };
98
98
  const getJobCountsMany = async (queueNames) => {
99
99
  const uniqueQueueNames = Array.from(new Set(queueNames.filter((queueName) => typeof queueName === 'string' && queueName.trim().length > 0)));
100
- Logger.info('[queue-monitor] getJobCountsMany start', {
101
- requestedCount: queueNames.length,
102
- uniqueCount: uniqueQueueNames.length,
103
- });
104
- const startedAt = Date.now();
105
- if (uniqueQueueNames.length === 0) {
106
- Logger.info('[queue-monitor] getJobCountsMany complete', {
107
- durationMs: Date.now() - startedAt,
100
+ const QUEUE_MONITOR_LOGGING_ENABLED = Env.getBool('QUEUE_MONITOR_LOGGING_ENABLED', false);
101
+ if (QUEUE_MONITOR_LOGGING_ENABLED) {
102
+ Logger.info('[queue-monitor] getJobCountsMany start', {
108
103
  requestedCount: queueNames.length,
109
104
  uniqueCount: uniqueQueueNames.length,
110
- pipelineCount: 0,
111
105
  });
106
+ }
107
+ const startedAt = Date.now();
108
+ if (uniqueQueueNames.length === 0) {
109
+ if (QUEUE_MONITOR_LOGGING_ENABLED) {
110
+ Logger.info('[queue-monitor] getJobCountsMany complete', {
111
+ durationMs: Date.now() - startedAt,
112
+ requestedCount: queueNames.length,
113
+ uniqueCount: uniqueQueueNames.length,
114
+ pipelineCount: 0,
115
+ });
116
+ }
112
117
  return [];
113
118
  }
114
119
  const stats = await Promise.all(uniqueQueueNames.map(async (name) => {
115
120
  const counts = await getJobCounts(name);
116
121
  return { name, counts };
117
122
  }));
118
- Logger.info('[queue-monitor] getJobCountsMany complete', {
119
- durationMs: Date.now() - startedAt,
120
- requestedCount: queueNames.length,
121
- uniqueCount: uniqueQueueNames.length,
122
- pipelineCount: uniqueQueueNames.length,
123
- });
123
+ if (QUEUE_MONITOR_LOGGING_ENABLED) {
124
+ Logger.info('[queue-monitor] getJobCountsMany complete', {
125
+ durationMs: Date.now() - startedAt,
126
+ requestedCount: queueNames.length,
127
+ uniqueCount: uniqueQueueNames.length,
128
+ pipelineCount: uniqueQueueNames.length,
129
+ });
130
+ }
124
131
  return stats;
125
132
  };
126
133
  const requeueFromSnapshot = async (queue, snapshot) => {
package/dist/index.js CHANGED
@@ -231,14 +231,17 @@ function createGetSnapshot(driver, startedAt, knownQueues) {
231
231
  const shouldDiscoverQueues = persistedQueues.length === 0;
232
232
  const discoveredQueues = shouldDiscoverQueues ? await driver.getQueues() : [];
233
233
  const queues = Array.from(new Set([...persistedQueues, ...discoveredQueues])).sort((left, right) => left.localeCompare(right));
234
- Logger.info('[queue-monitor] snapshot queue list resolved', {
235
- discoveredCount: discoveredQueues.length,
236
- persistedCount: persistedQueues.length,
237
- totalQueues: queues.length,
238
- usedRedisDiscovery: shouldDiscoverQueues,
239
- skippedRedisDiscovery: !shouldDiscoverQueues,
240
- hasBatchCounts: typeof driver.getJobCountsMany === 'function',
241
- });
234
+ const QUEUE_MONITOR_LOGGING_ENABLED = Env.getBool('QUEUE_MONITOR_LOGGING_ENABLED', false);
235
+ if (QUEUE_MONITOR_LOGGING_ENABLED) {
236
+ Logger.info('[queue-monitor] snapshot queue list resolved', {
237
+ discoveredCount: discoveredQueues.length,
238
+ persistedCount: persistedQueues.length,
239
+ totalQueues: queues.length,
240
+ usedRedisDiscovery: shouldDiscoverQueues,
241
+ skippedRedisDiscovery: !shouldDiscoverQueues,
242
+ hasBatchCounts: typeof driver.getJobCountsMany === 'function',
243
+ });
244
+ }
242
245
  const batchStartedAt = Date.now();
243
246
  const stats = typeof driver.getJobCountsMany === 'function'
244
247
  ? (await driver.getJobCountsMany(queues)).map((item) => ({
@@ -249,12 +252,14 @@ function createGetSnapshot(driver, startedAt, knownQueues) {
249
252
  const counts = await driver.getJobCounts(name);
250
253
  return { name, counts: counts };
251
254
  }));
252
- Logger.info('[queue-monitor] snapshot queue counts resolved', {
253
- durationMs: Date.now() - batchStartedAt,
254
- totalQueues: queues.length,
255
- returnedQueues: stats.length,
256
- usedBatchCounts: typeof driver.getJobCountsMany === 'function',
257
- });
255
+ if (QUEUE_MONITOR_LOGGING_ENABLED) {
256
+ Logger.info('[queue-monitor] snapshot queue counts resolved', {
257
+ durationMs: Date.now() - batchStartedAt,
258
+ totalQueues: queues.length,
259
+ returnedQueues: stats.length,
260
+ usedBatchCounts: typeof driver.getJobCountsMany === 'function',
261
+ });
262
+ }
258
263
  return {
259
264
  status: 'ok',
260
265
  startedAt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/queue-monitor",
3
- "version": "2.1.9",
3
+ "version": "2.2.0",
4
4
  "description": "Queue monitoring package for ZinTrust with BullMQ and Redis.",
5
5
  "private": false,
6
6
  "type": "module",