You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core/tracer.md
+4-21
Original file line number
Diff line number
Diff line change
@@ -20,33 +20,16 @@ Tracer is an opinionated thin wrapper for [AWS X-Ray Python SDK](https://github.
20
20
21
21
Before your use this utility, your AWS Lambda function [must have permissions](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html#services-xray-permissions) to send traces to AWS X-Ray.
22
22
23
-
```yaml hl_lines="6 9" title="AWS Serverless Application Model (SAM) example"
24
-
Resources:
25
-
HelloWorldFunction:
26
-
Type: AWS::Serverless::Function
27
-
Properties:
28
-
Runtime: python3.8
29
-
Tracing: Active
30
-
Environment:
31
-
Variables:
32
-
POWERTOOLS_SERVICE_NAME: example
23
+
```yaml hl_lines="9 12" title="AWS Serverless Application Model (SAM) example"
24
+
--8<-- "examples/tracer/template.yaml"
33
25
```
34
26
35
27
### Lambda handler
36
28
37
29
You can quickly start by initializing `Tracer` and use `capture_lambda_handler` decorator for your Lambda handler.
38
30
39
-
```python hl_lines="1 3 6" title="Tracing Lambda handler with capture_lambda_handler"
40
-
from aws_lambda_powertools import Tracer
41
-
42
-
tracer = Tracer() # Sets service via env var
43
-
# OR tracer = Tracer(service="example")
44
-
45
-
@tracer.capture_lambda_handler
46
-
defhandler(event, context):
47
-
charge_id = event.get('charge_id')
48
-
payment = collect_payment(charge_id)
49
-
...
31
+
```python hl_lines="1 4 12" title="Tracing Lambda handler with capture_lambda_handler"
0 commit comments