You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone, as title mentions, I wonder if this is something that can be done, if so how?
My present understanding is that the default implementation of metrics works on per requests/response basis. At least those objects are available from the prometheus_fastapi_instrumentator.metrics.Info object. I use them and they work as expected. However, the API I work on triggers fastapi.BackgroundTask with some external computation process, that is executed asynchronously.
What I would like to have is a metrics on how long the BackgroundTask execution took as well as resources consumed. I can extract the values when the task is completed, but I have no idea how should I create metric and pass those values to the instrumentator, so that these values are consumed in the same fashion as the default metrices.
Generally speaking the API contains end point for passing parameters. Response is immediate with info that the job has started (or not). Next, there is another end point to retrieve status / download results. If the job completed successfully no new job is triggered when new request comes in with the same parameters.
Any help would be greatly appreciated. Thank you!
The text was updated successfully, but these errors were encountered:
Hey @lpravda, it sounds like this is not something that can be covered by this project. As you have pointed out it is really only usable for request/response workflows where the response represents the "end" of the task you are interested to instrument. So in your case I'd probably do the instrumentation myself either completely uncoupled from the FastAPI endpoint or extract path info from the request and use that info in combination with custom instrumentation
I wonder if there are other options / existing libraries available for this. But I cannot think of any. Maybe in the future OpenTelemetry initiative will this easy and many different small packages redundant.
Can you post an example or a link that shows using BackgroundTask? It is new to me
Hello everyone, as title mentions, I wonder if this is something that can be done, if so how?
My present understanding is that the default implementation of metrics works on per requests/response basis. At least those objects are available from the
prometheus_fastapi_instrumentator.metrics.Info
object. I use them and they work as expected. However, the API I work on triggersfastapi.BackgroundTask
with some external computation process, that is executed asynchronously.What I would like to have is a metrics on how long the BackgroundTask execution took as well as resources consumed. I can extract the values when the task is completed, but I have no idea how should I create metric and pass those values to the instrumentator, so that these values are consumed in the same fashion as the default metrices.
Generally speaking the API contains end point for passing parameters. Response is immediate with info that the job has started (or not). Next, there is another end point to retrieve status / download results. If the job completed successfully no new job is triggered when new request comes in with the same parameters.
Any help would be greatly appreciated. Thank you!
The text was updated successfully, but these errors were encountered: