Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting complete duration in metrics #1392

Closed
Xrazik1 opened this issue Aug 24, 2022 · 6 comments
Closed

Getting complete duration in metrics #1392

Xrazik1 opened this issue Aug 24, 2022 · 6 comments

Comments

@Xrazik1
Copy link

Xrazik1 commented Aug 24, 2022

Does this library have a built-in mechanism for retrieving information about jobs completion duration? I could not find any methods containing execution time info in QueueGetters.ts

@manast
Copy link
Contributor

manast commented Aug 24, 2022

Jobs include a timestamp and a finishOn fields that can be used for computing durations: https://api.docs.bullmq.io/classes/Job.html
Furthermore there is a metrics facility: https://docs.bullmq.io/guide/metrics

@Xrazik1
Copy link
Author

Xrazik1 commented Aug 24, 2022

Jobs include a timestamp and a finishOn fields that can be used for computing durations: https://api.docs.bullmq.io/classes/Job.html Furthermore there is a metrics facility: https://docs.bullmq.io/guide/metrics

Thank you, could you also explain the meaning of parameters in that object?) Don't see any explanation in docs.

export interface Metrics {
    meta: {
        count: number;
        prevTS: number;
        prevCount: number;
    };
    data: number[];
    count: number;
}

For example, I have maxDataPoints equaling MetricsTime.ONE_HOUR
After a several jobs metrics method returns following:

{
"meta": 
   {
     "count":12,
     "prevTS":1661381723723,
     "prevCount":11
   },
 "data":["3","8"],
 "count":2
}

What does each of them mean?

@Xrazik1
Copy link
Author

Xrazik1 commented Aug 24, 2022

I'll write how I see that, correct me if I misunderstand something.

meta.count - count of all jobs per hour(referring to maxDataPoints)
meta.prevTS - ?
meta.prevCount - a value before updating meta.count

data - an array of counts of jobs per point (per minute)
count - the size of the array above (max is maxDataPoints)

@manast
Copy link
Contributor

manast commented Aug 25, 2022

Meta is actually data used internally, maybe we should not expose it to avoid confusion. count is the number of jobs processed so far, prevCount the number of jobs processed up to the last minute boundary, prevTS is the previous TS where prevCount was updated. This is used to calculate the number of jobs that have been processed per minute.

@Xrazik1
Copy link
Author

Xrazik1 commented Aug 26, 2022

@manast
I have one more question about getting recent completed and failed jobs. Trying to get average job completion time.
There is a code below await queue.getJobs( [ 'completed', 'failed' ], 0, 60 ) here you can pull timestamp and finishedOn fields for that. But I've noticed this method returning static jobs(not recent). I tried using asc flag and there I got the same list of static data but from the other end of the list.

How to use this method to get the most recent jobs for a minute?

@manast
Copy link
Contributor

manast commented Aug 27, 2022

But I've noticed this method returning static jobs(not recent)

Not sure what you mean with that. The method returns the completed/failed jobs with "descending" order by default:
https://api.docs.bullmq.io/classes/Queue.html#getJobs

@taskforcesh taskforcesh locked and limited conversation to collaborators Aug 27, 2022
@manast manast converted this issue into discussion #1394 Aug 27, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants