File tree Expand file tree Collapse file tree 3 files changed +14
-15
lines changed Expand file tree Collapse file tree 3 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -32,12 +32,15 @@ def send_entity(self, entity):
32
32
33
33
:param entity: a trace entity to send to the X-Ray daemon
34
34
"""
35
- message = "%s%s%s" % (PROTOCOL_HEADER ,
36
- PROTOCOL_DELIMITER ,
37
- entity .serialize ())
35
+ try :
36
+ message = "%s%s%s" % (PROTOCOL_HEADER ,
37
+ PROTOCOL_DELIMITER ,
38
+ entity .serialize ())
38
39
39
- log .debug ("sending: %s to %s:%s." % (message , self ._ip , self ._port ))
40
- self ._send_data (message )
40
+ log .debug ("sending: %s to %s:%s." % (message , self ._ip , self ._port ))
41
+ self ._send_data (message )
42
+ except Exception :
43
+ log .exception ("Failed to send entity to Daemon." )
41
44
42
45
def set_daemon_address (self , address ):
43
46
"""
@@ -57,12 +60,7 @@ def port(self):
57
60
return self ._port
58
61
59
62
def _send_data (self , data ):
60
-
61
- try :
62
- self ._socket .sendto (data .encode ('utf-8' ), (self ._ip ,
63
- self ._port ))
64
- except Exception :
65
- log .exception ('failed to send data to X-Ray daemon.' )
63
+ self ._socket .sendto (data .encode ('utf-8' ), (self ._ip , self ._port ))
66
64
67
65
def _parse_address (self , daemon_address ):
68
66
try :
Original file line number Diff line number Diff line change @@ -259,10 +259,7 @@ def serialize(self):
259
259
Serialize to JSON document that can be accepted by the
260
260
X-Ray backend service. It uses json to perform serialization.
261
261
"""
262
- try :
263
- return json .dumps (self .to_dict (), default = str )
264
- except Exception :
265
- log .exception ("Failed to serialize %s" , self .name )
262
+ return json .dumps (self .to_dict (), default = str )
266
263
267
264
def to_dict (self ):
268
265
"""
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ def initialize():
28
28
29
29
30
30
def get_token ():
31
+ """
32
+ Get the session token for IMDSv2 endpoint valid for 60 seconds
33
+ by specifying the X-aws-ec2-metadata-token-ttl-seconds header.
34
+ """
31
35
token = None
32
36
try :
33
37
headers = {"X-aws-ec2-metadata-token-ttl-seconds" : "60" }
You can’t perform that action at this time.
0 commit comments