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

Feat: Failed requests HTTP client #473

Merged
merged 23 commits into from
Jun 15, 2021
Merged

Feat: Failed requests HTTP client #473

merged 23 commits into from
Jun 15, 2021

Conversation

ueman
Copy link
Collaborator

@ueman ueman commented May 25, 2021

📜 Description

This is a HTTP client wich automatically add failed requests to an event.

💡 Motivation and Context

Closes #292

💚 How did you test it?

It still needs tests.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

🔮 Next steps

@codecov-commenter
Copy link

codecov-commenter commented May 25, 2021

Codecov Report

Merging #473 (5d382cf) into main (6873600) will decrease coverage by 0.01%.
The diff coverage is 89.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #473      +/-   ##
==========================================
- Coverage   91.24%   91.23%   -0.02%     
==========================================
  Files          63       66       +3     
  Lines        2091     2168      +77     
==========================================
+ Hits         1908     1978      +70     
- Misses        183      190       +7     
Impacted Files Coverage Δ
dart/lib/src/http_client/sentry_http_client.dart 76.19% <75.00%> (-13.81%) ⬇️
dart/lib/src/http_client/breadcrumb_client.dart 88.23% <88.23%> (ø)
...art/lib/src/http_client/failed_request_client.dart 94.00% <94.00%> (ø)
dart/lib/src/protocol/breadcrumb.dart 100.00% <100.00%> (ø)
dart/lib/src/protocol/max_request_body_size.dart 100.00% <100.00%> (ø)
dart/lib/src/protocol/sentry_request.dart 98.03% <0.00%> (+1.96%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6873600...5d382cf. Read the comment docs.

@ueman
Copy link
Collaborator Author

ueman commented May 25, 2021

@bruno-garcia
What do you think of splitting each HTTP client related functionality in its own client?
So recording breadcrumbs goes into the BreadcrumbClient, capturing "bad" requests (requests which throw or have a 400/500 status code for example) goes into the FailedRequestClient.
Additionally there's the SentryHttpClient which then uses both internally and it's the user facing class.

In the future there would then be a third client for the distributed tracing thingy.

@marandaneto
Copy link
Contributor

@bruno-garcia
What do you think of splitting each HTTP client related functionality in its own client?
So recording breadcrumbs goes into the BreadcrumbClient, capturing "bad" requests (requests which throw or have a 400/500 status code for example) goes into the FailedRequestClient.
Additionally there's the SentryHttpClient which then uses both internally and it's the user facing class.

In the future there would then be a third client for the distributed tracing thingy.

@bruno-garcia opinions?

@ueman ueman marked this pull request as ready for review May 31, 2021 15:53
@bruno-garcia
Copy link
Member

Sorry I'll take a look in a bit

@bruno-garcia
Copy link
Member

The decorator approach LGTM as its indeed easier to test and compose features as needed.

A couple of things to keep in mind is the usability though, the user should have a simple way into the API without having to worry about the decoration composition. This will also to allow us to add new decorators later without affecting the user.

So if we can keep: SentryHttpClient() that bundles all decorators by default, it's a great approach.
The order also is important, for example add the breadcrumb after capturing the event (so the event doesn't include double crumbs, the artificial one created by Sentry plus the one from the integration).

@ueman
Copy link
Collaborator Author

ueman commented May 31, 2021

So if we can keep: SentryHttpClient() that bundles all decorators by default, it's a great approach.

That's the plan.

The order also is important, for example add the breadcrumb after capturing the event (so the event doesn't include double crumbs, the artificial one created by Sentry plus the one from the integration).

That's a good point. Just changed it accordingly.

@bruno-garcia
Copy link
Member

The integration creating events directly will open a new precedence for other SDKs. We don't do this yet from anywhere AFAIK. At least not in the Mobile team's SDKs. Including .NET and Java bases.

Would love to hear your learnings once this is live and some customer feedback came in

@ueman ueman added the 6.0.0 label Jun 6, 2021
Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marandaneto
Copy link
Contributor

@bruno-garcia would you like to do a final review before we merge and release it as beta? as this PR drives the PoC

@ueman
Copy link
Collaborator Author

ueman commented Jun 8, 2021

There's the risk of creating events too large for ingestion.

What is the largest allowed size? I'll add another test for that.

Finally, PII is another concern so docs should clearly state that there's this risk and point to the scrubbing data parts of the docs. I'm not too familiar with the automatic scrubbing we already have, worth pointing to that too since there's some level of default protection against PII getting in already.

Gonna do that, too

Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's the risk of creating events too large for ingestion.

What is the largest allowed size? I'll add another test for that.

as we are using MaxRequestBodySize, I guess we don't need to do anything more, if the user is using always its their own risk to get events dropped, see a similar issue getsentry/sentry-java#910
checking the size of the event before sending has runtime cost so that's why we don't do it.
just in case of know-how, https://develop.sentry.dev/sdk/envelopes/#size-limits
worth noting that this is for envelopes, which is gonna be into the next major as well

dart/lib/src/http_client/failed_request_client.dart Outdated Show resolved Hide resolved
dart/lib/src/http_client/sentry_http_client.dart Outdated Show resolved Hide resolved
Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

SentryHttpClient captures errored requests and set the 'request' field accordingly
4 participants