Skip to content

Commit

Permalink
respect prefix for monitor command
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwitt committed Jul 9, 2024
1 parent 2100e4b commit 3f7a60f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
12 changes: 2 additions & 10 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,8 @@ export async function monitor (argv) {

// Load module after AWS global load
setupAWS(options)
const { getAggregateData } = await import('./monitor.js')
const { putAggregateData } = await import('./cloudWatch.js')
const data = await getAggregateData(queue)
console.log(data)
if (options.save) {
process.stderr.write('Saving to CloudWatch...')
await putAggregateData(data)
process.stderr.write('done\n')
}
return data
const { monitor } = await import('./monitor.js')
return monitor(queue, options.save, options)

Check warning on line 238 in src/cli.js

View check run for this annotation

Codecov / codecov/patch

src/cli.js#L237-L238

Added lines #L237 - L238 were not covered by tests
}

export async function loadBatchFile (filename) {
Expand Down
7 changes: 5 additions & 2 deletions src/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
import { getMatchingQueues, getQueueAttributes } from './sqs.js'
import { putAggregateData } from './cloudWatch.js'
import { getOptionsWithDefaults } from './defaults.js'
import { normalizeQueueName } from './qrlCache.js'
import Debug from 'debug'
const debug = Debug('sd:utils:qmonitor:index')
const debug = Debug('qdone:monitor')

/**
* Splits a queue name with a single wildcard into prefix and suffix regex.
*/
export async function monitor (queue, save, options) {
const opt = getOptionsWithDefaults(options)
const data = await getAggregateData(queue)
const queueName = normalizeQueueName(queue, opt)
debug({ opt, queueName })
const data = await getAggregateData(queueName)
console.log(data)

Check warning on line 20 in src/monitor.js

View check run for this annotation

Codecov / codecov/patch

src/monitor.js#L15-L20

Added lines #L15 - L20 were not covered by tests
if (save) {
if (opt.verbose) process.stderr.write('Saving to CloudWatch...')
Expand Down

0 comments on commit 3f7a60f

Please sign in to comment.