forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextensions.py
34 lines (25 loc) · 962 Bytes
/
extensions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def aiohttp_trace_config():
"""aiohttp extension for X-Ray (aws_xray_trace_config)
It expects you to have aiohttp as a dependency.
Example
-------
```python
import asyncio
import aiohttp
from aws_lambda_powertools import Tracer
from aws_lambda_powertools.tracing import aiohttp_trace_config
tracer = Tracer()
async def aiohttp_task():
async with aiohttp.ClientSession(trace_configs=[aiohttp_trace_config()]) as session:
async with session.get("https://httpbin.org/json") as resp:
resp = await resp.json()
return resp
```
Returns
-------
TraceConfig
aiohttp trace config
"""
from aws_xray_sdk.ext.aiohttp.client import aws_xray_trace_config # pragma: no cover
aws_xray_trace_config.__doc__ = "aiohttp extension for X-Ray (aws_xray_trace_config)" # pragma: no cover
return aws_xray_trace_config() # pragma: no cover