Skip to content

Commit

Permalink
Removing overly dimensional generate metrics (#1383)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxl0rd authored Nov 22, 2024
1 parent c10aacb commit bf7a942
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
14 changes: 1 addition & 13 deletions js/plugins/google-cloud/src/telemetry/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,6 @@ class GenerateTelemetry implements Telemetry {
}
) {
this.doRecordGenerateActionMetrics(modelName, opts.response?.usage || {}, {
temperature: input.config?.temperature,
topK: input.config?.topK,
topP: input.config?.topP,
maxOutputTokens: input.config?.maxOutputTokens,
featureName,
path,
latencyMs: opts.response?.latencyMs,
Expand Down Expand Up @@ -342,7 +338,7 @@ class GenerateTelemetry implements Telemetry {
}

private xOfY(x: number, y: number): string {
return `${x} of ${y}`;
return `${x + 1} of ${y}`;
}

private toPartLogContent(part: Part): string {
Expand Down Expand Up @@ -415,10 +411,6 @@ class GenerateTelemetry implements Telemetry {
dimensions: {
featureName?: string;
path?: string;
temperature?: number;
maxOutputTokens?: number;
topK?: number;
topP?: number;
latencyMs?: number;
errName?: string;
source?: string;
Expand All @@ -429,16 +421,12 @@ class GenerateTelemetry implements Telemetry {
modelName: modelName,
featureName: dimensions.featureName,
path: dimensions.path,
temperature: dimensions.temperature,
topK: dimensions.topK,
topP: dimensions.topP,
source: dimensions.source,
sourceVersion: dimensions.sourceVersion,
status: dimensions.errName ? 'failure' : 'success',
};

this.actionCounter.add(1, {
maxOutputTokens: dimensions.maxOutputTokens,
error: dimensions.errName,
...shared,
});
Expand Down
7 changes: 0 additions & 7 deletions js/plugins/google-cloud/tests/metrics_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ describe('GoogleCloudMetrics', () => {
'genkit/ai/generate/latency'
);
assert.equal(requestCounter.value, 1);
assert.equal(requestCounter.attributes.maxOutputTokens, 7);
assert.equal(inputTokenCounter.value, 10);
assert.equal(outputTokenCounter.value, 14);
assert.equal(inputCharacterCounter.value, 8);
Expand All @@ -361,9 +360,6 @@ describe('GoogleCloudMetrics', () => {
latencyHistogram,
]) {
assert.equal(metric.attributes.modelName, 'testModel');
assert.equal(metric.attributes.temperature, 1.0);
assert.equal(metric.attributes.topK, 3);
assert.equal(metric.attributes.topP, 5);
assert.equal(metric.attributes.source, 'ts');
assert.equal(metric.attributes.status, 'success');
assert.equal(metric.attributes.featureName, 'generate');
Expand Down Expand Up @@ -398,9 +394,6 @@ describe('GoogleCloudMetrics', () => {
);
assert.equal(requestCounter.value, 1);
assert.equal(requestCounter.attributes.modelName, 'failingTestModel');
assert.equal(requestCounter.attributes.temperature, 1.0);
assert.equal(requestCounter.attributes.topK, 3);
assert.equal(requestCounter.attributes.topP, 5);
assert.equal(requestCounter.attributes.source, 'ts');
assert.equal(requestCounter.attributes.status, 'failure');
assert.equal(requestCounter.attributes.error, 'TypeError');
Expand Down

0 comments on commit bf7a942

Please sign in to comment.