mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 05:32:30 +08:00
24 lines
539 B
Python
24 lines
539 B
Python
"""
|
|
tags for common error attributes
|
|
"""
|
|
|
|
import traceback
|
|
|
|
|
|
ERROR_MSG = 'error.msg' # a string representing the error message
|
|
ERROR_TYPE = 'error.type' # a string representing the type of the error
|
|
ERROR_STACK = 'error.stack' # a human readable version of the stack. beta.
|
|
|
|
# shorthand for -----^
|
|
MSG = ERROR_MSG
|
|
TYPE = ERROR_TYPE
|
|
STACK = ERROR_STACK
|
|
|
|
|
|
def get_traceback(tb=None, error=None):
|
|
t = None
|
|
if error:
|
|
t = type(error)
|
|
lines = traceback.format_exception(t, error, tb, limit=20)
|
|
return '\n'.join(lines)
|