-
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.
Extract Prom. metrics to separate module
- Loading branch information
1 parent
d0e4679
commit d879e08
Showing
3 changed files
with
79 additions
and
117 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,52 @@ | ||
from prometheus_client import ( | ||
start_http_server, | ||
Counter, | ||
Histogram, | ||
REGISTRY, | ||
GC_COLLECTOR, | ||
PROCESS_COLLECTOR, | ||
) | ||
|
||
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