-
Notifications
You must be signed in to change notification settings - Fork 658
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
RequestsInstrumentor: Add support for prepared requests #1040
RequestsInstrumentor: Add support for prepared requests #1040
Conversation
in addition to Session.request instrument Session.send to also create spans for prepared requests.
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.
LGTM! I think the test code can use a bit more of a refactor, but the execution looks good.
currently not traced. If you find any other way to trigger an untraced HTTP | ||
request, please report it via a GitHub issue with :code:`[requests: untraced | ||
API]` in the title. | ||
If you find any way to trigger an untraced HTTP request, please report it via a |
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.
Wondering if this comment even needs to be in the code? An uninstrumented trace feels like a self-evident issue.
def instrumented_send(self, request, **kwargs): | ||
def get_or_create_headers(): | ||
request.headers = ( | ||
request.headers if request.headers is not None else {} |
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.
this could also be request.headers or {}
, although it comes with a little less type safety.
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.
an empty request.headers
would actually change the type from CaseInsensitiveDict
to a plain dict
.
i guess in the else clause should also use a CaseInsensitiveDict
httpretty.disable() | ||
|
||
|
||
class TestRequestsIntegration(TestBase, RequestsIntegrationTestBase): |
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.
I believe you could actually incorporate this setup and teardown code into RequestsIntegrationTestBase.
abc.ABC is okay to use as a second parent class, and will still have the abstractmethod enforcing logic as if it was the first class passed.
Then you can just subclass everything from TestRequestsBase as before.
Hm.., |
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.
LGTM, the failing test is related to a flaky test captured in #1044
Description
The
RequestsInstrumentor
was currently only instrumetingSession.request
. Sending a prepared request with a direct call toSession.send
were not tracked.This PR adds instrumentation support for prepared requests by instrumenting
Session.send
in addition toSession.request
.Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Additional unit tests for sending prepared requests were added.
Checklist: