This commit is contained in:
Carl-Gerhard Lindesvärd
2025-11-10 10:09:59 +01:00
parent 37246f57f0
commit bb0e413b06
9 changed files with 76 additions and 107 deletions

View File

@@ -216,10 +216,10 @@ export async function bootWorkers() {
(worker as Worker).on('failed', (job) => {
if (job) {
if (job.processedOn && job.finishedOn) {
const duration = job.finishedOn - job.processedOn;
const elapsed = job.finishedOn - job.processedOn;
eventsGroupJobDuration.observe(
{ queue_shard: worker.name, status: 'failed' },
duration,
{ name: worker.name, status: 'failed' },
elapsed,
);
}
logger.error('job failed', {
@@ -235,10 +235,15 @@ export async function bootWorkers() {
(worker as Worker).on('completed', (job) => {
if (job) {
if (job.processedOn && job.finishedOn) {
const duration = job.finishedOn - job.processedOn;
const elapsed = job.finishedOn - job.processedOn;
logger.info('job completed', {
jobId: job.id,
worker: worker.name,
elapsed,
});
eventsGroupJobDuration.observe(
{ queue_shard: worker.name, status: 'success' },
duration,
{ name: worker.name, status: 'success' },
elapsed,
);
}
}

View File

@@ -16,9 +16,9 @@ const queues = [sessionsQueue, cronQueue, ...eventsGroupQueues];
// Histogram to track job processing time for eventsGroupQueues
export const eventsGroupJobDuration = new client.Histogram({
name: 'events_group_job_duration_ms',
help: 'Duration of job processing in eventsGroupQueues (in ms)',
labelNames: ['queue_shard', 'status'],
name: 'job_duration_ms',
help: 'Duration of job processing (in ms)',
labelNames: ['name', 'status'],
buckets: [10, 25, 50, 100, 250, 500, 750, 1000, 2000, 5000, 10000, 30000], // 10ms to 30s
});