windlass.providers.observability.console¶
console
¶
Console and in-memory tracers — dependency-free observability.
:class:ConsoleTracer prints an indented trace tree as your pipeline runs. It
is the fastest way to answer "what is this thing actually doing?" without
signing up for anything::
Windlass.rag().observe("console")
:class:MemoryTracer keeps spans in a list, which is what you want in tests:
assert that retrieval ran once, that the guardrail fired, that no LLM call was
made on the cached path.
Example
tracer = MemoryTracer() with tracer.span("retrieve", kind="retriever") as span: ... span.set_output(["a", "b"]) [s.name for s in tracer.spans]['retrieve']
ConsoleTracer
¶
ConsoleTracer(
*,
stream: TextIO | None = None,
show_io: bool = False,
show_usage: bool = True,
max_value_length: int = 160,
colour: bool | None = None,
enabled: bool = True,
**config: Any
)
Bases: Tracer
Prints spans as an indented tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream
|
TextIO | None
|
Where to write. Defaults to |
None
|
show_io
|
bool
|
Print each span's inputs and outputs. |
False
|
show_usage
|
bool
|
Print token usage for model spans. |
True
|
max_value_length
|
int
|
Truncate printed values at this length. |
160
|
colour
|
bool | None
|
Emit ANSI colour. Auto-detected from the stream when |
None
|
enabled
|
bool
|
Master switch. |
True
|
**config
|
Any
|
Forwarded to :class: |
{}
|
Example
import io buffer = io.StringIO() tracer = ConsoleTracer(stream=buffer, colour=False) with tracer.span("work", kind="tool"): ... pass "work" in buffer.getvalue() True
Source code in src\windlass\providers\observability\console.py
start_span
¶
Print the span's opening line and indent.
Source code in src\windlass\providers\observability\console.py
end_span
¶
Print the span's result line and dedent.
Source code in src\windlass\providers\observability\console.py
MemoryTracer
¶
Bases: Tracer
Records every span in memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_spans
|
int
|
Ceiling on retained spans; the oldest are dropped. Prevents a long-running process from growing without bound. |
10000
|
enabled
|
bool
|
Master switch. |
True
|
**config
|
Any
|
Forwarded to :class: |
{}
|
Attributes:
| Name | Type | Description |
|---|---|---|
spans |
list[Span]
|
Finished spans in completion order. |
Example
tracer = MemoryTracer() with tracer.span("llm-call", kind="llm"): ... pass tracer.count("llm") 1
Source code in src\windlass\providers\observability\console.py
start_span
¶
end_span
¶
Record the finished span.
count
¶
Return how many spans were recorded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str | None
|
Restrict the count to one span kind. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The number of matching spans. |
Source code in src\windlass\providers\observability\console.py
by_kind
¶
errors
¶
total_usage
¶
Return summed token usage across every recorded span.
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
A dict with |
dict[str, int]
|
|