mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 13:34:15 -07:00
feat(routing): A/B Test Numerical Complexity Scoring for Gemini 3 (#16041)
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
This commit is contained in:
@@ -478,6 +478,8 @@ describe('Telemetry Metrics', () => {
|
||||
'user.email': 'test@example.com',
|
||||
'routing.decision_model': 'gemini-pro',
|
||||
'routing.decision_source': 'default',
|
||||
'routing.failed': false,
|
||||
'routing.reasoning': 'test-reason',
|
||||
});
|
||||
// The session counter is called once on init
|
||||
expect(mockCounterAddFn).toHaveBeenCalledTimes(1);
|
||||
@@ -501,6 +503,8 @@ describe('Telemetry Metrics', () => {
|
||||
'user.email': 'test@example.com',
|
||||
'routing.decision_model': 'gemini-pro',
|
||||
'routing.decision_source': 'classifier',
|
||||
'routing.failed': true,
|
||||
'routing.reasoning': 'test-reason',
|
||||
});
|
||||
|
||||
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
||||
@@ -508,7 +512,10 @@ describe('Telemetry Metrics', () => {
|
||||
'session.id': 'test-session-id',
|
||||
'installation.id': 'test-installation-id',
|
||||
'user.email': 'test@example.com',
|
||||
'routing.decision_model': 'gemini-pro',
|
||||
'routing.decision_source': 'classifier',
|
||||
'routing.failed': true,
|
||||
'routing.reasoning': 'test-reason',
|
||||
'routing.error_message': 'test-error',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -779,16 +779,29 @@ export function recordModelRoutingMetrics(
|
||||
)
|
||||
return;
|
||||
|
||||
modelRoutingLatencyHistogram.record(event.routing_latency_ms, {
|
||||
const attributes: Attributes = {
|
||||
...baseMetricDefinition.getCommonAttributes(config),
|
||||
'routing.decision_model': event.decision_model,
|
||||
'routing.decision_source': event.decision_source,
|
||||
});
|
||||
'routing.failed': event.failed,
|
||||
};
|
||||
|
||||
if (event.reasoning) {
|
||||
attributes['routing.reasoning'] = event.reasoning;
|
||||
}
|
||||
if (event.enable_numerical_routing !== undefined) {
|
||||
attributes['routing.enable_numerical_routing'] =
|
||||
event.enable_numerical_routing;
|
||||
}
|
||||
if (event.classifier_threshold) {
|
||||
attributes['routing.classifier_threshold'] = event.classifier_threshold;
|
||||
}
|
||||
|
||||
modelRoutingLatencyHistogram.record(event.routing_latency_ms, attributes);
|
||||
|
||||
if (event.failed) {
|
||||
modelRoutingFailureCounter.add(1, {
|
||||
...baseMetricDefinition.getCommonAttributes(config),
|
||||
'routing.decision_source': event.decision_source,
|
||||
...attributes,
|
||||
'routing.error_message': event.error_message,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1193,6 +1193,8 @@ export class ModelRoutingEvent implements BaseTelemetryEvent {
|
||||
reasoning?: string;
|
||||
failed: boolean;
|
||||
error_message?: string;
|
||||
enable_numerical_routing?: boolean;
|
||||
classifier_threshold?: string;
|
||||
|
||||
constructor(
|
||||
decision_model: string,
|
||||
@@ -1201,6 +1203,8 @@ export class ModelRoutingEvent implements BaseTelemetryEvent {
|
||||
reasoning: string | undefined,
|
||||
failed: boolean,
|
||||
error_message: string | undefined,
|
||||
enable_numerical_routing?: boolean,
|
||||
classifier_threshold?: string,
|
||||
) {
|
||||
this['event.name'] = 'model_routing';
|
||||
this['event.timestamp'] = new Date().toISOString();
|
||||
@@ -1210,20 +1214,38 @@ export class ModelRoutingEvent implements BaseTelemetryEvent {
|
||||
this.reasoning = reasoning;
|
||||
this.failed = failed;
|
||||
this.error_message = error_message;
|
||||
this.enable_numerical_routing = enable_numerical_routing;
|
||||
this.classifier_threshold = classifier_threshold;
|
||||
}
|
||||
|
||||
toOpenTelemetryAttributes(config: Config): LogAttributes {
|
||||
return {
|
||||
const attributes: LogAttributes = {
|
||||
...getCommonAttributes(config),
|
||||
'event.name': EVENT_MODEL_ROUTING,
|
||||
'event.timestamp': this['event.timestamp'],
|
||||
decision_model: this.decision_model,
|
||||
decision_source: this.decision_source,
|
||||
routing_latency_ms: this.routing_latency_ms,
|
||||
reasoning: this.reasoning,
|
||||
failed: this.failed,
|
||||
error_message: this.error_message,
|
||||
};
|
||||
|
||||
if (this.reasoning) {
|
||||
attributes['reasoning'] = this.reasoning;
|
||||
}
|
||||
|
||||
if (this.error_message) {
|
||||
attributes['error_message'] = this.error_message;
|
||||
}
|
||||
|
||||
if (this.enable_numerical_routing !== undefined) {
|
||||
attributes['enable_numerical_routing'] = this.enable_numerical_routing;
|
||||
}
|
||||
|
||||
if (this.classifier_threshold) {
|
||||
attributes['classifier_threshold'] = this.classifier_threshold;
|
||||
}
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
toLogBody(): string {
|
||||
|
||||
Reference in New Issue
Block a user