Skip to content

Include bytes sent/received in HTTP requests for replays #7373

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

Closed
bruno-garcia opened this issue Mar 7, 2023 · 5 comments · Fixed by #7407
Closed

Include bytes sent/received in HTTP requests for replays #7373

bruno-garcia opened this issue Mar 7, 2023 · 5 comments · Fixed by #7407
Assignees
Labels
Package: replay Issues related to the Sentry Replay SDK Type: Improvement

Comments

@bruno-garcia
Copy link
Member

bruno-garcia commented Mar 7, 2023

The goal here is to get on the Replay blob request_body_size and response_body_size so we can understand how large these are.
We'll need to set some limits so it can also help answer the question: "Why don't I see my request body" or "why is it truncated"?

Additionally, it'll help us get a distribution of size and decide what these limits should be.

Note that Mobile SDKs add to breadcrumb.data the keys request_body_size and response_body_size to all breadcrumbs. This isn't on the develop docs it seems but possibly good value to breadcrumbs XHR/fetch on JS too outside of Replay

@bruno-garcia bruno-garcia added Type: Improvement Package: replay Issues related to the Sentry Replay SDK labels Mar 7, 2023
@bruno-garcia
Copy link
Member Author

FYI @krystofwoldrich outside of replays this would affect React Native and bring in on par to the other mobile SDKs if we're aligning.

@mydea
Copy link
Member

mydea commented Mar 8, 2023

So just to clarify, we'll add this for all breadcrumbs, not just in replay itself. We'll add:

  • request_body_size
  • response_body_size

Which we get the same way as for replay recording length:

new TextEncoder().encode(recordingData).length

(Which is not supported in IE11, so we'll just not have this data there).

Final question: Should we do this for all requests/responses, or just for e.g. JSON? For responses we can probably look at content-type headers, for requests not so much (we can't access them).

I would propose one of these options, for simplicity:

  1. Only capture it if we detect it to be a JSON string (starts with { and ends with }, or starts with [ and ends with ]), or form data (TBD how to detect this)
  2. Always capture it from the text representation (not 100% sure but may be incorrect for non-text media types, I guess)

@krystofwoldrich
Copy link
Member

@bruno-garcia Thanks
@mydea RN doesn't have TextEncoder either. If possible let's use the TextEncoderInternal abstraction so we can supply our own.

@billyvg
Copy link
Member

billyvg commented Mar 8, 2023

Final question: Should we do this for all requests/responses, or just for e.g. JSON? For responses we can probably look at content-type headers, for requests not so much (we can't access them).

Shouldn't we be able to access the request headers (at least for fetch?)

I would propose one of these options, for simplicity:

  1. Only capture it if we detect it to be a JSON string (starts with { and ends with }, or starts with [ and ends with ]), or form data (TBD how to detect this)
  2. Always capture it from the text representation (not 100% sure but may be incorrect for non-text media types, I guess)

I'd lean towards #2, but we should do some testing to see how inaccurate this can be.

@billyvg billyvg changed the title Include bytes sent/received in HTTP requests Include bytes sent/received in HTTP request breadcrumbs Mar 8, 2023
@billyvg billyvg changed the title Include bytes sent/received in HTTP request breadcrumbs Include bytes sent/received in HTTP requests for replays Mar 9, 2023
@dprevost-LMI
Copy link

dprevost-LMI commented Nov 28, 2024

bytes or kb, bytes I assume?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: replay Issues related to the Sentry Replay SDK Type: Improvement
Projects
None yet
5 participants