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
Hi, thanks for your question. Can you provide a bit more detail about how you're calling Secrets Manager?
Which AsyncContext are you using? The one from xraysink, or the one from aws_xray_sdk? If it's from aws_xray_sdk, which version of that library do you have?
Can you show some code for how you use boto3. eg. Is it from a request handler, or a task, or a once-off startup-time initialisation, ...
The boto3 was used within the request handler. As a workaround, I ended up removing xraysink (and the FastAPI middleware) and wrapped the APIrouter request handler manually. For a small project this was fine, but larger projects would have been nicer with xraysink!
router=APIRouter()
@router.post(.....)
def sample_post():
xray_recorder.begin_segment('myapp-method')
....
#boto3 actions here
....
xray_recorder.endsegment() #make sure to do this on each return or exception handling statement
Thanks for your response, that code snippet helped. And I'm glad you found a way to workaround your problem.
The fundamental problem, as you suspected, is that the AsyncContext only gets propagated through async calls, which means it is not present when your non-async request handler is called (AIUI FastAPI runs these in a separate thread pool). I'm aware of this issue but the fix (see #89) appears to be a non-trivial amount of work.
Something I have done is to use the async aioboto3 library for calling the AWS API, which allows me to then write an async request handler. The only downside is that testing becomes more arduous - moto doesn't really support aioboto3, although let me know if you find something
Question/query - has anyone successfully used boto3 with xraysink? or particularly secrets manager?
Some of the symptoms I'm seeing appears that mixing the two may potentially be an issue (mixing async context in xray recorder w/ boto3 sync methods)?
My app logs shows things like this:
Could not get Secret Manager credentials, exception: [ cannot find the current segment/subsegment, please make sure you have a segment open ]
The text was updated successfully, but these errors were encountered: