-
Notifications
You must be signed in to change notification settings - Fork 515
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
Improved handling of span status #3261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, please consider suggestions before merging
@@ -386,6 +386,32 @@ class SPANDATA: | |||
""" | |||
|
|||
|
|||
class SPANSTATUS: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we make this an enum?
elif 400 <= http_status_code < 500: | ||
if http_status_code == 403: | ||
return SPANSTATUS.PERMISSION_DENIED | ||
elif http_status_code == 404: | ||
return SPANSTATUS.NOT_FOUND | ||
elif http_status_code == 429: | ||
return SPANSTATUS.RESOURCE_EXHAUSTED | ||
elif http_status_code == 413: | ||
return SPANSTATUS.FAILED_PRECONDITION | ||
elif http_status_code == 401: | ||
return SPANSTATUS.UNAUTHENTICATED | ||
elif http_status_code == 409: | ||
return SPANSTATUS.ALREADY_EXISTS | ||
else: | ||
return SPANSTATUS.INVALID_ARGUMENT | ||
|
||
elif 500 <= http_status_code < 600: | ||
if http_status_code == 504: | ||
return SPANSTATUS.DEADLINE_EXCEEDED | ||
elif http_status_code == 501: | ||
return SPANSTATUS.UNIMPLEMENTED | ||
elif http_status_code == 503: | ||
return SPANSTATUS.UNAVAILABLE | ||
else: | ||
return SPANSTATUS.INTERNAL_ERROR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to sort the if statements in increasing order by status code. Although, perhaps this would better belong in a separate PR
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3261 +/- ##
==========================================
+ Coverage 79.36% 79.39% +0.03%
==========================================
Files 132 132
Lines 14227 14247 +20
Branches 2987 2988 +1
==========================================
+ Hits 11291 11312 +21
Misses 2092 2092
+ Partials 844 843 -1
|
Thanks for the quick review @szokeasaurusrex |
Having the Sentry span statuses in a class and introducing
get_span_status_from_http_code()
. This will be used in our new OpenTelementry instrumentation.General Notes
Thank you for contributing to
sentry-python
!Please add tests to validate your changes, and lint your code using
tox -e linters
.Running the test suite on your PR might require maintainer approval. Some tests (AWS Lambda) additionally require a maintainer to add a special label to run and will fail if the label is not present.
For maintainers
Sensitive test suites require maintainer review to ensure that tests do not compromise our secrets. This review must be repeated after any code revisions.
Before running sensitive test suites, please carefully check the PR. Then, apply the
Trigger: tests using secrets
label. The label will be removed after any code changes to enforce our policy requiring maintainers to review all code revisions before running sensitive tests.