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
Integration for FastAPI #829
Comments
This comment has been minimized.
This comment has been minimized.
@KrunchMuffin you're running into #860, fixed in 0.19.1. I'm collapsing your comment because it's unrelated. |
RE: what doesn't work well. I'm trying to work out how to best attach some additional context (user information, from a session) to a sentry event. The user information is per request. Can the middleware accommodate this use case currently? Edit: As @untitaker pointed out, this should already work as expected. I missed in the docs here the part which reads "Each request has a separate scope. Changes to the scope within a view, for example setting a tag, will only apply to events sent as part of the request being handled." |
The Middleware should make sure that the data you set within a request
handler does not persist between requests.
…On Fri, May 28, 2021, 22:43 adg-mh ***@***.***> wrote:
I'm trying to work out how to best attach some additional context (user
information, from a session) to a sentry event. The user information is per
request. Can the middleware accommodate this use case currently?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#829 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGMPRPWDJ2TXSTE7MDCEOLTP76AHANCNFSM4RVQVJNA>
.
|
What aspect of performance monitoring is missing with the Is there an example of the "gold standard"? For example, is the Django integration more feature-filled? |
The Django integration is feature-complete and our gold standard for sure.
The main feature that is missing from the ASGI and WSGI Middleware is that
the transaction name is not set automatically because the Middleware cannot
have knowledge of request routing. But having this information is critical
for the product. So you need to set it manually for now.
…On Sat, May 29, 2021, 14:13 Ricky ***@***.***> wrote:
particularly around Performance monitoring
What aspect of performance monitoring is missing with the
SentryAsgiMiddleware() class? I see that it's tracking transactions, that
should give us full performance monitoring, right?
Is there an example of the "gold standard"? For example, is the Django
integration more feature-filled?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#829 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGMPRKGDSWGVGBLCWZTA5TTQDK7DANCNFSM4RVQVJNA>
.
|
@untitaker can you expand on what we need to do to set this manually? |
Run this in your view: https://docs.sentry.io/platforms/python/enriching-events/transaction-name/ |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
The setup for ASGI in the documentation didn't work for me, but this worked: https://issueexplorer.com/issue/getsentry/sentry-python/1215 |
@aimfeld, it seems as a reason for another issue :) |
Another thing is not working as expected (at least for me) is the release health dashboard, the support team told me was because the autodetection of the transactions, is it already fixed? or this will be fixed with this integration? |
@juanbenitopr we added session tracking for ASGI only in 1.5.5, so maybe upgrade and try out the latest version and it should work. |
@sl0thentr0py thank you! I will try it :) |
@aimfeld I am also not able to integrate Sentry into FastAPI using the ASGIMiddleware solution. Can you please share the other link(or code) which worked for you as the solution link you shared is broken? |
for the record this works for me.
|
For me, when I added the I ended up using the code from it and a now abandoned open source project to write a custom middleware for Starlette that's based on In addition there are two custom error types that FastAPI uses |
This issue was created almost two years ago, is there any progress or even a desire for building native Sentry / FastAPI integration? FastAPI arguably is in top 3 of python web frameworks (based on Github stars, 44K stars just behind Django and Flask) so I think it would be quite popular. |
perfect timing @ruslaniv! We want to start work on the FastAPI integration next quarter. And have some project kickoff planning this afternoon. |
Just a quick update, @sl0thentr0py has started working on this. As FastAPI is a wrapper around Starlette he started doing a Startlette Integration that will be the foundation of the FastAPI integration. Have a look here: #1441 |
@sl0thentr0py Note that the SentryASGI Middleware seems to be swallowing Starlette ServerErrors. Had some trouble figuring this out myself, since I was using Streaming Responses and was only seeing RuntimeErrors. Turns out it was because of Sentry's middlware. Check this thread out for more information: encode/starlette#1739 |
Hey @RamiAwar ! |
Just to clarify even further for the sake of completeness: Sentry DOES log the error that happens as part of the StreamingResponse, but the server log does not: Server log only logs a Runtime error and uncaught exception, without specifying what it was. It's pretty weird to replicate. Happened only with Pydantic validation errors that happened inside the generator passed into the streaming response. Did not happen with generic exceptions. |
initial release will be with manual integration, so we can do some testing in the wild before auto-enabling for all users |
This has now been released! |
FastAPI is just Starlette which is just ASGI. We have an ASGI integration that should work fine. However, it would be nice to have deeper integration than we currently provide, particularly around Performance monitoring.
Please vote with 👍 on this post if you're interested in this. I would also like to hear what currently doesn't work out well with the ASGI middleware applied to your FastAPI app.
The text was updated successfully, but these errors were encountered: