Skip to content

Commit 3faf915

Browse files
committed
docs: create Patching modules section; cleanup response wording
Signed-off-by: heitorlessa <[email protected]>
1 parent 64f7aa8 commit 3faf915

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

docs/content/core/tracer.mdx

+20-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ You can trace your Lambda function handler via `capture_lambda_handler`.
5858
When using this decorator, Tracer performs these additional tasks to ease operations:
5959

6060
* Creates a `ColdStart` annotation to easily filter traces that have had an initialization overhead
61-
* Adds any response, or full exceptions generated by the handler as metadata
61+
* Captures any response, or full exceptions generated by the handler, and include as tracing metadata
6262

6363
```python:title=lambda_handler.py
6464
from aws_lambda_powertools import Tracer
@@ -70,6 +70,8 @@ def handler(event, context):
7070
payment = collect_payment(charge_id)
7171
...
7272

73+
# Disables Tracer from capturing response and adding as metadata
74+
# Useful when dealing with sensitive data
7375
@tracer.capture_lambda_handler(capture_response=False) # highlight-line
7476
def handler(event, context):
7577
return "sensitive_information"
@@ -170,7 +172,23 @@ def handler(evt, ctx): # highlight-line
170172
another_result = list(collect_payment_gen())
171173
```
172174

173-
## Tracing aiohttp requests
175+
## Patching modules
176+
177+
Tracer automatically patches all [supported libraries by X-Ray](https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-python-patching.html) during initialization, by default. Underneath, AWS X-Ray SDK checks whether a supported library has been imported before patching.
178+
179+
If you're looking to shave a few microseconds, or milliseconds depending on your function memory configuration, you can patch specific modules using `patch_modules` param:
180+
181+
```python:title=app.py
182+
import boto3
183+
import requests
184+
185+
from aws_lambda_powertools import Tracer
186+
187+
modules_to_be_patched = ["boto3", "requests"]
188+
tracer = Tracer(patch_modules=modules_to_be_patched) # highlight-line
189+
```
190+
191+
### Tracing aiohttp requests
174192

175193
<Note type="info">
176194
This snippet assumes you have <strong>aiohttp</strong> as a dependency

0 commit comments

Comments
 (0)