Skip to content

Conversation

@sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Jan 29, 2025

  • add logic to maybe_create_breadcrumbs_from_span to set the level of the breadcrumb to warning for the client error range (4xx) and to error for server errors (5xx)
  • add functionality to the simple HTTP server that we use in some tests to respond with a specific error code
    • we were (and are) still "using" responses in multiple places, but they're not actually active (the activate decorator is missing) and we're making actual requests outside -- we should clean this up
    • we also can't use responses for stdlib/requests tests since they patch something that we patch
  • add httpx, stdlib, requests, aiohttp tests for the new behavior
    • restrict the requests tests to 3.7+ since in 3.6, the span is finished before the HTTP status is set for some reason...

Closes #4000

@codecov
Copy link

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.22%. Comparing base (8c25c73) to head (fd6cb87).
Report is 10 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4004      +/-   ##
==========================================
+ Coverage   80.16%   80.22%   +0.05%     
==========================================
  Files         139      139              
  Lines       15397    15406       +9     
  Branches     2597     2601       +4     
==========================================
+ Hits        12343    12359      +16     
+ Misses       2210     2202       -8     
- Partials      844      845       +1     
Files with missing lines Coverage Δ
sentry_sdk/tracing_utils.py 84.42% <100.00%> (+0.39%) ⬆️

... and 5 files with indirect coverage changes

@sentrivana sentrivana marked this pull request as ready for review January 31, 2025 12:10
Copy link
Contributor

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

Just a tiny nit picking question, otherwise looks good!

Comment on lines +173 to +178
if level:
scope.add_breadcrumb(
type="http", category="httplib", data=span._data, level=level
)
else:
scope.add_breadcrumb(type="http", category="httplib", data=span._data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it mess up the breadcrumb if we would add it with level=None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think but wasn't entirely sure so opted for the safe version 😬

@sentrivana sentrivana merged commit c1cf0fe into master Feb 11, 2025
151 checks passed
@sentrivana sentrivana deleted the ivana/set-breadcrumb-status-on-client-error branch February 11, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set HTTP client breadcrumbs log level based on status code

3 participants