Skip to content
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

fix: refactor code, attach expres async router, fix typescript issues #9

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,192 +1,220 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should list 1 active job 1`] = `
exports[`Queue Gauges should list 1 active job 1`] = `
"# HELP test_stat_completed Number of completed messages
# TYPE test_stat_completed gauge
test_stat_completed{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 0
test_stat_completed{prefix="test-queue",queue="7a814e3e91b956ed"} 0

# HELP test_stat_complete_duration Time to complete jobs
# TYPE test_stat_complete_duration summary

# HELP test_stat_active Number of active messages
# TYPE test_stat_active gauge
test_stat_active{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 1
test_stat_active{prefix="test-queue",queue="7a814e3e91b956ed"} 1

# HELP test_stat_delayed Number of delayed messages
# TYPE test_stat_delayed gauge
test_stat_delayed{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 0
test_stat_delayed{prefix="test-queue",queue="7a814e3e91b956ed"} 0

# HELP test_stat_failed Number of failed messages
# TYPE test_stat_failed gauge
test_stat_failed{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 0
test_stat_failed{prefix="test-queue",queue="7a814e3e91b956ed"} 0

# HELP test_stat_waiting Number of waiting messages
# TYPE test_stat_waiting gauge
test_stat_waiting{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 0
test_stat_waiting{prefix="test-queue",queue="7a814e3e91b956ed"} 0

# HELP test_stat_prioritized Number of prioritized messages
# TYPE test_stat_prioritized gauge
test_stat_prioritized{prefix="test-queue",queue="7a814e3e91b956ed"} 0
"
`;

exports[`should list 1 active job 2`] = `
exports[`Queue Gauges should list 1 active job 2`] = `
"# HELP test_stat_completed Number of completed messages
# TYPE test_stat_completed gauge
test_stat_completed{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 1
test_stat_completed{prefix="test-queue",queue="7a814e3e91b956ed"} 1

# HELP test_stat_complete_duration Time to complete jobs
# TYPE test_stat_complete_duration summary

# HELP test_stat_active Number of active messages
# TYPE test_stat_active gauge
test_stat_active{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 0
test_stat_active{prefix="test-queue",queue="7a814e3e91b956ed"} 0

# HELP test_stat_delayed Number of delayed messages
# TYPE test_stat_delayed gauge
test_stat_delayed{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 0
test_stat_delayed{prefix="test-queue",queue="7a814e3e91b956ed"} 0

# HELP test_stat_failed Number of failed messages
# TYPE test_stat_failed gauge
test_stat_failed{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 0
test_stat_failed{prefix="test-queue",queue="7a814e3e91b956ed"} 0

# HELP test_stat_waiting Number of waiting messages
# TYPE test_stat_waiting gauge
test_stat_waiting{prefix="test-queue",queue="2dc07c0ff9d27ef5"} 0
test_stat_waiting{prefix="test-queue",queue="7a814e3e91b956ed"} 0

# HELP test_stat_prioritized Number of prioritized messages
# TYPE test_stat_prioritized gauge
test_stat_prioritized{prefix="test-queue",queue="7a814e3e91b956ed"} 0
"
`;

exports[`should list 1 completed job 1`] = `
exports[`Queue Gauges should list 1 completed job 1`] = `
"# HELP test_stat_completed Number of completed messages
# TYPE test_stat_completed gauge
test_stat_completed{prefix="test-queue",queue="7cc276b43bb43656"} 1
test_stat_completed{prefix="test-queue",queue="671b7dde665077bf"} 1

# HELP test_stat_complete_duration Time to complete jobs
# TYPE test_stat_complete_duration summary

# HELP test_stat_active Number of active messages
# TYPE test_stat_active gauge
test_stat_active{prefix="test-queue",queue="7cc276b43bb43656"} 0
test_stat_active{prefix="test-queue",queue="671b7dde665077bf"} 0

# HELP test_stat_delayed Number of delayed messages
# TYPE test_stat_delayed gauge
test_stat_delayed{prefix="test-queue",queue="7cc276b43bb43656"} 0
test_stat_delayed{prefix="test-queue",queue="671b7dde665077bf"} 0

# HELP test_stat_failed Number of failed messages
# TYPE test_stat_failed gauge
test_stat_failed{prefix="test-queue",queue="7cc276b43bb43656"} 0
test_stat_failed{prefix="test-queue",queue="671b7dde665077bf"} 0

# HELP test_stat_waiting Number of waiting messages
# TYPE test_stat_waiting gauge
test_stat_waiting{prefix="test-queue",queue="7cc276b43bb43656"} 0
test_stat_waiting{prefix="test-queue",queue="671b7dde665077bf"} 0

# HELP test_stat_prioritized Number of prioritized messages
# TYPE test_stat_prioritized gauge
test_stat_prioritized{prefix="test-queue",queue="671b7dde665077bf"} 0
"
`;

exports[`should list 1 completed job with delay 1`] = `
exports[`Queue Gauges should list 1 completed job with delay 1`] = `
"# HELP test_stat_completed Number of completed messages
# TYPE test_stat_completed gauge
test_stat_completed{prefix="test-queue",queue="672d03e07bff9cd3"} 1
test_stat_completed{prefix="test-queue",queue="ea1cc46ecbb104f2"} 1

# HELP test_stat_complete_duration Time to complete jobs
# TYPE test_stat_complete_duration summary
test_stat_complete_duration{quantile="0.01",prefix="test-queue",queue="672d03e07bff9cd3"} 1000
test_stat_complete_duration{quantile="0.05",prefix="test-queue",queue="672d03e07bff9cd3"} 1000
test_stat_complete_duration{quantile="0.5",prefix="test-queue",queue="672d03e07bff9cd3"} 1000
test_stat_complete_duration{quantile="0.9",prefix="test-queue",queue="672d03e07bff9cd3"} 1000
test_stat_complete_duration{quantile="0.95",prefix="test-queue",queue="672d03e07bff9cd3"} 1000
test_stat_complete_duration{quantile="0.99",prefix="test-queue",queue="672d03e07bff9cd3"} 1000
test_stat_complete_duration{quantile="0.999",prefix="test-queue",queue="672d03e07bff9cd3"} 1000
test_stat_complete_duration_sum{prefix="test-queue",queue="672d03e07bff9cd3"} 1000
test_stat_complete_duration_count{prefix="test-queue",queue="672d03e07bff9cd3"} 1
test_stat_complete_duration{quantile="0.01",prefix="test-queue",queue="ea1cc46ecbb104f2"} 1000
test_stat_complete_duration{quantile="0.05",prefix="test-queue",queue="ea1cc46ecbb104f2"} 1000
test_stat_complete_duration{quantile="0.5",prefix="test-queue",queue="ea1cc46ecbb104f2"} 1000
test_stat_complete_duration{quantile="0.9",prefix="test-queue",queue="ea1cc46ecbb104f2"} 1000
test_stat_complete_duration{quantile="0.95",prefix="test-queue",queue="ea1cc46ecbb104f2"} 1000
test_stat_complete_duration{quantile="0.99",prefix="test-queue",queue="ea1cc46ecbb104f2"} 1000
test_stat_complete_duration{quantile="0.999",prefix="test-queue",queue="ea1cc46ecbb104f2"} 1000
test_stat_complete_duration_sum{prefix="test-queue",queue="ea1cc46ecbb104f2"} 1000
test_stat_complete_duration_count{prefix="test-queue",queue="ea1cc46ecbb104f2"} 1

# HELP test_stat_active Number of active messages
# TYPE test_stat_active gauge
test_stat_active{prefix="test-queue",queue="672d03e07bff9cd3"} 0
test_stat_active{prefix="test-queue",queue="ea1cc46ecbb104f2"} 0

# HELP test_stat_delayed Number of delayed messages
# TYPE test_stat_delayed gauge
test_stat_delayed{prefix="test-queue",queue="672d03e07bff9cd3"} 0
test_stat_delayed{prefix="test-queue",queue="ea1cc46ecbb104f2"} 0

# HELP test_stat_failed Number of failed messages
# TYPE test_stat_failed gauge
test_stat_failed{prefix="test-queue",queue="672d03e07bff9cd3"} 0
test_stat_failed{prefix="test-queue",queue="ea1cc46ecbb104f2"} 0

# HELP test_stat_waiting Number of waiting messages
# TYPE test_stat_waiting gauge
test_stat_waiting{prefix="test-queue",queue="672d03e07bff9cd3"} 0
test_stat_waiting{prefix="test-queue",queue="ea1cc46ecbb104f2"} 0

# HELP test_stat_prioritized Number of prioritized messages
# TYPE test_stat_prioritized gauge
test_stat_prioritized{prefix="test-queue",queue="ea1cc46ecbb104f2"} 0
"
`;

exports[`should list 1 delayed job 1`] = `
exports[`Queue Gauges should list 1 delayed job 1`] = `
"# HELP test_stat_completed Number of completed messages
# TYPE test_stat_completed gauge
test_stat_completed{prefix="test-queue",queue="4f2249f79c9d68b5"} 0
test_stat_completed{prefix="test-queue",queue="33a2ca3b8ebeccb3"} 0

# HELP test_stat_complete_duration Time to complete jobs
# TYPE test_stat_complete_duration summary

# HELP test_stat_active Number of active messages
# TYPE test_stat_active gauge
test_stat_active{prefix="test-queue",queue="4f2249f79c9d68b5"} 0
test_stat_active{prefix="test-queue",queue="33a2ca3b8ebeccb3"} 0

# HELP test_stat_delayed Number of delayed messages
# TYPE test_stat_delayed gauge
test_stat_delayed{prefix="test-queue",queue="4f2249f79c9d68b5"} 1
test_stat_delayed{prefix="test-queue",queue="33a2ca3b8ebeccb3"} 1

# HELP test_stat_failed Number of failed messages
# TYPE test_stat_failed gauge
test_stat_failed{prefix="test-queue",queue="4f2249f79c9d68b5"} 0
test_stat_failed{prefix="test-queue",queue="33a2ca3b8ebeccb3"} 0

# HELP test_stat_waiting Number of waiting messages
# TYPE test_stat_waiting gauge
test_stat_waiting{prefix="test-queue",queue="4f2249f79c9d68b5"} 0
test_stat_waiting{prefix="test-queue",queue="33a2ca3b8ebeccb3"} 0

# HELP test_stat_prioritized Number of prioritized messages
# TYPE test_stat_prioritized gauge
test_stat_prioritized{prefix="test-queue",queue="33a2ca3b8ebeccb3"} 0
"
`;

exports[`should list 1 failed job 1`] = `
exports[`Queue Gauges should list 1 failed job 1`] = `
"# HELP test_stat_completed Number of completed messages
# TYPE test_stat_completed gauge
test_stat_completed{prefix="test-queue",queue="dd304535bf11c117"} 0
test_stat_completed{prefix="test-queue",queue="0ccf466733bb4e42"} 0

# HELP test_stat_complete_duration Time to complete jobs
# TYPE test_stat_complete_duration summary

# HELP test_stat_active Number of active messages
# TYPE test_stat_active gauge
test_stat_active{prefix="test-queue",queue="dd304535bf11c117"} 0
test_stat_active{prefix="test-queue",queue="0ccf466733bb4e42"} 0

# HELP test_stat_delayed Number of delayed messages
# TYPE test_stat_delayed gauge
test_stat_delayed{prefix="test-queue",queue="dd304535bf11c117"} 0
test_stat_delayed{prefix="test-queue",queue="0ccf466733bb4e42"} 0

# HELP test_stat_failed Number of failed messages
# TYPE test_stat_failed gauge
test_stat_failed{prefix="test-queue",queue="dd304535bf11c117"} 1
test_stat_failed{prefix="test-queue",queue="0ccf466733bb4e42"} 1

# HELP test_stat_waiting Number of waiting messages
# TYPE test_stat_waiting gauge
test_stat_waiting{prefix="test-queue",queue="dd304535bf11c117"} 0
test_stat_waiting{prefix="test-queue",queue="0ccf466733bb4e42"} 0

# HELP test_stat_prioritized Number of prioritized messages
# TYPE test_stat_prioritized gauge
test_stat_prioritized{prefix="test-queue",queue="0ccf466733bb4e42"} 0
"
`;

exports[`should list 1 queued job 1`] = `
exports[`Queue Gauges should list 1 queued job 1`] = `
"# HELP test_stat_completed Number of completed messages
# TYPE test_stat_completed gauge
test_stat_completed{prefix="test-queue",queue="54cceb2dc1d55935"} 0
test_stat_completed{prefix="test-queue",queue="e2e3d921e8b25f5e"} 0

# HELP test_stat_complete_duration Time to complete jobs
# TYPE test_stat_complete_duration summary

# HELP test_stat_active Number of active messages
# TYPE test_stat_active gauge
test_stat_active{prefix="test-queue",queue="54cceb2dc1d55935"} 0
test_stat_active{prefix="test-queue",queue="e2e3d921e8b25f5e"} 0

# HELP test_stat_delayed Number of delayed messages
# TYPE test_stat_delayed gauge
test_stat_delayed{prefix="test-queue",queue="54cceb2dc1d55935"} 0
test_stat_delayed{prefix="test-queue",queue="e2e3d921e8b25f5e"} 0

# HELP test_stat_failed Number of failed messages
# TYPE test_stat_failed gauge
test_stat_failed{prefix="test-queue",queue="54cceb2dc1d55935"} 0
test_stat_failed{prefix="test-queue",queue="e2e3d921e8b25f5e"} 0

# HELP test_stat_waiting Number of waiting messages
# TYPE test_stat_waiting gauge
test_stat_waiting{prefix="test-queue",queue="54cceb2dc1d55935"} 1
test_stat_waiting{prefix="test-queue",queue="e2e3d921e8b25f5e"} 1

# HELP test_stat_prioritized Number of prioritized messages
# TYPE test_stat_prioritized gauge
test_stat_prioritized{prefix="test-queue",queue="e2e3d921e8b25f5e"} 0
"
`;
2 changes: 1 addition & 1 deletion __tests__/create.util.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Processor, Queue, QueueEvents, Worker } from 'bullmq';
import { Registry } from 'prom-client';

import { makeGuages, QueueGauges } from '../src/queueGauges';
import { makeGuages, QueueGauges } from '../src/queue-gauges';

export interface TestData {
name: string;
Expand Down
Loading