-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable Prometheus metrics on the RabbitMQ Worker (#181)
* Enable Prometheus metrics on the RabbitMQ Worker * Extract Prom. metrics to separate module * Fix linter errors, fix missing import * Fix import * Add comment
- Loading branch information
1 parent
8c8e531
commit d6d6129
Showing
3 changed files
with
126 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from prometheus_client import ( | ||
Counter, | ||
Histogram, | ||
REGISTRY, | ||
GC_COLLECTOR, | ||
PROCESS_COLLECTOR, | ||
) | ||
|
||
# These definitions should be moved as close to the place | ||
# where they are used as possible. However, since we | ||
# support both a homebrewed Worker and one based on | ||
# RabbitMQ, these definitions would come into conflict. | ||
|
||
REGISTRY.unregister(GC_COLLECTOR) | ||
REGISTRY.unregister(PROCESS_COLLECTOR) | ||
|
||
TASKS_STARTED = Counter( | ||
"servicelayer_tasks_started_total", | ||
"Number of tasks that a worker started processing", | ||
["stage"], | ||
) | ||
|
||
TASKS_SUCCEEDED = Counter( | ||
"servicelayer_tasks_succeeded_total", | ||
"Number of successfully processed tasks", | ||
["stage", "retries"], | ||
) | ||
|
||
TASKS_FAILED = Counter( | ||
"servicelayer_tasks_failed_total", | ||
"Number of failed tasks", | ||
["stage", "retries", "failed_permanently"], | ||
) | ||
|
||
TASK_DURATION = Histogram( | ||
"servicelayer_task_duration_seconds", | ||
"Task duration in seconds", | ||
["stage"], | ||
# The bucket sizes are a rough guess right now, we might want to adjust | ||
# them later based on observed runtimes | ||
buckets=[ | ||
0.25, | ||
0.5, | ||
1, | ||
5, | ||
15, | ||
30, | ||
60, | ||
60 * 15, | ||
60 * 30, | ||
60 * 60, | ||
60 * 60 * 2, | ||
60 * 60 * 6, | ||
60 * 60 * 24, | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters