Skip to main content

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="agentforge_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 agentforge_records WHERE kind = 'llm' GROUP BY agent_name;

SELECT metadata.team, sum(cost_usd)
FROM agentforge_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 agentforge_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forgesight_clickhouse-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forgesight_clickhouse-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file forgesight_clickhouse-0.1.0.tar.gz.

File metadata

  • Download URL: forgesight_clickhouse-0.1.0.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

Hashes for forgesight_clickhouse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f455ad3d80e030b2aa70befbe64ffabae2c673db11f79ba9f9c74ad90d9dbb9d
MD5 b19e4ad30299cdbdfa1b9d147645164d
BLAKE2b-256 d8470b90503d59e87f5dee90d531229438b0f9e1bf6f7ee93c0b4ff2e58c7748

See more details on using hashes here.

File details

Details for the file forgesight_clickhouse-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for forgesight_clickhouse-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d8cf45743f60b6989f7e38d01e2e1a454bdf556455f19d3201d4d7a54f55847
MD5 a27a4db02db7f67b6662b3fc3a18494d
BLAKE2b-256 b23dcb5071b52a13cdfcb33a6e78db7df5f329d6ae7c5d7c15db63743e3062fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page