Skip to content

Commit 335b778

Browse files
authored
Merge branch 'master' into sqlalchemy_140_fix
2 parents 33da1af + 1294dee commit 335b778

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

aws_xray_sdk/core/emitters/udp_emitter.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ def send_entity(self, entity):
3232
3333
:param entity: a trace entity to send to the X-Ray daemon
3434
"""
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())
3839

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.")
4144

4245
def set_daemon_address(self, address):
4346
"""
@@ -57,12 +60,7 @@ def port(self):
5760
return self._port
5861

5962
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))
6664

6765
def _parse_address(self, daemon_address):
6866
try:

aws_xray_sdk/core/models/entity.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,7 @@ def serialize(self):
259259
Serialize to JSON document that can be accepted by the
260260
X-Ray backend service. It uses json to perform serialization.
261261
"""
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)
266263

267264
def to_dict(self):
268265
"""

aws_xray_sdk/core/plugins/ec2_plugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def initialize():
2828

2929

3030
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+
"""
3135
token = None
3236
try:
3337
headers = {"X-aws-ec2-metadata-token-ttl-seconds": "60"}

0 commit comments

Comments
 (0)