Skip to content

Commit 65da20c

Browse files
authored
feat: replicate task runs to clickhouse to power dashboard improvements (#2035)
* WIP clickhouse package with test containers setup * More clickhouse client setup now with otel and real tests, and the v1 of raw run events * Add some additional columns to raw_run_events_v1 * WIP runs dashboard service * Create a new run engine event bus event for the runs dashboard to hook into * Track run events in the run engine * make sure engine v1 runs get synced to CH * Update the attemptNumber of v3 task runs * Restructure the run events to be more sparse * emit more stuff * Setup replication package * scaffold the replication package * replication wip * resolve conflicts * more replication stuff * Add ability to drop the replication slot completely on teardown * Use the new single replacingmergetree task events table for replication * get it working * insert payloads into their own table only on insert and then join * prepare for using clickhouse cloud and now running ch migrations during boot in the entrypoint.sh * Handover WIP and tests * Testing the replication service * Remove the runs dashboard stuff that we aren't using anymore * Added a test for large payloads * hacky typecheck fix * Fix new internal package typecheck issues and start adding telemetry to the replication service * tracing over spans, some other improvements * Improvements to the runs replication service, now ready for testing * Some fixes and cleanups * Don't need this code anymore * move transaction types into the runs replication service * only send spans where there are transaction events * A couple of suggested tweaks
1 parent ccc9764 commit 65da20c

File tree

88 files changed

+7712
-752
lines changed

Some content is hidden

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

88 files changed

+7712
-752
lines changed

apps/webapp/app/env.server.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,47 @@ const EnvironmentSchema = z.object({
725725
// BetterStack
726726
BETTERSTACK_API_KEY: z.string().optional(),
727727
BETTERSTACK_STATUS_PAGE_ID: z.string().optional(),
728+
729+
RUN_REPLICATION_REDIS_HOST: z
730+
.string()
731+
.optional()
732+
.transform((v) => v ?? process.env.REDIS_HOST),
733+
RUN_REPLICATION_REDIS_READER_HOST: z
734+
.string()
735+
.optional()
736+
.transform((v) => v ?? process.env.REDIS_READER_HOST),
737+
RUN_REPLICATION_REDIS_READER_PORT: z.coerce
738+
.number()
739+
.optional()
740+
.transform(
741+
(v) =>
742+
v ?? (process.env.REDIS_READER_PORT ? parseInt(process.env.REDIS_READER_PORT) : undefined)
743+
),
744+
RUN_REPLICATION_REDIS_PORT: z.coerce
745+
.number()
746+
.optional()
747+
.transform((v) => v ?? (process.env.REDIS_PORT ? parseInt(process.env.REDIS_PORT) : undefined)),
748+
RUN_REPLICATION_REDIS_USERNAME: z
749+
.string()
750+
.optional()
751+
.transform((v) => v ?? process.env.REDIS_USERNAME),
752+
RUN_REPLICATION_REDIS_PASSWORD: z
753+
.string()
754+
.optional()
755+
.transform((v) => v ?? process.env.REDIS_PASSWORD),
756+
RUN_REPLICATION_REDIS_TLS_DISABLED: z.string().default(process.env.REDIS_TLS_DISABLED ?? "false"),
757+
758+
RUN_REPLICATION_CLICKHOUSE_URL: z.string().optional(),
759+
RUN_REPLICATION_ENABLED: z.string().default("0"),
760+
RUN_REPLICATION_SLOT_NAME: z.string().default("task_runs_to_clickhouse_v1"),
761+
RUN_REPLICATION_PUBLICATION_NAME: z.string().default("task_runs_to_clickhouse_v1_publication"),
762+
RUN_REPLICATION_MAX_FLUSH_CONCURRENCY: z.coerce.number().int().default(100),
763+
RUN_REPLICATION_FLUSH_INTERVAL_MS: z.coerce.number().int().default(1000),
764+
RUN_REPLICATION_FLUSH_BATCH_SIZE: z.coerce.number().int().default(100),
765+
RUN_REPLICATION_LEADER_LOCK_TIMEOUT_MS: z.coerce.number().int().default(30_000),
766+
RUN_REPLICATION_LEADER_LOCK_EXTEND_INTERVAL_MS: z.coerce.number().int().default(10_000),
767+
RUN_REPLICATION_ACK_INTERVAL_SECONDS: z.coerce.number().int().default(10),
768+
RUN_REPLICATION_LOG_LEVEL: z.enum(["log", "error", "warn", "info", "debug"]).default("info"),
728769
});
729770

730771
export type Environment = z.infer<typeof EnvironmentSchema>;

apps/webapp/app/metrics.server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { env } from "./env.server";
44

55
export const metricsRegister = singleton("metricsRegister", initializeMetricsRegister);
66

7-
function initializeMetricsRegister() {
7+
export type MetricsRegister = Registry<OpenMetricsContentType>;
8+
9+
function initializeMetricsRegister(): MetricsRegister {
810
const registry = new Registry<OpenMetricsContentType>();
911

1012
register.setDefaultLabels({

0 commit comments

Comments
 (0)