Skip to content

Commit b3a6f46

Browse files
authored
Merge pull request #605 from lmnr-ai/dev
Span level errors, clickhouse migrations
2 parents 476f6bf + 06a255f commit b3a6f46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+6463
-1507
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ SHARED_SECRET_TOKEN=some_secret
77
RABBITMQ_DEFAULT_USER=admin
88
RABBITMQ_DEFAULT_PASS=adminpasswd
99

10-
CLICKHOUSE_USER=default
10+
CLICKHOUSE_USER=ch_user
11+
CLICKHOUSE_PASSWORD=ch_passwd
1112
POSTGRES_PORT=5433
1213
# must be exactly 32 bytes (64 hex characters)
1314
AEAD_SECRET_KEY=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef

.github/workflows/backend-build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ on:
77
- opened
88
- reopened
99
paths:
10-
- "app-server/**"
10+
# Explicit list prevents triggering build on changes such as
11+
# README, .env.example.
12+
- "app-server/src/**"
13+
- "app-server/proto/**"
14+
- "app-server/**/*.rs"
15+
- "app-server/Cargo.lock"
16+
- "app-server/Cargo.toml"
1117

1218
jobs:
1319
build:

.github/workflows/fe-tests-check.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Check Frontend Tests
2+
3+
on:
4+
pull_request:
5+
types:
6+
- synchronize
7+
- opened
8+
- reopened
9+
paths:
10+
- 'frontend/**'
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Install pnpm
21+
uses: pnpm/action-setup@v4
22+
with:
23+
version: 9
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 'lts/*'
29+
cache: 'pnpm'
30+
cache-dependency-path: ./frontend/pnpm-lock.yaml
31+
32+
- name: Install dependencies
33+
working-directory: ./frontend
34+
run: pnpm install
35+
36+
- name: Run tests
37+
working-directory: ./frontend
38+
run: pnpm test

app-server/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ GRPC_PORT=8001
99
RABBITMQ_URL=amqp://admin:adminpasswd@localhost:5672/%2f
1010

1111
CLICKHOUSE_URL=http://localhost:8123
12-
CLICKHOUSE_USER=default
12+
CLICKHOUSE_USER=ch_user
13+
CLICKHOUSE_PASSWORD=ch_passwd
1314

1415
SHARED_SECRET_TOKEN=some_secret
1516
# must be exactly 32 bytes (64 hex characters)

app-server/src/ch/spans.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub struct CHSpan {
6464
pub path: String,
6565
pub input: String,
6666
pub output: String,
67+
pub status: String,
6768
#[serde(default)]
6869
pub size_bytes: u64,
6970
}
@@ -117,6 +118,7 @@ impl CHSpan {
117118
.unwrap_or(String::from("<null>")),
118119
input: span_input_string,
119120
output: span_output_string,
121+
status: span.status.clone().unwrap_or(String::from("<null>")),
120122
size_bytes: size_bytes as u64,
121123
}
122124
}

app-server/src/db/spans.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub struct Span {
5555
pub start_time: DateTime<Utc>,
5656
pub end_time: DateTime<Utc>,
5757
pub events: Option<Value>,
58+
pub status: Option<String>,
5859
pub labels: Option<Value>,
5960
pub input_url: Option<String>,
6061
pub output_url: Option<String>,
@@ -108,6 +109,7 @@ pub async fn record_span(pool: &PgPool, span: &Span, project_id: &Uuid) -> Resul
108109
output_preview,
109110
input_url,
110111
output_url,
112+
status,
111113
project_id
112114
)
113115
VALUES(
@@ -125,7 +127,8 @@ pub async fn record_span(pool: &PgPool, span: &Span, project_id: &Uuid) -> Resul
125127
$12,
126128
$13,
127129
$14,
128-
$15)
130+
$15,
131+
$16)
129132
ON CONFLICT (span_id, project_id) DO UPDATE SET
130133
trace_id = EXCLUDED.trace_id,
131134
parent_span_id = EXCLUDED.parent_span_id,
@@ -139,7 +142,8 @@ pub async fn record_span(pool: &PgPool, span: &Span, project_id: &Uuid) -> Resul
139142
input_preview = EXCLUDED.input_preview,
140143
output_preview = EXCLUDED.output_preview,
141144
input_url = EXCLUDED.input_url,
142-
output_url = EXCLUDED.output_url
145+
output_url = EXCLUDED.output_url,
146+
status = EXCLUDED.status
143147
",
144148
)
145149
.bind(&span.span_id)
@@ -156,6 +160,7 @@ pub async fn record_span(pool: &PgPool, span: &Span, project_id: &Uuid) -> Resul
156160
.bind(&output_preview)
157161
.bind(&span.input_url as &Option<String>)
158162
.bind(&span.output_url as &Option<String>)
163+
.bind(&span.status)
159164
.bind(&project_id)
160165
.execute(pool)
161166
.await?;

app-server/src/db/stats.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -140,62 +140,6 @@ pub struct WorkspaceStats {
140140
pub storage_limit: i64,
141141
}
142142

143-
pub async fn get_workspace_stats(pool: &PgPool, workspace_id: &Uuid) -> Result<WorkspaceStats> {
144-
let workspace_stats = sqlx::query_as::<_, WorkspaceStats>(
145-
"WITH members_per_workspace AS (
146-
SELECT
147-
workspace_id,
148-
count(user_id)::int8 as members
149-
FROM
150-
members_of_workspaces
151-
WHERE
152-
workspace_id = $1
153-
GROUP BY workspace_id
154-
)
155-
SELECT
156-
subscription_tiers.name as tier_name,
157-
subscription_tiers.members_per_workspace as seats_included_in_tier,
158-
workspace_usage.span_count as total_spans,
159-
workspace_usage.span_count_since_reset as spans_this_month,
160-
workspace_usage.step_count as total_steps,
161-
workspace_usage.step_count_since_reset as steps_this_month,
162-
subscription_tiers.spans as spans_limit,
163-
subscription_tiers.steps as steps_limit,
164-
GREATEST(
165-
workspace_usage.span_count_since_reset - subscription_tiers.spans,
166-
0
167-
) as spans_over_limit,
168-
GREATEST(
169-
workspace_usage.span_count_since_reset - subscription_tiers.spans,
170-
0
171-
)::float8 * subscription_tiers.extra_span_price as spans_over_limit_cost,
172-
GREATEST(
173-
workspace_usage.step_count_since_reset - subscription_tiers.steps,
174-
0
175-
) as steps_over_limit,
176-
GREATEST(
177-
workspace_usage.step_count_since_reset - subscription_tiers.steps,
178-
0
179-
)::float8 * subscription_tiers.extra_step_price as steps_over_limit_cost,
180-
members_per_workspace.members,
181-
subscription_tiers.members_per_workspace +
182-
workspaces.additional_seats as members_limit,
183-
subscription_tiers.storage_mib as storage_limit,
184-
workspace_usage.reset_time
185-
FROM
186-
workspace_usage
187-
JOIN members_per_workspace
188-
ON members_per_workspace.workspace_id = workspace_usage.workspace_id
189-
JOIN workspaces ON workspaces.id = workspace_usage.workspace_id
190-
JOIN subscription_tiers ON subscription_tiers.id = workspaces.tier_id",
191-
)
192-
.bind(workspace_id)
193-
.fetch_one(pool)
194-
.await?;
195-
196-
Ok(workspace_stats)
197-
}
198-
199143
pub async fn is_workspace_over_limit(
200144
pool: &PgPool,
201145
workspace_id: &Uuid,

app-server/src/evaluators/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,14 @@ pub async fn inner_process_evaluators(
6161
client: Arc<reqwest::Client>,
6262
python_online_evaluator_url: &str,
6363
) {
64-
let mut receiver = match queue
64+
let mut receiver = queue
6565
.get_receiver(
6666
EVALUATORS_QUEUE,
6767
EVALUATORS_EXCHANGE,
6868
EVALUATORS_ROUTING_KEY,
6969
)
7070
.await
71-
{
72-
Ok(receiver) => receiver,
73-
Err(e) => {
74-
log::error!("Failed to get receiver for evaluator queue: {:?}", e);
75-
return;
76-
}
77-
};
71+
.unwrap();
7872

7973
while let Some(delivery) = receiver.receive().await {
8074
if let Err(e) = delivery {

app-server/src/main.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,6 @@ fn main() -> anyhow::Result<()> {
533533
.service(routes::workspace::get_workspace)
534534
.service(routes::workspace::create_workspace),
535535
)
536-
.service(
537-
web::scope("/api/v1/limits")
538-
.wrap(auth.clone())
539-
.service(routes::limits::get_workspace_stats),
540-
)
541536
.service(
542537
// auth on path projects/{project_id} is handled by middleware on Next.js
543538
web::scope("/api/v1/projects/{project_id}")

app-server/src/routes/limits.rs

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

0 commit comments

Comments
 (0)