Sentry-python: How does sentry gets access to request body in the asgi middleware?

Created on 12 Apr 2021  路  5Comments  路  Source: getsentry/sentry-python

Hello, I was reading through the asgi middleware and it's not clear to me: how is the request data (i.e. the json payload of a POST request, for example) accessed to be sent by sentry, since all that's accessible there is the scope, passing receive and send downstream?

Thank you!

All 5 comments

You are right, we are not doing that in the ASGI middleware. I think the docs may be wrong.

I see! Do you think there's a way to include that too? Or maybe @thomchristie does?

Unfortunately I don't think this is possible in a memory-efficient way. In framework integrations we can piggyback on the in-memory buffering of the framework itself but in a middleware we would have to wrap the bytestream and keep our own copy, which is expensive.

Thank you :)

Was this page helpful?
0 / 5 - 0 ratings