Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format tracebacks with cause #100

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lightstep/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import warnings

from basictracer.recorder import SpanRecorder
from opentracing.logs import ERROR_KIND, STACK
from opentracing.logs import ERROR_KIND, STACK, ERROR_OBJECT

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

if STACK in log.key_values:
log.key_values[STACK] = util._format_exc_tb(log.key_values[STACK])
log.key_values[STACK] = util._format_exc_tb(
log.key_values.get(ERROR_OBJECT),
log.key_values.get(ERROR_KIND),
log.key_values[STACK]
)

return log

Expand Down
4 changes: 2 additions & 2 deletions lightstep/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def _coerce_to_unicode(val):
return '(encoding error)'


def _format_exc_tb(exc_tb):
def _format_exc_tb(exc_value, exc_type, exc_tb):
if type(exc_tb) is types.TracebackType:
return ''.join(traceback.format_tb(exc_tb))
return ''.join(traceback.format_exception(exc_value, exc_type, exc_tb))

return exc_tb

Expand Down