MantaService is the entry point for querying trace data from ClickHouse. It handles connections, filtering, and returns typed TraceRow and SpanRow objects.
Creating a service
MantaService reads connection details from environment variables. You can also pass them explicitly:
Loading traces
Lightweight ID queries
If you only need trace IDs (e.g. for orchestration), useget_trace_ids():
Entity counts
Count entities at each level without loading full rows:Datapoint and step queries
Query distinct datapoints or steps for a run:Loading spans
Load spans grouped by trace ID:Span filters
The underlyingSpanFilter supports additional filtering:
| Filter | What it does |
|---|---|
span_kinds | Filter by kind: "message", "tool", "grader", "llm", "system" |
roles | Filter messages by role: "user", "assistant", "system", "tool" |
tool_names | Filter tool spans by name |
requestor | Filter tools by requestor: "agent", "user", "system" |
grader_names | Filter grader spans by grader name |
errors_only | Only return spans with errors |
Configuration
Environment variables
| Variable | Default | Description |
|---|---|---|
CLICKHOUSE_URL | http://localhost:8123 | ClickHouse HTTP endpoint |
CLICKHOUSE_USER | default | ClickHouse user |
CLICKHOUSE_PASSWORD | — | ClickHouse password |
CLICKHOUSE_DATABASE | default | ClickHouse database |
CLICKHOUSE_TRACES_TABLE | traces | Traces table name |
CLICKHOUSE_SPANS_TABLE | spans | Spans table name |