Skip to content

Commit d887475

Browse files
committed
refactor(webapp): reuse logs ClickHouse connection for projection
1 parent 5c47145 commit d887475

4 files changed

Lines changed: 6 additions & 15 deletions

File tree

.env.example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ RUN_REPLICATION_CLICKHOUSE_URL=http://default:password@localhost:8123
2525
RUN_REPLICATION_ENABLED=1
2626
# LOGS_SEARCH_PROJECTOR_ENABLED=1
2727
# LOGS_SEARCH_PROJECTOR_PREVIEW_ENABLED=1
28-
# LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL=http://default:password@localhost:8123
2928
# Store task run spans/traces in ClickHouse so the dashboard trace view is
3029
# populated in local dev. The local stack is ClickHouse-backed (see above), so
3130
# leaving this unset falls back to the "postgres" store and dev run traces show

apps/webapp/app/env.server.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,11 +2097,10 @@ const EnvironmentSchema = z
20972097
// Keep reads on v1 until the scheduled v2 projector has enough history.
20982098
LOGS_SEARCH_TABLE_VERSION: z.enum(["v1", "v2"]).default("v1"),
20992099

2100-
// Scheduled logs-search projection. Disabled by default. The writer URL must reach both the
2101-
// task_events_v2 source and task_events_search_v2 destination tables.
2100+
// Scheduled logs-search projection. Disabled by default. LOGS_CLICKHOUSE_URL must reach both
2101+
// the task_events_v2 source and task_events_search_v2 destination tables.
21022102
LOGS_SEARCH_PROJECTOR_ENABLED: BoolEnv.default(false),
21032103
LOGS_SEARCH_PROJECTOR_PREVIEW_ENABLED: BoolEnv.default(false),
2104-
LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL: z.string().optional(),
21052104
LOGS_SEARCH_PROJECTOR_MAX_WINDOWS_PER_TICK: z.coerce.number().int().min(1).max(20).default(5),
21062105
LOGS_SEARCH_PROJECTOR_MAX_EXECUTION_TIME_SECONDS: z.coerce
21072106
.number()
@@ -2437,14 +2436,6 @@ const EnvironmentSchema = z
24372436
.and(GithubAppEnvSchema)
24382437
.and(S2EnvSchema)
24392438
.superRefine((env, ctx) => {
2440-
if (env.LOGS_SEARCH_PROJECTOR_ENABLED && !env.LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL) {
2441-
ctx.addIssue({
2442-
code: z.ZodIssueCode.custom,
2443-
path: ["LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL"],
2444-
message: "Required when LOGS_SEARCH_PROJECTOR_ENABLED is true",
2445-
});
2446-
}
2447-
24482439
const presets = new Set(env.COMPUTE_TEMPLATE_MACHINE_PRESETS);
24492440
for (const required of env.COMPUTE_TEMPLATE_MACHINE_PRESETS_REQUIRED) {
24502441
if (!presets.has(required)) {

apps/webapp/app/services/clickhouse/clickhouseFactory.server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ const defaultLogsClickhouseClient = singleton(
3838
);
3939

4040
function initializeLogsSearchProjectorClickhouseClient() {
41-
if (!env.LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL) {
42-
throw new Error("LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL is not set");
41+
if (!env.LOGS_CLICKHOUSE_URL) {
42+
throw new Error("LOGS_CLICKHOUSE_URL is not set");
4343
}
4444

45-
const url = new URL(env.LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL);
45+
const url = new URL(env.LOGS_CLICKHOUSE_URL);
4646
url.searchParams.delete("secure");
4747

4848
return new ClickHouse({

apps/webapp/test/logsSearchProjectorStateStore.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const at = (value: string) => new Date(value);
1111

1212
postgresTest(
1313
"persists low-churn control state and append-only finalized checkpoints",
14+
{ timeout: 20_000 },
1415
async ({ prisma }) => {
1516
const store = new PrismaLogsSearchProjectorStateStore(prisma);
1617
const initial = at("2026-08-14T12:00:00.000Z");

0 commit comments

Comments
 (0)