Skip to content

Commit c47c227

Browse files
author
Alex Boten
committed
format tracebacks with cause
This reverts commit 84e00eb.
1 parent ad11cc2 commit c47c227

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lightstep/recorder.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import warnings
1515

1616
from basictracer.recorder import SpanRecorder
17-
from opentracing.logs import ERROR_KIND, STACK
17+
from opentracing.logs import ERROR_KIND, STACK, ERROR_OBJECT
1818

1919
from lightstep.http_converter import HttpConverter
2020
from lightstep.thrift_converter import ThriftConverter
@@ -171,7 +171,11 @@ def _normalize_log(self, log):
171171
log.key_values[ERROR_KIND] = util._format_exc_type(log.key_values[ERROR_KIND])
172172

173173
if STACK in log.key_values:
174-
log.key_values[STACK] = util._format_exc_tb(log.key_values[STACK])
174+
log.key_values[STACK] = util._format_exc_tb(
175+
log.key_values.get(ERROR_OBJECT),
176+
log.key_values.get(ERROR_KIND),
177+
log.key_values[STACK]
178+
)
175179

176180
return log
177181

lightstep/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ def _coerce_to_unicode(val):
105105
return '(encoding error)'
106106

107107

108-
def _format_exc_tb(exc_tb):
108+
def _format_exc_tb(exc_value, exc_type, exc_tb):
109109
if type(exc_tb) is types.TracebackType:
110-
return ''.join(traceback.format_tb(exc_tb))
110+
return ''.join(traceback.format_exception(exc_value, exc_type, exc_tb))
111111

112112
return exc_tb
113113

0 commit comments

Comments
 (0)