Skip to content

Conversation

@koxudaxi
Copy link
Collaborator

@koxudaxi koxudaxi commented Jan 6, 2026

Add ClickHouse for Analytics

TL;DR

Add ClickHouse database for analytics with tables for spans and annotations.

What changed?

  • Added ClickHouse service to Docker Compose configuration
  • Created SQL schema for spans_analytics table with optimized structure for OLAP queries
  • Created SQL schema for annotations_analytics table to track span annotations
  • Added npm scripts for managing the ClickHouse service

The spans table includes:

  • Core span identifiers and relationships
  • Multi-tenant support columns
  • Timing information
  • LLM-specific fields (tokens, costs, etc.)
  • Compressed attribute storage
  • Optimized indexes for common query patterns

How to test?

  1. Start the ClickHouse service:

    npm run clickhouse:start
    
  2. Connect to ClickHouse using the web interface at http://localhost:8123 or CLI client

    • Username: default
    • Password: clickhouse
    • Database: mirascope_analytics
  3. Verify tables were created:

    SHOW TABLES;
    DESCRIBE TABLE spans_analytics;
    DESCRIBE TABLE annotations_analytics;
  4. Stop the service when done:

    npm run clickhouse:stop
    

Why make this change?

This adds analytical capabilities to support complex queries across span data without impacting the performance of the transactional PostgreSQL database. ClickHouse's columnar storage is optimized for OLAP workloads, enabling efficient aggregation and filtering across large volumes of trace data.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 6, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
v2-docs 145ccd6 Jan 09 2026, 03:31 AM

Copy link
Collaborator Author

koxudaxi commented Jan 6, 2026

@gitguardian
Copy link

gitguardian bot commented Jan 6, 2026

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from 195effa to e3af912 Compare January 6, 2026 10:56
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from e3af912 to 84bbe68 Compare January 6, 2026 11:02
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch 2 times, most recently from 237a2c3 to 409e497 Compare January 6, 2026 15:13
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch 2 times, most recently from 0ead3c4 to 39630ec Compare January 8, 2026 10:11
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch 3 times, most recently from 8a09180 to af7802b Compare January 8, 2026 10:30
@koxudaxi koxudaxi changed the base branch from v2 to graphite-base/1807 January 8, 2026 12:00
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from af7802b to f304bba Compare January 8, 2026 12:00
@koxudaxi koxudaxi changed the base branch from graphite-base/1807 to 01-08-fix_clickhouse_target_database_in_migrations January 8, 2026 12:00
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from f304bba to b48b0e8 Compare January 8, 2026 12:21
@koxudaxi koxudaxi force-pushed the 01-08-fix_clickhouse_target_database_in_migrations branch 2 times, most recently from a12104c to c402f9b Compare January 8, 2026 13:25
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from b48b0e8 to f7e727e Compare January 8, 2026 13:25
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch 2 times, most recently from ff98703 to b99dbd3 Compare January 8, 2026 18:03
@koxudaxi koxudaxi force-pushed the 01-08-fix_clickhouse_target_database_in_migrations branch from c402f9b to 094c363 Compare January 8, 2026 18:03
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from b99dbd3 to 3bd2c0e Compare January 8, 2026 18:09
@koxudaxi koxudaxi force-pushed the 01-08-fix_clickhouse_target_database_in_migrations branch from 094c363 to 3963ed9 Compare January 8, 2026 18:09
Copy link
Collaborator

willbakst commented Jan 9, 2026

Merge activity

@willbakst willbakst changed the base branch from 01-08-fix_clickhouse_target_database_in_migrations to graphite-base/1807 January 9, 2026 01:29
@koxudaxi koxudaxi force-pushed the graphite-base/1807 branch from 3963ed9 to fc202da Compare January 9, 2026 03:11
@koxudaxi koxudaxi force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from 3bd2c0e to 03c0acf Compare January 9, 2026 03:11
@willbakst willbakst force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from 03c0acf to c95780a Compare January 9, 2026 03:16
@graphite-app graphite-app bot changed the base branch from graphite-base/1807 to v2 January 9, 2026 03:16
@willbakst willbakst force-pushed the 01-06-feat_docker_add_clickhouse_service_for_local_development branch from c95780a to 145ccd6 Compare January 9, 2026 03:16
@willbakst willbakst merged commit 2028cfb into v2 Jan 9, 2026
13 of 14 checks passed
@willbakst willbakst deleted the 01-06-feat_docker_add_clickhouse_service_for_local_development branch January 9, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants