feat(telemetry): add onboarding start and end metrics for login with google

This commit is contained in:
Srinath Padmanabhan
2026-02-17 09:28:56 -08:00
parent 5f2f60bed6
commit ed2204ffce
3 changed files with 113 additions and 3 deletions
+36 -3
View File
@@ -43,6 +43,8 @@ const KEYCHAIN_AVAILABILITY_COUNT = 'gemini_cli.keychain.availability.count';
const TOKEN_STORAGE_TYPE_COUNT = 'gemini_cli.token_storage.type.count';
const OVERAGE_OPTION_COUNT = 'gemini_cli.overage_option.count';
const CREDIT_PURCHASE_COUNT = 'gemini_cli.credit_purchase.count';
const EVENT_ONBOARDING_START = 'gemini_cli.onboarding.start';
const EVENT_ONBOARDING_END = 'gemini_cli.onboarding.end';
// Agent Metrics
const AGENT_RUN_COUNT = 'gemini_cli.agent.run.count';
@@ -257,7 +259,6 @@ const COUNTER_DEFINITIONS = {
assign: (c: Counter) => (tokenStorageTypeCounter = c),
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
attributes: {} as {
type: string;
forced: boolean;
},
},
@@ -281,6 +282,18 @@ const COUNTER_DEFINITIONS = {
model: string;
},
},
[EVENT_ONBOARDING_START]: {
description: 'Counts onboarding start events.',
valueType: ValueType.INT,
assign: (c: Counter) => (onboardingStartCounter = c),
attributes: {} as Record<string, never>,
},
[EVENT_ONBOARDING_END]: {
description: 'Counts onboarding end events.',
valueType: ValueType.INT,
assign: (c: Counter) => (onboardingEndCounter = c),
attributes: {} as Record<string, never>,
},
} as const;
const HISTOGRAM_DEFINITIONS = {
@@ -529,7 +542,7 @@ const PERFORMANCE_HISTOGRAM_DEFINITIONS = {
},
} as const;
type AllMetricDefs = typeof COUNTER_DEFINITIONS &
export type AllMetricDefs = typeof COUNTER_DEFINITIONS &
typeof HISTOGRAM_DEFINITIONS &
typeof PERFORMANCE_COUNTER_DEFINITIONS &
typeof PERFORMANCE_HISTOGRAM_DEFINITIONS;
@@ -621,6 +634,8 @@ let keychainAvailabilityCounter: Counter | undefined;
let tokenStorageTypeCounter: Counter | undefined;
let overageOptionCounter: Counter | undefined;
let creditPurchaseCounter: Counter | undefined;
let onboardingStartCounter: Counter | undefined;
let onboardingEndCounter: Counter | undefined;
// OpenTelemetry GenAI Semantic Convention Metrics
let genAiClientTokenUsageHistogram: Histogram | undefined;
@@ -793,6 +808,25 @@ export function recordLinesChanged(
// --- New Metric Recording Functions ---
/**
* Records a metric for when the onboarding process starts.
*/
export function recordOnboardingStart(config: Config): void {
if (!onboardingStartCounter || !isMetricsInitialized) return;
onboardingStartCounter.add(
1,
baseMetricDefinition.getCommonAttributes(config),
);
}
/**
* Records a metric for when the onboarding process ends successfully.
*/
export function recordOnboardingEnd(config: Config): void {
if (!onboardingEndCounter || !isMetricsInitialized) return;
onboardingEndCounter.add(1, baseMetricDefinition.getCommonAttributes(config));
}
/**
* Records a metric for when a UI frame flickers.
*/
@@ -1354,7 +1388,6 @@ export function recordTokenStorageInitialization(
if (!tokenStorageTypeCounter || !isMetricsInitialized) return;
tokenStorageTypeCounter.add(1, {
...baseMetricDefinition.getCommonAttributes(config),
type: event.type,
forced: event.forced,
});
}