diff --git a/python/HISTORY.md b/python/HISTORY.md index b90bb22ec96..894e2b1fc05 100644 --- a/python/HISTORY.md +++ b/python/HISTORY.md @@ -1,5 +1,11 @@ # HISTORY +## May 14th + +**0.9.2** + +* **Tracer**: Bugfix - aiohttp lazy import so it's not a hard dependency + ## May 12th **0.9.0** diff --git a/python/README.md b/python/README.md index ab0efc45dbd..3208b668410 100644 --- a/python/README.md +++ b/python/README.md @@ -142,6 +142,8 @@ You can use `tracer.provider` attribute to access all methods provided by `xray_ **Example using aiohttp with an async context manager** +> NOTE: It expects you have `aiohttp` as a dependency. `aiohttp_trace_config` uses lazy import to create a trace_config object following `aiohttp` protocol. + ```python import asyncio import aiohttp diff --git a/python/aws_lambda_powertools/tracing/__init__.py b/python/aws_lambda_powertools/tracing/__init__.py index ece90f7d1bc..f45ac1fb73e 100644 --- a/python/aws_lambda_powertools/tracing/__init__.py +++ b/python/aws_lambda_powertools/tracing/__init__.py @@ -1,10 +1,8 @@ """Tracing utility """ -from aws_xray_sdk.ext.aiohttp.client import aws_xray_trace_config as aiohttp_trace_config -from .tracer import Tracer - -aiohttp_trace_config.__doc__ = "aiohttp extension for X-Ray (aws_xray_trace_config)" +from .extensions import aiohttp_trace_config +from .tracer import Tracer __all__ = ["Tracer", "aiohttp_trace_config"] diff --git a/python/aws_lambda_powertools/tracing/extensions.py b/python/aws_lambda_powertools/tracing/extensions.py new file mode 100644 index 00000000000..2bb0125e841 --- /dev/null +++ b/python/aws_lambda_powertools/tracing/extensions.py @@ -0,0 +1,15 @@ +def aiohttp_trace_config(): + """aiohttp extension for X-Ray (aws_xray_trace_config) + + It expects you to have aiohttp as a dependency. + + Returns + ------- + TraceConfig + aiohttp trace config + """ + from aws_xray_sdk.ext.aiohttp.client import aws_xray_trace_config + + aws_xray_trace_config.__doc__ = "aiohttp extension for X-Ray (aws_xray_trace_config)" + + return aws_xray_trace_config() diff --git a/python/pyproject.toml b/python/pyproject.toml index 95845cc9f9c..ffd44e243fb 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aws_lambda_powertools" -version = "0.9.0" +version = "0.9.2" description = "Python utilities for AWS Lambda functions including but not limited to tracing, logging and custom metric" authors = ["Amazon Web Services"] classifiers=[