Repository navigation
feat(metrics): expose Prometheus device gauges (#31) - #36
Open
2022117144 wants to merge 1 commit into
Open
2022117144 wants to merge 1 commit into
2022117144 wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed
Closes #31.
create_metrics_router(db)endpoint that publishes the current SQLite device totals, alive, and down states in Prometheus text exposition format.app.mainAPI. Remove an unusedDeviceimport that prevented loading the module.prometheus-client, requirements file for the existing Dockerfile, user documentation, and 5 backend tests.Local verification
On Windows / Python 3.10 (with
prometheus-client 0.26.0):python -m pytest -q -p no:cacheprovider tests/test_metrics.py: 5 passed (one third-party TestClient deprecation warning).python -m flake8 app/metrics.py app/main.py tests/test_metrics.py --select=E9,F63,F7,F82 --show-source: exit 0.git diff --check: exit 0.Tests cover empty database, mixed online/offline counts, state updates reflected on the next scrape, independent repeated scrapes and hidden OpenAPI schema.
Limitations
An actual Prometheus deployment/scrape was not run; the tests use a local FastAPI TestClient and parse official Prometheus metric text. The repository's separate CI/environment-config issues #11 and #13 have separate pending PRs; this PR targets only metrics and introduces no Raspberry Pi hardware dependency.
AI-assisted implementation and verification; no cash bounty, hiring or payment acceptance is claimed.