Repository navigation
[18.0] Expose jobrunner metrics #1029
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
Draft
yvaucher
wants to merge
5
commits into
OCA:18.0
Choose a base branch
from
acsone:18.0-metrics-sbi-ypt
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b88d2d
[ADD] metrics gathering for Prometheus
sbidoul f799b8c
[ADD] metrics: add db label to metrics
yvaucher fc61335
[REM] metrics: remove leaf and root labels
sbidoul 405cbc2
[IMP] metrics: start metrics server after acquiring leader lock
sbidoul db858ba
[IMP] metrics: use empty value instead of 'None' for db label
sbidoul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,78 @@ | ||
| import socket | ||
| from http.server import HTTPServer | ||
|
|
||
| from prometheus_client import CollectorRegistry, Counter, Gauge, MetricsHandler | ||
|
|
||
| _registry = CollectorRegistry() | ||
|
|
||
| _channel_label_names = ("db", "channel") | ||
| channel_capacity = Gauge( | ||
| "queue_job_channel_capacity", | ||
| documentation="Channel Capacity", | ||
| labelnames=_channel_label_names, | ||
| registry=_registry, | ||
| ) | ||
| channel_pending = Gauge( | ||
| "queue_job_channel_pending", | ||
| documentation="Pending jobs in channel", | ||
| labelnames=_channel_label_names, | ||
| registry=_registry, | ||
| ) | ||
| channel_running = Gauge( | ||
| "queue_job_channel_running", | ||
| documentation="Running jobs in channel", | ||
| labelnames=_channel_label_names, | ||
| registry=_registry, | ||
| ) | ||
| channel_failed = Gauge( | ||
| "queue_job_channel_failed", | ||
| documentation="Failed jobs in channel", | ||
| labelnames=_channel_label_names, | ||
| registry=_registry, | ||
| ) | ||
| channel_waiting_dependencies = Gauge( | ||
| "queue_job_channel_waiting_dependencies", | ||
| documentation="Jobs waiting for dependencies in channel", | ||
| labelnames=_channel_label_names, | ||
| registry=_registry, | ||
| ) | ||
|
|
||
| jobs_to_do = Gauge( | ||
| "queue_job_jobs_to_do", | ||
| documentation=( | ||
| "Number of jobs waiting to be done (including running and failed jobs)" | ||
| ), | ||
| labelnames=("db",), | ||
| registry=_registry, | ||
| ) | ||
| jobs_scheduled_total = Counter( | ||
| "queue_job_jobs_scheduled_total", | ||
| documentation=( | ||
| "Total number of jobs scheduled for execution (asked Odoo to run job)" | ||
| ), | ||
| labelnames=("db",), | ||
| registry=_registry, | ||
| ) | ||
| dead_jobs_requeued_total = Counter( | ||
| "queue_job_dead_jobs_requeued_total", | ||
| documentation=("Total number of dead jobs requeued"), | ||
| labelnames=("db",), | ||
| registry=_registry, | ||
| ) | ||
|
|
||
|
|
||
| def db_label(db_name: str | None) -> str: | ||
| return db_name or "" | ||
|
|
||
|
|
||
| def make_metrics_server(bind_addr, port) -> HTTPServer: | ||
| infos = socket.getaddrinfo( | ||
| bind_addr, | ||
| port, | ||
| type=socket.SOCK_STREAM, | ||
| flags=socket.AI_PASSIVE, | ||
| ) | ||
| _, _, _, _, sockaddr = next(iter(infos)) | ||
| server = HTTPServer(sockaddr, MetricsHandler.factory(_registry)) | ||
| server.socket.setblocking(False) | ||
| return server |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: test that prometheus client renders math.inf correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It renders
+Inf. Now need to see what prometheus and grafana do with that.