Decorators
decorators.Span
Span utilities for decorators for automatic logging and instrumentation of functions and methods.
_SpanStack Objects
Stack of spans.
push
Push a span onto the stack.
pop
Pop a span from the stack.
current
Get the current span from the stack.
current_span
Get the current span from the stack.
span
Decorator for creating a span within a trace.
This decorator should be used within a function that is already decorated with @trace. It creates a new span and injects a tracer object into the decorated function.
Arguments:
Name | Type | Description |
---|---|---|
logger | Logger | The Logger instance to use for logging. |
id | Optional[str] or Optional[Callable], optional | The ID for the span. If callable, it will be called to generate the ID. Defaults to None. |
trace_id | Optional[str] or Optional[Callable], optional | The trace ID to associate with this span. If callable, it will be called to generate the trace ID. Defaults to current_trace. |
name | Optional[str], optional | The name of the span. Defaults to None. |
tags | Optional[dict], optional | Additional tags to associate with the span. Defaults to None. |
Returns:
Name | Description |
---|---|
Callable | A decorator function that wraps the original function with span functionality. |
Raises:
ValueError
- If the decorator is used outside of a @trace decorated function.