🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(dev-tables): update events seed logic to better emulate production (#12095)
Valery Meleshkin9dc61e52be05
diff --git a/packages/shared/clickhouse/scripts/dev-tables.sh b/packages/shared/clickhouse/scripts/dev-tables.shindex d57e862ec7..a2e89fca81 100644--- a/packages/shared/clickhouse/scripts/dev-tables.sh+++ b/packages/shared/clickhouse/scripts/dev-tables.sh@@ -695,40 +695,43 @@ clickhouse client \--password="${CLICKHOUSE_PASSWORD}" \--database="${CLICKHOUSE_DB}" \--multiquery <<EOF+ SET type_json_skip_duplicated_paths = 1;TRUNCATE events;INSERT INTO events (project_id, trace_id, span_id, parent_span_id, start_time, end_time, name, type,environment, version, release, tags, trace_name, user_id, session_id, public, bookmarked, level, status_message, completion_start_time, prompt_id,prompt_name, prompt_version, model_id, provided_model_name, model_parameters,- provided_usage_details, usage_details, provided_cost_details, cost_details, tool_definitions, tool_calls, tool_call_names, input,-+ provided_usage_details, usage_details, provided_cost_details, cost_details,+ usage_pricing_tier_id, usage_pricing_tier_name,+ tool_definitions, tool_calls, tool_call_names, input,output, metadata, metadata_names, metadata_raw_values,- -- metadata_string_names, metadata_string_values, metadata_number_names, metadata_number_values, metadata_bool_names, metadata_bool_values,- source, service_name, service_version, scope_name, scope_version, telemetry_sdk_language,- telemetry_sdk_name, telemetry_sdk_version, blob_storage_file_path, event_bytes,+ source, blob_storage_file_path, event_bytes,created_at, updated_at, event_ts, is_deleted)SELECT o.project_id,o.trace_id,o.id AS span_id,- o.parent_observation_id AS parent_span_id,+ CASE+ WHEN o.id = concat('t-', o.trace_id) THEN ''+ ELSE coalesce(o.parent_observation_id, concat('t-', o.trace_id))+ END AS parent_span_id,o.start_time,o.end_time,o.name,o.type,o.environment,- o.version,- t.release as release,- t.tags as tags,- t.name as trace_name,- t.user_id AS user_id,- t.session_id AS session_id,- t.public AS public,- t.bookmarked AND (o.parent_observation_id IS NULL OR o.parent_observation_id == '') AS bookmarked,+ coalesce(o.version, t.version) AS version,+ coalesce(t.release, '') AS release,+ t.tags AS tags,+ t.name AS trace_name,+ coalesce(t.user_id, '') AS user_id,+ coalesce(t.session_id, '') AS session_id,+ t.public AS public,+ t.bookmarked AND (o.parent_observation_id IS NULL OR o.parent_observation_id = '') AS bookmarked,o.level,- ifNull(o.status_message, '') AS status_message,+ coalesce(o.status_message, '') AS status_message,o.completion_start_time,o.prompt_id,o.prompt_name,- CAST(o.prompt_version, 'Nullable(String)'),+ o.prompt_version,o.internal_model_id AS model_id,o.provided_model_name,coalesce(o.model_parameters, '{}'),@@ -736,88 +739,80 @@ clickhouse client \o.usage_details,o.provided_cost_details,o.cost_details,+ o.usage_pricing_tier_id,+ o.usage_pricing_tier_name,o.tool_definitions,o.tool_calls,o.tool_call_names,-- ifNull(o.input, '') AS input,- ifNull(o.output, '') AS output,- CAST(o.metadata, 'JSON'),- mapKeys(o.metadata) AS metadata_names,- mapValues(o.metadata) AS metadata_raw_values,- multiIf(mapContains(o.metadata, 'resourceAttributes'), 'otel', 'ingestion-api') AS source,- NULL AS service_name,- NULL AS service_version,- NULL AS scope_name,- NULL AS scope_version,- NULL AS telemetry_sdk_language,- NULL AS telemetry_sdk_name,- NULL AS telemetry_sdk_version,- '' AS blob_storage_file_path,- 0 AS event_bytes,+ coalesce(o.input, '') AS input,+ coalesce(o.output, '') AS output,+ CAST(mapConcat(o.metadata, coalesce(t.metadata, map())), 'JSON(max_dynamic_paths=0)') AS metadata,+ mapKeys(mapConcat(o.metadata, coalesce(t.metadata, map()))) AS metadata_names,+ mapValues(mapConcat(o.metadata, coalesce(t.metadata, map()))) AS metadata_raw_values,+ multiIf(mapContains(o.metadata, 'resourceAttributes'), 'otel-dual-write', 'ingestion-api-dual-write') AS source,+ '' AS blob_storage_file_path,+ byteSize(*) AS event_bytes,o.created_at,o.updated_at,o.event_ts,o.is_deletedFROM observations o FINAL- LEFT JOIN traces t ON o.trace_id = t.id+ LEFT JOIN traces t ON o.project_id = t.project_id AND o.trace_id = t.id+ LEFT ANTI JOIN dataset_run_items_rmt excl ON excl.project_id = o.project_id AND excl.trace_id = o.trace_idWHERE (o.is_deleted = 0);-- Backfill events from traces table as well+ -- Traces are converted to synthetic observations with id = 't-' + trace_id+ -- (matching convertTraceToStagingObservation in the ingestion pipeline)INSERT INTO events (project_id, trace_id, span_id, parent_span_id, start_time, name, type,environment, version, release, tags, trace_name, user_id, session_id, public, bookmarked, level,- model_parameters, provided_usage_details, usage_details, provided_cost_details, cost_details, tool_definitions, tool_calls, tool_call_names,-+ model_parameters, provided_usage_details, usage_details, provided_cost_details, cost_details,+ usage_pricing_tier_id, usage_pricing_tier_name,+ tool_definitions, tool_calls, tool_call_names,input, output,metadata, metadata_names, metadata_raw_values,- source, service_name, service_version, scope_name, scope_version, telemetry_sdk_language,- telemetry_sdk_name, telemetry_sdk_version, blob_storage_file_path, event_bytes,+ source, blob_storage_file_path, event_bytes,created_at, updated_at, event_ts, is_deleted)SELECT t.project_id,t.id,- t.id AS span_id,- '' AS parent_span_id,+ concat('t-', t.id) AS span_id,+ '' AS parent_span_id,t.timestamp,t.name,'SPAN',t.environment,t.version,- t.release as release,- t.tags as tags,- t.name as trace_name,- t.user_id AS user_id,- t.session_id AS session_id,- t.public AS public,- t.bookmarked AS bookmarked,- 'DEFAULT' AS level,- map() AS model_parameters,+ coalesce(t.release, '') AS release,+ t.tags AS tags,+ t.name AS trace_name,+ coalesce(t.user_id, '') AS user_id,+ coalesce(t.session_id, '') AS session_id,+ t.public AS public,+ t.bookmarked AS bookmarked,+ 'DEFAULT' AS level,+ '{}' AS model_parameters,map(),map(),map(),map(),+ NULL,+ NULL,map(),[],[],-- ifNull(t.input, '') AS input,- ifNull(t.output, '') AS output,- CAST(t.metadata, 'JSON'),+ coalesce(t.input, '') AS input,+ coalesce(t.output, '') AS output,+ CAST(t.metadata, 'JSON(max_dynamic_paths=0)'),mapKeys(t.metadata) AS metadata_names,mapValues(t.metadata) AS metadata_raw_values,- multiIf(mapContains(t.metadata, 'resourceAttributes'), 'otel', 'ingestion-api') AS source,- NULL AS service_name,- NULL AS service_version,- NULL AS scope_name,- NULL AS scope_version,- NULL AS telemetry_sdk_language,- NULL AS telemetry_sdk_name,- NULL AS telemetry_sdk_version,- '' AS blob_storage_file_path,- 0 AS event_bytes,+ multiIf(mapContains(t.metadata, 'resourceAttributes'), 'otel-dual-write', 'ingestion-api-dual-write') AS source,+ '' AS blob_storage_file_path,+ byteSize(*) AS event_bytes,t.created_at,t.updated_at,t.event_ts,t.is_deletedFROM traces t FINAL+ LEFT ANTI JOIN dataset_run_items_rmt excl ON excl.project_id = t.project_id AND excl.trace_id = t.idWHERE (t.is_deleted = 0);EOF