GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(boto3): Trace the complete botocore client-call lifecycle by pabloDeputter · Pull Request #7538 · getsentry/sentry-python Conversation
|
Codecov Results 📊✅ 132487 passed | ⏭️ 7220 skipped | Total: 139707 | Pass Rate: 94.83% | Execution Time: 454m 48s 📊 Comparison with Base Branch
➖ Removed Tests (60)View removed tests
All tests are passing successfully. ✅ Patch coverage is 95.51%. Project has 2551 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@ ## master #PR +/-## ========================================== + Coverage 90.31% 90.35% +0.04% ========================================== Files 195 199 +4 Lines 26261 26422 +161 Branches 9798 9834 +36 ========================================== + Hits 23714 23871 +157 - Misses 2547 2551 +4 - Partials 1485 1491 +6 Generated by Codecov Action |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
53a8717 to
4efce4b
Compare
4efce4b to
05501d2
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Minor things but overall looking good. Will take a look at tests on my 2nd pass
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| from sentry_sdk.integrations.boto3 import Boto3Integration | ||
| @contextmanager | ||
| def _activate_client_span(span: "StreamedSpan") -> "Iterator[StreamedSpan]": | ||
| """Temporarily activate an inactive boto span without ending it.""" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Worth adding context on why we're doing this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| # use unknown if `service_id_hyphenized` so span name can still be created. | ||
| # e.g. "aws.unkown.GetObject" | ||
| service_name = ctx.service_id_hyphenized or "unknown" | ||
| span_name = "aws.%s.%s" % (service_name, ctx.operation_name) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
f-strings are generally the preferred way to construct strings like this in modern python these days
| span_name = "aws.%s.%s" % (service_name, ctx.operation_name) | |
| span_name = f"aws.{service_name}.{ctx.operation_name}" |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
yupp, I took over the old code, but I usually also use f-strings.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| SPANDATA.SENTRY_ORIGIN: span_origin, | ||
| } | ||
| if ctx.service_id: | ||
| attributes[SPANDATA.RPC_METHOD] = "%s/%s" % ( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Same f-string comment here
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| "sentry.op": OP.HTTP_CLIENT_STREAM, | ||
| "sentry.origin": Boto3Integration.origin, | ||
| SPANDATA.SENTRY_OP: OP.HTTP_CLIENT_STREAM, | ||
| SPANDATA.SENTRY_ORIGIN: Boto3Integration.origin, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nice change👌🏻
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if isinstance(span, StreamedSpan) and ( | ||
| span.get_attributes().get(SPANDATA.SENTRY_ORIGIN) != Boto3Integration.origin | ||
| ): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Because of the length of this conditional, I think it'd be a bit cleaner to pull this into a variable
| if isinstance(span, StreamedSpan) and ( | |
| span.get_attributes().get(SPANDATA.SENTRY_ORIGIN) != Boto3Integration.origin | |
| ): | |
| is_span_origin_from_boto = span.get_attributes().get(SPANDATA.SENTRY_ORIGIN) == Boto3Integration.origin | |
| if isinstance(span, StreamedSpan) and is_span_origin_from_boto: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I agree, but then you get the issue that the legacy span doesn't support get_attributes(); I fixed it like this:
# an ignored streamed span is not activated; avoid enriching its parent. if isinstance(span, StreamedSpan): if not (span.get_attributes().get(SPANDATA.SENTRY_ORIGIN) == ORIGIN): return
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| }, | ||
| # boto3 integration owns span's lifecycle; keep child inactive so it | ||
| # can't restore boto3 span later on. | ||
| active=not is_inactive_boto3_span, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Apologies for this slight nitpick, but can we add a space after the = and before the not?
The "not" almost blends in with the =, especially because the syntax highlighting of Github and IDEs use the same colour for the two. 😭
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I agree, but the linter doesn't really like that 🤣 I fixed it by adding fmt: off and fmt: on for that specific block; I haven't seen it being used anywhere else in the codebase, so not sure whether this is correct.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
05501d2 to
421da22
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
c3e8f5b to
66d4665
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
fe64ae9 to
add0913
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Stale Bugbot comment from a previous run.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
f649477 to
4423557
Compare
4423557 to
c622458
Compare
c622458 to
3e4fcfd
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Some minor things but otherwise LGTM 🚀 Approving to not block
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Track a single API call, including retries, serialization, and endpoint | ||
| resolution. For streaming responses, keep the span open until the | ||
| response body is consumed or closed. | ||
| https://github.com/boto/botocore/blob/develop/botocore/client.py |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think something got borked in a merge conflict resolution - I can see you made the change in this commit but for some reason it's still using the old path 🤔
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
yeah I vaguely remember fixing it; so don't know why it was removed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| origin=ORIGIN, | ||
| return None | ||
|
|
||
| # use unknown if `service_id_hyphenized` so span name can still be created. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This looks like a partially incomplete comment - is it supposed to instead be the following?
| # use unknown if `service_id_hyphenized` so span name can still be created. | |
| # use unknown if `service_id_hyphenized` is not set so span name can still be created. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return None | ||
|
|
||
| # use unknown if `service_id_hyphenized` so span name can still be created. | ||
| # e.g. "aws.unkown.GetObject" |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| # e.g. "aws.unkown.GetObject" | |
| # e.g. "aws.unknown.GetObject" |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
5b894cb to
440b19a
Compare
440b19a to
04d968a
Compare
04d968a to
33807b8
Compare
| assert len(http_spans) == 1 | ||
| assert len(stream_spans) == 1 | ||
| client_span = client_spans[0] | ||
| http_span = http_spans[0] |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
AWS connection putrequest wrapper bypasses the stdlib span wrapper
_install_httplib wraps AWSHTTPConnection.putrequest before replacing HTTPConnection.putrequest, so the AWS wrapper captures the unpatched inherited method. The AWS class then shadows the patched base method, and boto HTTP requests skip stdlib HTTP span setup, including setting _sentrysdk_real_url (the boto client span is still created). Install the base wrapper before wrapping the AWS classes.
_install_httplib saves the original HTTPConnection.putrequest and defines the sentry wrapper that creates the HTTP span and sets _sentrysdk_real_url._patch_aws_connection() before assigning that wrapper to HTTPConnection.putrequest._patch_aws_connection() wraps AWSHTTPConnection.putrequest at that point, capturing the unpatched method; the AWS class method then shadows the later base-class patch, so requests through it skip sentry putrequest.Identified by Warden · code-review, find-bugs · GUM-LY4
Sorry, something went wrong.
There was an error while loading. Please reload this page.
33807b8 to
2647da1
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2647da1. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
ref(boto3): Own one logical botocore client-call lifecycle
There was an error while loading. Please reload this page.