Skip to content

How to avoid missing metrics until first request is received? #293

Answered by trallnag
alfaro28 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @alfaro28, you are raising a valid point. I've run into this problem myself a few times. What I'm doing atm is just writing a custom metrics closure like in metrics.py that also initializes all my metrics. I think I could bring that into the package itself by adding an optional parameter to the metric functions that accepts the FastAPI app. Then every metric function could decide on it's own if and how it wants to init stuff.

But this solution will never cover all corner cases without custom "metric functions" (I really should find a better name for these functions that take a few settings and return a function that actually performs stuff like incrementing metrics). The reason is tha…

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by trallnag
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@trallnag
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #25 on March 12, 2024 22:12.