From 106ded0ea4b53420cdab201f4407467200ba0e95 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sat, 15 Aug 2020 22:37:32 +0200 Subject: [PATCH 1/2] docs: clarify auto_patch as per #108 --- docs/content/core/tracer.mdx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/content/core/tracer.mdx b/docs/content/core/tracer.mdx index ba489b0c965..17b1b540f0b 100644 --- a/docs/content/core/tracer.mdx +++ b/docs/content/core/tracer.mdx @@ -199,6 +199,11 @@ async def collect_payment(charge_id): 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. + + When reusing Tracer in Lambda Layers, or in multiple modules, do not set auto_patch=False, because import order matters. +

This can result in the first Tracer config being inherited by new instances, and their modules not being patched. +

+ ```python:title=lambda_handler.py # handler.py from aws_lambda_powertools import Tracer @@ -214,8 +219,8 @@ def handler(event, context): ```python:title=another_file.py from aws_lambda_powertools import Tracer # highlight-start -# new instance using existing configuration with auto patching overriden -tracer = Tracer(auto_patch=False) +# new instance using existing configuration +tracer = Tracer(service="payment") # highlight-end ``` From c6cf2af7347d43adf109f9b95edc8b4e600be66d Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sat, 15 Aug 2020 22:40:53 +0200 Subject: [PATCH 2/2] chore: update Tracer docs as per #108 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 655762a5611..34100fc4a1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- **Docs**: Clarify confusion on Tracer reuse and `auto_patch=False` statement + ## [1.1.1] - 2020-08-14 ### Fixed - **Logger**: Regression on `Logger` level not accepting `int` i.e. `Logger(level=logging.INFO)`