Closed sandeeppilania closed 3 years ago
You don't need this library probably. Just use something like this:
from pyinstrument import Profiler
app = ...
@app.middleware("http")
async def __profiling(request: Request, call_next):
p = Profiler()
p.start()
response: Response = await call_next(request)
p.stop()
p.print()
return response
@kigawas use a middleware is more pythonic. 😄
In the logs i just see the framework level tracing, where as i want to know it for every method under the endpoint call. Am i missing something or is that the expected output. this is how as per your example i am adding to the fastapi middleware.
app.add_middleware(PyInstrumentProfilerMiddleware)