feat: add prometheus metrics to /metrics#466
Open
tgalske wants to merge 1 commit intoUnstructured-IO:mainfrom
Open
feat: add prometheus metrics to /metrics#466tgalske wants to merge 1 commit intoUnstructured-IO:mainfrom
tgalske wants to merge 1 commit intoUnstructured-IO:mainfrom
Conversation
de53ea0 to
b43fef0
Compare
tgalske
commented
Oct 14, 2024
| ) | ||
|
|
||
| metrics_app = make_asgi_app() | ||
| app.mount("/metrics", metrics_app) |
Author
There was a problem hiding this comment.
Pointing out that /metrics calls are not being logged already:
unstructured-api/prepline_general/api/app.py
Lines 121 to 124 in b43fef0
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.
Summary
This PR adds the Prometheus Python client as a dependency, and serves up the out-of-the-box metrics on the
/metricsendpoint.The metrics mounting code was taken almost directly from Prometheus' documentation on how to add metrics to a FastAPI application: https://prometheus.github.io/client_python/exporting/http/fastapi-gunicorn/
Since this would be my first contribution and in an effort to keep the change on the small side, this PR does not expose any custom metrics.
Testing
make docker-test,make checkpassmake docker-start-apiand observing the metrics at http://localhost:8000/metricsExample output