Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question - I am not able to track every method under my fastapi endpoint #4

Closed
sandeeppilania opened this issue Apr 6, 2021 · 2 comments

Comments

@sandeeppilania
Copy link

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)

@kigawas
Copy link

kigawas commented Aug 5, 2021

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

@sunhailin-Leo
Copy link
Owner

@kigawas use a middleware is more pythonic. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants