ForgeSight ClickHouse exporter — columnar batch insert of immutable records into a denormalized MergeTree.
Project description
forgesight-clickhouse
The ClickHouse exporter for ForgeSight. Writes each ForgeSight record as one row in a denormalized single-table MergeTree, batched columnar — so a platform team can query its agent telemetry in SQL: spend by team, p99 LLM latency by model, tokens per workflow over 90 days.
pip install forgesight-clickhouse
import forgesight
from forgesight_clickhouse import ClickHouseExporter
forgesight.configure(exporters=[
ClickHouseExporter(
dsn="clickhouse://user:pass@ch-host:8443/agents?secure=true",
table="forgesight_records",
create_table=True, # dev convenience; production runs the shipped migration
),
])
Or by name: exporters: [{name: clickhouse, config: {dsn: "${FORGESIGHT_CLICKHOUSE_DSN}"}}].
Why a columnar exporter
A Record is written once and never updated (OTel's immutable span model), so trace-level business metadata is denormalized onto every row — no join table, so analytical queries never pay a join:
SELECT agent_name, quantile(0.99)(duration_ms)
FROM forgesight_records WHERE kind = 'llm' GROUP BY agent_name;
SELECT metadata.team, sum(cost_usd)
FROM forgesight_records
WHERE kind = 'llm' AND start_time >= now() - INTERVAL 30 DAY
GROUP BY metadata.team;
Inserts are batched by the SDK's export pipeline (ClickHouse hates row-at-a-time): one
columnar INSERT per batch, on the export worker, fault-isolated. A ClickHouse outage makes
export() return FAILURE (counted, never raised — P6); it never blocks the agent.
Schema & migrations
The DDL ships in the package (migrations/0001_init.sql). create_table=True runs
CREATE TABLE IF NOT EXISTS on first export for dev; production applies the migration
out-of-band. New domain fields arrive as new nullable columns via numbered migrations —
old queries keep working.
Configuration
| Key | Env | Default |
|---|---|---|
dsn |
FORGESIGHT_CLICKHOUSE_DSN |
— (required) |
table |
FORGESIGHT_CLICKHOUSE_TABLE |
forgesight_records |
batch_size |
FORGESIGHT_CLICKHOUSE_BATCH_SIZE |
512 (clamped to the pipeline max) |
async_insert |
FORGESIGHT_CLICKHOUSE_ASYNC_INSERT |
true |
wait_for_async_insert |
FORGESIGHT_CLICKHOUSE_WAIT_ASYNC |
false |
create_table |
FORGESIGHT_CLICKHOUSE_CREATE_TABLE |
false |
Constructor kwargs win over env (FR-12). Prompt/response content is never stored in
the base table; it is gated SDK-wide by capture_content (off by default, P7).
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file forgesight_clickhouse-0.1.1.tar.gz.
File metadata
- Download URL: forgesight_clickhouse-0.1.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cafc939d8503a82b10ec85887f37e78ff1cd0c13d958f7cd67a0715fbbad5f6a
|
|
| MD5 |
1a7f502df9a2ca80ae872b2baa0e3294
|
|
| BLAKE2b-256 |
e7e7cb795984f3af8760e1f71b5687884543e32006c974cc233643e2781792fe
|
File details
Details for the file forgesight_clickhouse-0.1.1-py3-none-any.whl.
File metadata
- Download URL: forgesight_clickhouse-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58c9d9f5bdb3e0078f361a534bbe78d1d1218517b833c1ade888bdfc53bd2151
|
|
| MD5 |
582e9c4bbd2c107687b0d5e24430820c
|
|
| BLAKE2b-256 |
4b3136a8193c0b1abc2918653953634bd5079750889e38eb1e477f5a89e8c9cb
|