OpenTracing¶
This module is available only if you have opentracing installed
trace_future¶
- satella.opentracing.trace_future(future: ResponseFuture | Future, span: 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 – can be either a normal Future or a Cassandra’s ResponseFuture
span – span to close on future’s completion
trace_function¶
- satella.opentracing.trace_function(tracer, name: str, tags: dict | None = None, tags_factory: 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): >>> ...
trace_exception¶
- satella.opentracing.trace_exception(span: Span | None, exc_type: Type[Exception] | None = None, exc_val: Exception | None = None, exc_tb: TracebackType | None = None, max_tb_length: int | None = None) None ¶
Log an exception’s information to the chosen span, as logs and tags.
- Parameters:
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()
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