File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
Monitoring-Debugging/Tracing-with-X-Ray Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ aws dynamodb create-table --table-name Flask \
2020## Configure Zappa
2121
2222``` sh
23+ cd example
2324pipenv --python 3.7
2425pipenv shell
2526pipenv install aws-xray-sdk flask zappa requests
Original file line number Diff line number Diff line change 1- import json
21import logging
32import uuid
43
54import boto3
65import requests
76from 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
109from 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
1514app = Flask (__name__ )
1615logging .basicConfig ()
2928
3029table_param = ssm .get_parameter (Name = '/dev/example/table_name' )
3130table_name = table_param ['Parameter' ]['Value' ]
32-
33- logger .info ('Table name:' + table_name )
34-
3531table = 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
You can’t perform that action at this time.
0 commit comments