Skip to content

Commit d582061

Browse files
fix: queue info with optimized queue runner (#405)
Co-authored-by: D045778 <johannes.vogel@sap.com> Co-authored-by: Johannes Vogel <31311694+johannes-vogel@users.noreply.github.com>
1 parent cabe34d commit d582061

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

lib/metrics/queue.js

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,25 @@ const PERSISTENT_QUEUE_DB_NAME = 'cds.outbox.Messages'
99
async function collectLatestQueueInfo(queueEntity, serviceName, maxAttempts) {
1010
const coldEntriesRow = await SELECT.one
1111
.columns([{ func: 'count', args: [{ val: 1 }], as: 'cold_count' }])
12-
.from(queueEntity)
13-
.where({
14-
target: serviceName,
15-
attempts: { '>=': maxAttempts }
16-
})
12+
.from(queueEntity).where`target = ${serviceName} or contains(msg, ${'"service":"' + serviceName})`.where({
13+
attempts: { '>=': maxAttempts }
14+
})
1715

1816
const remaingEntriesInfoRow = await SELECT.one
1917
.columns([
2018
{ func: 'count', args: [{ val: 1 }], as: 'remaining_count' },
2119
{ func: 'min', args: [{ ref: ['timestamp'] }], as: 'min_timestamp' },
2220
{ func: 'max', args: [{ ref: ['timestamp'] }], as: 'max_timestamp' }
2321
])
24-
.from(queueEntity)
25-
.where({
26-
target: serviceName,
27-
attempts: { '<': maxAttempts }
28-
})
22+
.from(queueEntity).where`target = ${serviceName} or contains(msg, ${'"service":"' + serviceName})`.where({
23+
attempts: { '<': maxAttempts }
24+
})
2925

3026
const remainingEntries = remaingEntriesInfoRow?.['remaining_count'] ?? 0
3127

32-
const medianStorageTimeRow = await SELECT.one
33-
.columns([{ ref: ['timestamp'], as: 'med_timestamp' }])
34-
.from(queueEntity)
35-
.where({
36-
target: serviceName,
37-
attempts: { '<': maxAttempts }
38-
})
28+
const medianStorageTimeRow = await SELECT.one.columns([{ ref: ['timestamp'], as: 'med_timestamp' }]).from(queueEntity)
29+
.where`target = ${serviceName} or contains(msg, ${'"service":"' + serviceName})`
30+
.where({ attempts: { '<': maxAttempts } })
3931
.orderBy({ ref: ['timestamp'], sort: 'asc' })
4032
.limit(1, Math.floor(remainingEntries / 2))
4133

0 commit comments

Comments
 (0)