OpenTracing¶
This module is available only if you have opentracing installed
trace_future¶
- satella.opentracing.trace_future(future, span)¶
Install a handler that will close a span upon a future completing, attaching the exception contents if the future ends with an exception.
- Parameters:
future (Union[ResponseFuture, Future]) – can be either a normal Future or a Cassandra’s ResponseFuture
span (Span) – span to close on future’s completion
trace_function¶
- satella.opentracing.trace_function(tracer, name, tags=None, tags_factory=None)¶
Return a decorator that will trace the execution of a given function using tracer.start_active_span.
Can optionally construct it’s tags from a predicate building, example:
>>> class Device: >>> device_id = 'test' >>> @trace_function(tracer, 'Processing', tags_factory=[('device_id', x[0].device_id)]) >>> def process(device: Device): >>> ...
- Parameters:
tracer – tracer to use
name (str) – Name of the trace
tags (Optional[dict]) – optional tags to use
tags_factory (Optional[Union[Dict[str, Callable], List[Tuple[str, Callable]]]]) – a list of tuple (tag name, callable that is called with *args and **kwargs passed to this function as a sole argument). Extra tags will be generated from this. Can be also a dict.
trace_exception¶
- satella.opentracing.trace_exception(span, exc_type=None, exc_val=None, exc_tb=None, max_tb_length=None)¶
Log an exception’s information to the chosen span, as logs and tags.
- Parameters:
span (Optional[Span]) – span to log into or None for a no-op
exc_type (Optional[Type[Exception]]) – exception type. If None this will be taken from sys.exc_info.
exc_val (Optional[Exception]) – exception value. If None this will be taken from sys.exc_info.
exc_tb (Optional[TracebackType]) – exception traceback. If None this will be taken from sys.exc_info.
max_tb_length (Optional[int]) – maximum traceback length. If traceback is longer than that, it will be trimmed. The default is 65536. You can set it by
satella.opentracing.set_maximum_traceback_length()
- Return type:
None
set_maximum_traceback_length¶
- satella.opentracing.set_maximum_traceback_length(length)¶
Set a new maximum traceback length
- Parameters:
length (int) – maximum traceback length, in bytes
- Return type:
None