-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Limit reading bytes from request bodies (#168)
This change both limits the number of bytes that the SDK attempts to read and buffer in memory, as well as delays as much work as possible. It requires breaking changes to the exported API. Notes on API changes: - Request.FromHTTPRequest + NewRequest The difference is that NewRequest does not read the request body. FromHTTPRequest was called from HTTP middleware in integrations in the beginning of the request handling flow. Attempting to read the whole body there is often wasteful, since most requests should not result in reporting an error to Sentry. With this change, Scope.SetRequest keeps a lazy buffer that clones a limited portion of the request body only if it is read by the user. - Scope.SetRequest(Request) + Scope.SetRequest(*http.Request) For most integrations (fasthttp being the only exception), this means less work needs to be done when handling a request. Converting from http.Request to sentry.Request is only done when there is an error to be reported. It also means we can keep a reference to the request body without reading all bytes upfront. - Event.Request type Request + Event.Request type *Request Avoids copying of possibly large struct.
- Loading branch information
1 parent
7b7d396
commit db5e5da
Showing
15 changed files
with
353 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.