Skip to content

Commit 32549c8

Browse files
authored
Merge pull request #109 from heitorlessa/docs/tracer-reuse
docs: clarify Tracer auto_patch as per #108
2 parents 24a3bdf + c6cf2af commit 32549c8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- **Docs**: Clarify confusion on Tracer reuse and `auto_patch=False` statement
11+
912
## [1.1.1] - 2020-08-14
1013
### Fixed
1114
- **Logger**: Regression on `Logger` level not accepting `int` i.e. `Logger(level=logging.INFO)`

Diff for: docs/content/core/tracer.mdx

+7-2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ async def collect_payment(charge_id):
199199

200200
Tracer keeps a copy of its configuration after the first initialization. This is useful for scenarios where you want to use Tracer in more than one location across your code base.
201201

202+
<Note type="warning">
203+
When reusing Tracer in Lambda Layers, or in multiple modules, <strong>do not set <code>auto_patch=False</code></strong>, because import order matters.
204+
<br/><br/>This can result in the first Tracer config being inherited by new instances, and their modules not being patched.
205+
</Note><br/>
206+
202207
```python:title=lambda_handler.py
203208
# handler.py
204209
from aws_lambda_powertools import Tracer
@@ -214,8 +219,8 @@ def handler(event, context):
214219
```python:title=another_file.py
215220
from aws_lambda_powertools import Tracer
216221
# highlight-start
217-
# new instance using existing configuration with auto patching overriden
218-
tracer = Tracer(auto_patch=False)
222+
# new instance using existing configuration
223+
tracer = Tracer(service="payment")
219224
# highlight-end
220225
```
221226

0 commit comments

Comments
 (0)