Elffuss BraidHub

kikocis/continue public

Merge pull request #7644 from continuedev/nate/fix-grafana

instance id to fix metrics
Changeset10d1431e9a2f108b48896c6ece74c49f438e76363f92e0c76a95a5d2c9264bc5
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-09-08 21:31 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-08 21:31 -07:00
Parentsf64709e50f50, 3231c10ab9d1

Browse the files at this changeset

2 files changed

modified extensions/cli/src/slashCommands.ts +4 −0
@@ -11,6 +11,7 @@
1111 import { reloadService, SERVICE_NAMES, services } from "./services/index.js";
1212 import { getCurrentSession } from "./session.js";
1313 import { posthogService } from "./telemetry/posthogService.js";
14+import { telemetryService } from "./telemetry/telemetryService.js";
1415 import { SlashCommandResult } from "./ui/hooks/useChat.types.js";
1516
1617 type CommandHandler = (
@@ -198,6 +199,9 @@
198199
199200 const [command, ...args] = input.slice(1).split(" ");
200201
202+ telemetryService.recordSlashCommand(command);
203+ posthogService.capture("useSlashCommand", { name: command });
204+
201205 const handler = commandHandlers[command];
202206 if (handler) {
203207 return await handler(args, assistant);
modified extensions/cli/src/telemetry/telemetryService.ts +22 −0
@@ -10,8 +10,10 @@
1010 } from "@opentelemetry/sdk-metrics";
1111 import {
1212 SEMRESATTRS_DEPLOYMENT_ENVIRONMENT,
13+ SEMRESATTRS_HOST_NAME,
1314 SEMRESATTRS_OS_TYPE,
1415 SEMRESATTRS_PROCESS_PID,
16+ SEMRESATTRS_SERVICE_INSTANCE_ID,
1517 SEMRESATTRS_SERVICE_NAME,
1618 SEMRESATTRS_SERVICE_VERSION,
1719 } from "@opentelemetry/semantic-conventions";
@@ -52,6 +54,7 @@
5254 private mcpConnectionsGauge: any = null;
5355 private startupTimeHistogram: any = null;
5456 private responseTimeHistogram: any = null;
57+ private slashCommandCounter: any = null;
5558
5659 constructor() {
5760 this.config = this.loadConfig();
@@ -88,6 +91,8 @@
8891 const resource = resourceFromAttributes({
8992 [SEMRESATTRS_SERVICE_NAME]: "continue-cli",
9093 [SEMRESATTRS_SERVICE_VERSION]: getVersion(),
94+ [SEMRESATTRS_SERVICE_INSTANCE_ID]: uuidv4(),
95+ [SEMRESATTRS_HOST_NAME]: os.hostname(),
9196 [SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]:
9297 process.env.NODE_ENV || "development",
9398 [SEMRESATTRS_OS_TYPE]: os.type(),
@@ -281,6 +286,14 @@
281286 unit: "ms",
282287 },
283288 );
289+
290+ this.slashCommandCounter = this.meter.createCounter(
291+ "continue_cli_slash_command_usage",
292+ {
293+ description: "Count of slash commands used",
294+ unit: "count",
295+ },
296+ );
284297 }
285298
286299 // Check if telemetry is enabled - this is the single point of checking
@@ -567,6 +580,15 @@
567580 return this.config.sessionId;
568581 }
569582
583+ public recordSlashCommand(commandName: string) {
584+ if (!this.isEnabled()) return;
585+
586+ this.slashCommandCounter.add(
587+ 1,
588+ this.getStandardAttributes({ command: commandName }),
589+ );
590+ }
591+
570592 /**
571593 * Shutdown telemetry service and ensure all metrics are flushed
572594 */