Skip to content

Commit 15ef119

Browse files
authored
update schemas to latest versions, control trace aggregation (#973)
* update schemas to latest versions, control trace aggregation * fix build * add playground trace type * change analysis_status to default to info
1 parent e5785b9 commit 15ef119

File tree

19 files changed

+4039
-1436
lines changed

19 files changed

+4039
-1436
lines changed

app-server/src/features/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub enum Feature {
1616
SqlQueryEngine,
1717
ClickhouseReadOnly,
1818
Tracing,
19+
AggregateTraces,
1920
}
2021

2122
pub fn is_feature_enabled(feature: Feature) -> bool {
@@ -44,5 +45,9 @@ pub fn is_feature_enabled(feature: Feature) -> bool {
4445
Feature::Tracing => {
4546
env::var("SENTRY_DSN").is_ok() && env::var("ENABLE_TRACING").is_ok_and(|s| s == "true")
4647
}
48+
Feature::AggregateTraces => {
49+
env::var("AGGREGATE_TRACES").is_ok()
50+
&& env::var("ENVIRONMENT") == Ok("PRODUCTION".to_string())
51+
}
4752
}
4853
}

app-server/src/traces/consumer.rs

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -337,27 +337,29 @@ async fn process_batch(
337337
}
338338

339339
// Process trace aggregations and update trace statistics
340-
let trace_aggregations = TraceAggregation::from_spans(&spans, &span_usage_vec);
341-
if !trace_aggregations.is_empty() {
342-
// Upsert trace statistics in PostgreSQL
343-
match upsert_trace_statistics_batch(&db.pool, &trace_aggregations).await {
344-
Ok(updated_traces) => {
345-
// Convert to ClickHouse traces and upsert
346-
let ch_traces: Vec<CHTrace> = updated_traces
347-
.iter()
348-
.map(|trace| CHTrace::from_db_trace(trace))
349-
.collect();
350-
351-
if let Err(e) = upsert_traces_batch(clickhouse.clone(), &ch_traces).await {
352-
log::error!(
353-
"Failed to upsert {} traces to ClickHouse: {:?}",
354-
ch_traces.len(),
355-
e
356-
);
340+
if is_feature_enabled(Feature::AggregateTraces) {
341+
let trace_aggregations = TraceAggregation::from_spans(&spans, &span_usage_vec);
342+
if !trace_aggregations.is_empty() {
343+
// Upsert trace statistics in PostgreSQL
344+
match upsert_trace_statistics_batch(&db.pool, &trace_aggregations).await {
345+
Ok(updated_traces) => {
346+
// Convert to ClickHouse traces and upsert
347+
let ch_traces: Vec<CHTrace> = updated_traces
348+
.iter()
349+
.map(|trace| CHTrace::from_db_trace(trace))
350+
.collect();
351+
352+
if let Err(e) = upsert_traces_batch(clickhouse.clone(), &ch_traces).await {
353+
log::error!(
354+
"Failed to upsert {} traces to ClickHouse: {:?}",
355+
ch_traces.len(),
356+
e
357+
);
358+
}
359+
}
360+
Err(e) => {
361+
log::error!("Failed to upsert trace statistics to PostgreSQL: {:?}", e);
357362
}
358-
}
359-
Err(e) => {
360-
log::error!("Failed to upsert trace statistics to PostgreSQL: {:?}", e);
361363
}
362364
}
363365
}

docker-compose-full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ services:
7070
test: ["CMD", "sleep", "5"]
7171
interval: 10s
7272
timeout: 6s
73-
retries: 1
73+
retries: 3
7474

7575
app-server:
7676
image: ghcr.io/lmnr-ai/app-server

docker-compose-local-build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
name: lmnr
44

55
services:
6-
76
rabbitmq:
87
image: rabbitmq
98
pull_policy: always
@@ -66,7 +65,7 @@ services:
6665
test: ["CMD", "sleep", "5"]
6766
interval: 10s
6867
timeout: 6s
69-
retries: 1
68+
retries: 3
7069

7170
app-server:
7271
ports:

docker-compose-local-dev-full.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ services:
5858
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
5959
POSTGRES_DB: ${POSTGRES_DB}
6060
healthcheck:
61-
test: [ "CMD", "pg_isready", "-U", "${POSTGRES_USER}", "-d", "${POSTGRES_DB}" ]
61+
test:
62+
["CMD", "pg_isready", "-U", "${POSTGRES_USER}", "-d", "${POSTGRES_DB}"]
6263
interval: 2s
6364
timeout: 5s
6465
retries: 5

docker-compose-local-dev.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ services:
5151
nofile:
5252
soft: 262144
5353
hard: 262144
54-
54+
5555
query-engine:
5656
image: ghcr.io/lmnr-ai/query-engine
5757
pull_policy: always
@@ -63,7 +63,7 @@ services:
6363
test: ["CMD", "sleep", "5"]
6464
interval: 10s
6565
timeout: 6s
66-
retries: 1
66+
retries: 3
6767

6868
app-server:
6969
image: ghcr.io/lmnr-ai/app-server

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545
nofile:
4646
soft: 262144
4747
hard: 262144
48-
48+
4949
query-engine:
5050
image: ghcr.io/lmnr-ai/query-engine
5151
pull_policy: always
@@ -57,7 +57,7 @@ services:
5757
test: ["CMD", "sleep", "5"]
5858
interval: 10s
5959
timeout: 6s
60-
retries: 1
60+
retries: 3
6161

6262
frontend:
6363
image: ghcr.io/lmnr-ai/frontend

frontend/app/api/traces/summary/route.ts

Lines changed: 0 additions & 73 deletions
This file was deleted.

frontend/lib/actions/traces/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,4 @@ export async function deleteTraces(input: z.infer<typeof DeleteTracesSchema>) {
148148
});
149149
}
150150

151-
export { EVENTS_TRACE_VIEW_WIDTH,TRACES_TRACE_VIEW_WIDTH };
151+
export { EVENTS_TRACE_VIEW_WIDTH, TRACES_TRACE_VIEW_WIDTH };

frontend/lib/actions/traces/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ const tracesSelectColumns = [
121121
"total_cost as totalCost",
122122
"trace_type as traceType",
123123
"status",
124-
"summary",
125124
"user_id as userId",
126125
];
127126

0 commit comments

Comments
 (0)