Skip to content
Snippets Groups Projects
Commit ce27e267 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

trace_exception can take None as an argument

parent 7af085b7
No related branches found
No related tags found
No related merge requests found
# v2.16.6
* trace_exception can take None as an argument
__version__ = '2.16.6a1'
__version__ = '2.16.6a2'
......@@ -7,17 +7,20 @@ from satella.instrumentation import Traceback
from satella.opentracing.trace import Span
def trace_exception(span: Span, exc_type: tp.Optional[ExceptionClassType] = None,
def trace_exception(span: tp.Optional[Span], exc_type: tp.Optional[ExceptionClassType] = None,
exc_val: tp.Optional[Exception] = None,
exc_tb: tp.Optional[types.TracebackType] = None) -> None:
"""
Log an exception's information to the chosen span, as logs and tags.
:param span: span to log into
:param span: span to log into or None for a no-op
:param exc_type: exception type. If None this will be taken from sys.exc_info.
:param exc_val: exception value. If None this will be taken from sys.exc_info.
:param exc_tb: exception traceback. If None this will be taken from sys.exc_info.
"""
if span is None:
return
if exc_type is None:
exc_type, exc_val, exc_tb = sys.exc_info()
if exc_type is None:
......
import unittest
from satella.opentracing import trace_exception
class TestOpentracing(unittest.TestCase):
def test_trace_exception_none(self):
trace_exception(None)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment