This module is available only if you have opentracing installed


satella.opentracing.trace_future(future: Union[satella.cassandra.common.ResponseFuture, concurrent.futures._base.Future], span: satella.opentracing.trace.Span)

Install a handler that will close a span upon a future completing, attaching the exception contents if the future ends with an exception.

  • future – can be either a normal Future or a Cassandra’s ResponseFuture
  • span – span to close on future’s completion


satella.opentracing.trace_function(tracer, name: str, tags: Optional[dict] = None, tags_factory: Union[Dict[str, Callable], List[Tuple[str, Callable]], None] = 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):
>>>     ...
  • tracer – tracer to use
  • name – Name of the trace
  • tags – optional tags to use
  • tags_factory – 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.


satella.opentracing.trace_exception(span: Optional[satella.opentracing.trace.Span], exc_type: Optional[Type[Exception]] = None, exc_val: Optional[Exception] = None, exc_tb: Optional[traceback] = None, max_tb_length: Optional[int] = None) → None

Log an exception’s information to the chosen span, as logs and tags.

  • span – span to log into or None for a no-op
  • exc_type – exception type. If None this will be taken from sys.exc_info.
  • exc_val – exception value. If None this will be taken from sys.exc_info.
  • exc_tb – exception traceback. If None this will be taken from sys.exc_info.
  • max_tb_length – 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()


satella.opentracing.set_maximum_traceback_length(length: int) → None

Set a new maximum traceback length

Parameters:length – maximum traceback length, in bytes