Skip to content

Commit 4ebd9ac

Browse files
committed
refactor(webapp): reuse logs ClickHouse connection for projection
1 parent 70280f5 commit 4ebd9ac

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
@@ -2075,11 +2075,10 @@ const EnvironmentSchema = z
20752075
// Keep reads on v1 until the scheduled v2 projector has enough history.
20762076
LOGS_SEARCH_TABLE_VERSION: z.enum(["v1", "v2"]).default("v1"),
20772077

2078-
// Scheduled logs-search projection. Disabled by default. The writer URL must reach both the
2079-
// task_events_v2 source and task_events_search_v2 destination tables.
2078+
// Scheduled logs-search projection. Disabled by default. LOGS_CLICKHOUSE_URL must reach both
2079+
// the task_events_v2 source and task_events_search_v2 destination tables.
20802080
LOGS_SEARCH_PROJECTOR_ENABLED: BoolEnv.default(false),
20812081
LOGS_SEARCH_PROJECTOR_PREVIEW_ENABLED: BoolEnv.default(false),
2082-
LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL: z.string().optional(),
20832082
LOGS_SEARCH_PROJECTOR_MAX_WINDOWS_PER_TICK: z.coerce.number().int().min(1).max(20).default(5),
20842083
LOGS_SEARCH_PROJECTOR_MAX_EXECUTION_TIME_SECONDS: z.coerce
20852084
.number()
@@ -2415,14 +2414,6 @@ const EnvironmentSchema = z
24152414
.and(GithubAppEnvSchema)
24162415
.and(S2EnvSchema)
24172416
.superRefine((env, ctx) => {
2418-
if (env.LOGS_SEARCH_PROJECTOR_ENABLED && !env.LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL) {
2419-
ctx.addIssue({
2420-
code: z.ZodIssueCode.custom,
2421-
path: ["LOGS_SEARCH_PROJECTOR_CLICKHOUSE_URL"],
2422-
message: "Required when LOGS_SEARCH_PROJECTOR_ENABLED is true",
2423-
});
2424-
}
2425-
24262417
const presets = new Set(env.COMPUTE_TEMPLATE_MACHINE_PRESETS);
24272418
for (const required of env.COMPUTE_TEMPLATE_MACHINE_PRESETS_REQUIRED) {
24282419
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)