Skip to content

Commit 95ee2e5

Browse files
committed
Update
1 parent 2c1a8bd commit 95ee2e5

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

Monitoring-Debugging/Tracing-with-X-Ray/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ aws dynamodb create-table --table-name Flask \
2020
## Configure Zappa
2121

2222
```sh
23+
cd example
2324
pipenv --python 3.7
2425
pipenv shell
2526
pipenv install aws-xray-sdk flask zappa requests

Monitoring-Debugging/Tracing-with-X-Ray/example/app.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import json
21
import logging
32
import uuid
43

54
import boto3
65
import requests
76
from flask import Flask
87

9-
from aws_xray_sdk.core import patcher, xray_recorder
8+
from aws_xray_sdk.core import patch_all, xray_recorder
109
from aws_xray_sdk.ext.flask.middleware import XRayMiddleware
1110

12-
# Patch the requests module to enable automatic instrumentation
13-
patcher.patch(('requests',))
11+
# Patch all supported modules to enable automatic instrumentation
12+
patch_all()
1413

1514
app = Flask(__name__)
1615
logging.basicConfig()
@@ -29,9 +28,6 @@
2928

3029
table_param = ssm.get_parameter(Name='/dev/example/table_name')
3130
table_name = table_param['Parameter']['Value']
32-
33-
logger.info('Table name:' + table_name)
34-
3531
table = dynamodb.Table(table_name)
3632

3733

@@ -41,12 +37,14 @@ def hello_world():
4137

4238
logger.debug(r.text)
4339

40+
xray_recorder.begin_subsegment('DynamoDB PutItem')
4441
table.put_item(
4542
Item={
4643
'key': str(uuid.uuid1()),
4744
'response': r.text
4845
}
4946
)
47+
xray_recorder.end_subsegment()
5048

5149
return 'Hello, World: %s' % r.url
5250

0 commit comments

Comments
 (0)