From d45e2118b5667128b6261c5dbcd1bd946f5da4bc Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sun, 13 Jul 2025 17:53:38 -0700 Subject: [PATCH] Add telemetry tracking for config loading performance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Import Telemetry from util/posthog.js in ConfigHandler - Track start and end time of reloadConfig method using performance.now() - Send "config_reload" telemetry event with duration, reason, totalConfigLoads, and configLoadInterrupted - Helps track config loading performance bottlenecks and understand reload patterns 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- core/config/ConfigHandler.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index e78af0028..b172ffb1d 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -17,6 +17,7 @@ import { } from "../control-plane/AuthTypes.js"; import { getControlPlaneEnv } from "../control-plane/env.js"; import { logger } from "../util/logger.js"; +import { Telemetry } from "../util/posthog.js"; import { ASSISTANTS, getAllDotContinueDefinitionFiles, @@ -431,6 +432,7 @@ export class ConfigHandler { // Because of e.g. MCP singleton and docs service using things from config // Could improve this async reloadConfig(reason: string) { + const startTime = performance.now(); this.totalConfigLoads += 1; // console.log(`Reloading config (${this.totalConfigLoads}): ${reason}`); // Uncomment to see config loading logs if (!this.currentProfile) { @@ -456,6 +458,17 @@ export class ConfigHandler { await this.currentProfile.reloadConfig(this.additionalContextProviders); this.notifyConfigListeners({ config, errors, configLoadInterrupted }); + + // Track config loading telemetry + const endTime = performance.now(); + const duration = endTime - startTime; + void Telemetry.capture("config_reload", { + duration, + reason, + totalConfigLoads: this.totalConfigLoads, + configLoadInterrupted, + }); + return { config, errors, configLoadInterrupted }; }