Tracer
provide.foundation.tracer
¶
TODO: Add module docstring.
Classes¶
Span
¶
Enhanced span implementation with optional OpenTelemetry integration.
Maintains simple API while providing distributed tracing when OpenTelemetry is available.
Functions¶
__attrs_post_init__
¶
Initialize span after creation.
Source code in provide/foundation/tracer/spans.py
__enter__
¶
Context manager entry.
Source code in provide/foundation/tracer/spans.py
__exit__
¶
__exit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: Any,
) -> None
Context manager exit.
Source code in provide/foundation/tracer/spans.py
duration_ms
¶
Get the duration of the span in milliseconds.
Source code in provide/foundation/tracer/spans.py
finish
¶
Finish the span and record end time.
Source code in provide/foundation/tracer/spans.py
set_error
¶
Mark the span as having an error.
Source code in provide/foundation/tracer/spans.py
set_tag
¶
Set a tag on the span.
Source code in provide/foundation/tracer/spans.py
to_dict
¶
Convert span to dictionary representation.
Source code in provide/foundation/tracer/spans.py
Functions¶
get_current_span
¶
get_current_trace_id
¶
get_trace_context
¶
Get the current trace context information.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with trace context information |
Source code in provide/foundation/tracer/context.py
set_current_span
¶
with_span
¶
Create a new span context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the span |
required |
Returns:
| Type | Description |
|---|---|
SpanContext
|
SpanContext that can be used as a context manager |