Skip to content

The only tool you need to know what is happening and how to fix it.

1.9 KB
Raw Blame
CREATE TABLE IF NOT EXISTS ai_traces_v2 (
    id UUID,
    project_id UUID,
    trace_id String DEFAULT '',
    span_id String DEFAULT '',
    parent_span_id String DEFAULT '',
    linked_trace_id String DEFAULT '',
    recorded_at DateTime64(3),
    duration Int64 DEFAULT 0,
    status_code UInt8 DEFAULT 0,
    model LowCardinality(String) DEFAULT '',
    response_model LowCardinality(String) DEFAULT '',
    provider LowCardinality(String) DEFAULT '',
    operation LowCardinality(String) DEFAULT '',
    input_tokens Int64 DEFAULT 0,
    output_tokens Int64 DEFAULT 0,
    total_tokens Int64 DEFAULT 0,
    cached_tokens Int64 DEFAULT 0,
    reasoning_tokens Int64 DEFAULT 0,
    input_cost Float64 DEFAULT 0,
    output_cost Float64 DEFAULT 0,
    total_cost Float64 DEFAULT 0,
    trace_name LowCardinality(String) DEFAULT '',
    user_id String DEFAULT '',
    finish_reason LowCardinality(String) DEFAULT '',
    server_name LowCardinality(String) DEFAULT '',
    app_version LowCardinality(String) DEFAULT '',
    storage_key String DEFAULT '',
    attributes String DEFAULT '{}',
    is_root UInt8 DEFAULT 1,
    conversation_id String DEFAULT '',
    tool_call_count Int64 DEFAULT 0,
    tool_names String DEFAULT '',
    flagged UInt8 DEFAULT 0,
    flagged_terms String DEFAULT '',
    INDEX idx_ai_traces_v2_id id TYPE bloom_filter(0.001) GRANULARITY 1,
    INDEX idx_ai_traces_v2_trace_name trace_name TYPE set(100) GRANULARITY 4,
    INDEX idx_ai_traces_v2_model model TYPE set(100) GRANULARITY 4,
    INDEX idx_ai_traces_v2_trace_id trace_id TYPE bloom_filter(0.001) GRANULARITY 1,
    INDEX idx_ai_traces_v2_linked_trace_id linked_trace_id TYPE bloom_filter(0.001) GRANULARITY 1,
    INDEX idx_ai_traces_v2_conversation_id conversation_id TYPE bloom_filter(0.001) GRANULARITY 1
) ENGINE = MergeTree
PARTITION BY toYYYYMMDD(recorded_at)
ORDER BY (project_id, recorded_at, trace_name)