As documented, we can use patch_all
to automatically create subsegments for aws services such as s3 and sqs. My question is where should I call this method.
For example, let's assume there are 2 files which use boto3 and we want to patch. Because they are independent, we must call patch_all
in both of them. Hence, we would have:
File a.py
:
import boto3
from xray_recorder import patch_all
patch_all()
File b.py
:
import boto3
from xray_recorder import patch_all
patch_all()
Now, lets assume we have a module named c.py
which import both a.py
and b.py
:
import a
import b
In this flow, boto3
would be patched twice.
The only solution I found for it is to import boto3
only from inside a file, named for example my_boto3.py
which imports boto3
and patch it.
What is the good practice to patch boto3
? Thanks
You can simply call patch_all()
in the main function. Just follow instructions here , and it should work for all of the libraries( functions and classes ) patched within the same application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.