-
Notifications
You must be signed in to change notification settings - Fork 418
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
fix(sanic): support version 21.x (#2240) #2379
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.
From the changes it's not immediately clear to me what the breaking change in sanic was, as well as our fix itself. Could you add some more details on the problem/solution to the PR description? 😄
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.
👍 great stuff! Just a few suggestions about the tests 🙂
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.
👍 👍 great stuff @nizox!
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 😎
Tests are broken because |
A fix for pytest-sanic was pushed to yunstanford/pytest-sanic#52. |
0b0d273
Description
The latest major sanic release (21.x) introduced support for streaming responses and our instrumentation broke due to a change of method's signature (reported by #2240). This PR updates our instrumentation to support both the latest version and older versions.
Sanic 20.12 and older versions have
Sanic.handle_request(request, write_callback, stream_callback)
while Sanic 21 and newer versions haveSanic.handle_request(request)
. In both cases, a request starts when this method is called and terminates when the method returns. This PR changes the request span finish when thehandle_request
method returns instead of when eitherwrite_callback
orstream_callback
is called.A
Pin
is also attached to therequest.ctx
object to pass the tracer to newly instrumented methods:Request.respond
replacingwrite_callback
&stream_callback
in Sanic 21.Sanic._run_request_middleware
becauserequest.match_info
is not filled anymore beforeSanic.handle_request
is called in Sanic 21.Checklist