You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When wrapt runs, the wrapped service is a coroutine which needs to be awaited.
Until its awaited, the injecting of headers wont run.
I created a copy of record_subsegment called record_subsegment_async which is also a coroutine and it runs return_value = await wrapped(*args, **kwargs) which during that the headers are injected and then the result is returned. After that everything else works.
I tried awaiting the wrapped function inside of _xray_traced_aiobotocore but when the headers are injected the subsegment hasn't begun as thats done inside of record_subsegment.
What would you reckon is the best way for solving this, I was thinking of subclassing xray_recorder but if there is a simpler way I'm up for that. Then another PR will come your way 😄.
The text was updated successfully, but these errors were encountered:
Feel free to add new interface for the recorder as you see fit. Right now the recorder has https://github.com/aws/aws-xray-sdk-python/blob/master/aws_xray_sdk/core/recorder.py#L287capture function so that any normal function can be annotated to be recorded. Once you add a record_subsegment_async helper a new function capture_async can utilize this helper so that all async functions can be easily recorded.
You probably have to do some work around compat.py so that the new change doesn't break python2.7. You cannot do import asyncio on top of recorder.py.
You cannot do import asyncio on top of recorder.py
Yeah I was thinking about that, in compat.py, what about a decorator that does the same as asyncio.coroutine but when asyncio isn't available then just be a passthrough decorator
Back again with more async stuff 😄
I've been using the aiobotocore library which essentially wraps botocore and uses aiohttp to perform async http requests.
I was looking into patching parts of it so the SDK creates subsegments when queries to AWS are made.
I've gotten it to work but its a bit messy.
The following is based off the botocore patcher. (The injecting headers bit is exactly the same bar a different class needs patching)
When wrapt runs, the wrapped service is a coroutine which needs to be awaited.
Until its awaited, the injecting of headers wont run.
I created a copy of
record_subsegment
calledrecord_subsegment_async
which is also a coroutine and it runsreturn_value = await wrapped(*args, **kwargs)
which during that the headers are injected and then the result is returned. After that everything else works.I tried awaiting the wrapped function inside of
_xray_traced_aiobotocore
but when the headers are injected the subsegment hasn't begun as thats done inside ofrecord_subsegment
.What would you reckon is the best way for solving this, I was thinking of subclassing xray_recorder but if there is a simpler way I'm up for that. Then another PR will come your way 😄.
The text was updated successfully, but these errors were encountered: