Skip to content

Commit 8b5609e

Browse files
authored
remove print_trace option in TransportException (#1809)
* remove print_trace option in TransportException The logging of the stack trace can be confusing, and does not add anything interesting that would help while debugging, as the stacktrace is always the same. * update changelog
1 parent 25eb517 commit 8b5609e

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

CHANGELOG.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ run agents both with and without this fix (for same or different languages), the
5858
same S3-buckets can appear twice in the service map (with and without
5959
s3-prefix).
6060
* Fix instrumentation to not bubble up exceptions during instrumentation {pull}1791[#1791]
61+
* Fix HTTP transport to not print useless and confusing stack trace {pull}1809[#1809]
6162
6263
[[release-notes-6.x]]
6364
=== Python Agent version 6.x

elasticapm/transport/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def handle_transport_fail(self, exception=None, **kwargs):
334334
Failure handler called by the transport on send failure
335335
"""
336336
message = str(exception)
337-
logger.error("Failed to submit message: %r", message, exc_info=getattr(exception, "print_trace", True))
337+
logger.error("Failed to submit message: %r", message, exc_info=False)
338338
self.state.set_fail()
339339

340340
def handle_fork(self) -> None:

elasticapm/transport/exceptions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434

3535
class TransportException(Exception):
36-
def __init__(self, message, data=None, print_trace=True):
36+
def __init__(self, message, data=None):
3737
super(TransportException, self).__init__(message)
3838
self.data = data
39-
self.print_trace = print_trace

elasticapm/transport/http.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,22 @@ def send(self, data, forced_flush=False, custom_url=None, custom_headers=None):
9595
)
9696
logger.debug("Sent request, url=%s size=%.2fkb status=%s", url, len(data) / 1024.0, response.status)
9797
except Exception as e:
98-
print_trace = True
9998
if isinstance(e, MaxRetryError) and isinstance(e.reason, TimeoutError):
10099
message = "Connection to APM Server timed out " "(url: %s, timeout: %s seconds)" % (
101100
self._url,
102101
self._timeout,
103102
)
104-
print_trace = False
105103
else:
106104
message = "Unable to reach APM Server: %s (url: %s)" % (e, self._url)
107-
raise TransportException(message, data, print_trace=print_trace)
105+
raise TransportException(message, data)
108106
body = response.read()
109107
if response.status >= 400:
110108
if response.status == 429: # rate-limited
111109
message = "Temporarily rate limited: "
112-
print_trace = False
113110
else:
114111
message = "HTTP %s: " % response.status
115-
print_trace = True
116112
message += body.decode("utf8", errors="replace")[:10000]
117-
raise TransportException(message, data, print_trace=print_trace)
113+
raise TransportException(message, data)
118114
return response.headers.get("Location")
119115
finally:
120116
if response:

0 commit comments

Comments
 (0)