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