Skip to content

Commit

Permalink
Fix upload track w prom metrics (#3568)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicky-g authored and cheran-senthil committed Jul 28, 2022
1 parent 501bd95 commit ecdf990
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions creator-node/src/AsyncProcessingQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class AsyncProcessingQueue {
`Adding ${task} task! uuid=${logContext.requestID}}`,
logContext
)
const jobName = task || '__default__'
const job = await this.queue.add(jobName, params)

const job = await this.queue.add(params)

return job
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as PrometheusClient from 'prom-client'
* See `prometheusMonitoring/README.md` for usage details
*/

enum JobStatus {
enum JOB_STATUS {
COMPLETED = 'completed',
FAILED = 'failed'
}
Expand Down Expand Up @@ -70,7 +70,7 @@ export class PrometheusRegistry {

public recordJobMetrics(
labels: { [key: string]: string },
status: JobStatus,
status: JOB_STATUS,
job: Job
) {
if (!job.finishedOn) {
Expand Down Expand Up @@ -110,26 +110,30 @@ export class PrometheusRegistry {
if (useGlobal) {
queue.on('global:completed', async (jobId: number) => {
const job = await queue.getJob(jobId)
const job_name = job?.name || ''
const job_name = job?.data?.task || job?.name || ''
this.recordJobMetrics(
{ job_name, ...labels },
JobStatus.COMPLETED,
JOB_STATUS.COMPLETED,
job!
)
})
queue.on('global:failed', async (jobId: number) => {
const job = await queue.getJob(jobId)
const job_name = job?.name || ''
this.recordJobMetrics({ job_name, ...labels }, JobStatus.FAILED, job!)
const job_name = job?.data?.task || job?.name || ''
this.recordJobMetrics({ job_name, ...labels }, JOB_STATUS.FAILED, job!)
})
} else {
queue.on('completed', (job: Job) => {
const job_name = job.name
this.recordJobMetrics({ job_name, ...labels }, JobStatus.COMPLETED, job)
const job_name = job?.data?.task || job.name
this.recordJobMetrics(
{ job_name, ...labels },
JOB_STATUS.COMPLETED,
job
)
})
queue.on('failed', (job: Job) => {
const job_name = job.name
this.recordJobMetrics({ job_name, ...labels }, JobStatus.FAILED, job)
const job_name = job?.data?.task || job.name
this.recordJobMetrics({ job_name, ...labels }, JOB_STATUS.FAILED, job)
})
}

Expand Down

0 comments on commit ecdf990

Please sign in to comment.