@frengki0707/google-cloud-clone 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +203 -0
- package/README.md +83 -0
- package/lib/auth.d.mts +33 -0
- package/lib/auth.d.ts +33 -0
- package/lib/auth.js +70 -0
- package/lib/auth.js.map +1 -0
- package/lib/auth.mjs +45 -0
- package/lib/auth.mjs.map +1 -0
- package/lib/gcpLogger.d.mts +25 -0
- package/lib/gcpLogger.d.ts +25 -0
- package/lib/gcpLogger.js +118 -0
- package/lib/gcpLogger.js.map +1 -0
- package/lib/gcpLogger.mjs +82 -0
- package/lib/gcpLogger.mjs.map +1 -0
- package/lib/gcpOpenTelemetry.d.mts +59 -0
- package/lib/gcpOpenTelemetry.d.ts +59 -0
- package/lib/gcpOpenTelemetry.js +374 -0
- package/lib/gcpOpenTelemetry.js.map +1 -0
- package/lib/gcpOpenTelemetry.mjs +364 -0
- package/lib/gcpOpenTelemetry.mjs.map +1 -0
- package/lib/index.d.mts +36 -0
- package/lib/index.d.ts +36 -0
- package/lib/index.js +56 -0
- package/lib/index.js.map +1 -0
- package/lib/index.mjs +29 -0
- package/lib/index.mjs.map +1 -0
- package/lib/metrics.d.mts +65 -0
- package/lib/metrics.d.ts +65 -0
- package/lib/metrics.js +91 -0
- package/lib/metrics.js.map +1 -0
- package/lib/metrics.mjs +65 -0
- package/lib/metrics.mjs.map +1 -0
- package/lib/model-armor.d.mts +59 -0
- package/lib/model-armor.d.ts +59 -0
- package/lib/model-armor.js +205 -0
- package/lib/model-armor.js.map +1 -0
- package/lib/model-armor.mjs +181 -0
- package/lib/model-armor.mjs.map +1 -0
- package/lib/telemetry/action.d.mts +27 -0
- package/lib/telemetry/action.d.ts +27 -0
- package/lib/telemetry/action.js +92 -0
- package/lib/telemetry/action.js.map +1 -0
- package/lib/telemetry/action.mjs +73 -0
- package/lib/telemetry/action.mjs.map +1 -0
- package/lib/telemetry/defaults.d.mts +30 -0
- package/lib/telemetry/defaults.d.ts +30 -0
- package/lib/telemetry/defaults.js +70 -0
- package/lib/telemetry/defaults.js.map +1 -0
- package/lib/telemetry/defaults.mjs +46 -0
- package/lib/telemetry/defaults.mjs.map +1 -0
- package/lib/telemetry/engagement.d.mts +35 -0
- package/lib/telemetry/engagement.d.ts +35 -0
- package/lib/telemetry/engagement.js +106 -0
- package/lib/telemetry/engagement.js.map +1 -0
- package/lib/telemetry/engagement.mjs +85 -0
- package/lib/telemetry/engagement.mjs.map +1 -0
- package/lib/telemetry/feature.d.mts +35 -0
- package/lib/telemetry/feature.d.ts +35 -0
- package/lib/telemetry/feature.js +142 -0
- package/lib/telemetry/feature.js.map +1 -0
- package/lib/telemetry/feature.mjs +127 -0
- package/lib/telemetry/feature.mjs.map +1 -0
- package/lib/telemetry/generate.d.mts +53 -0
- package/lib/telemetry/generate.d.ts +53 -0
- package/lib/telemetry/generate.js +326 -0
- package/lib/telemetry/generate.js.map +1 -0
- package/lib/telemetry/generate.mjs +314 -0
- package/lib/telemetry/generate.mjs.map +1 -0
- package/lib/telemetry/path.d.mts +32 -0
- package/lib/telemetry/path.d.ts +32 -0
- package/lib/telemetry/path.js +91 -0
- package/lib/telemetry/path.js.map +1 -0
- package/lib/telemetry/path.mjs +78 -0
- package/lib/telemetry/path.mjs.map +1 -0
- package/lib/types.d.mts +121 -0
- package/lib/types.d.ts +121 -0
- package/lib/types.js +17 -0
- package/lib/types.js.map +1 -0
- package/lib/types.mjs +1 -0
- package/lib/types.mjs.map +1 -0
- package/lib/utils.d.mts +57 -0
- package/lib/utils.d.ts +57 -0
- package/lib/utils.js +143 -0
- package/lib/utils.js.map +1 -0
- package/lib/utils.mjs +104 -0
- package/lib/utils.mjs.map +1 -0
- package/package.json +89 -0
- package/src/auth.ts +89 -0
- package/src/gcpLogger.ts +124 -0
- package/src/gcpOpenTelemetry.ts +485 -0
- package/src/index.ts +59 -0
- package/src/metrics.ts +122 -0
- package/src/model-armor.ts +317 -0
- package/src/telemetry/action.ts +106 -0
- package/src/telemetry/defaults.ts +72 -0
- package/src/telemetry/engagement.ts +120 -0
- package/src/telemetry/feature.ts +170 -0
- package/src/telemetry/generate.ts +454 -0
- package/src/telemetry/path.ts +111 -0
- package/src/types.ts +133 -0
- package/src/utils.ts +175 -0
- package/tests/logs_no_input_output_test.ts +267 -0
- package/tests/logs_session_test.ts +219 -0
- package/tests/logs_test.ts +633 -0
- package/tests/metrics_test.ts +792 -0
- package/tests/model_armor_test.ts +336 -0
- package/tests/traces_test.ts +380 -0
- package/typedoc.json +3 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
import { Telemetry } from '../metrics.mjs';
|
|
3
|
+
import '@opentelemetry/api';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright 2024 Google LLC
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare class GenerateTelemetry implements Telemetry {
|
|
22
|
+
/**
|
|
23
|
+
* Wraps the declared metrics in a Genkit-specific, internal namespace.
|
|
24
|
+
*/
|
|
25
|
+
private _N;
|
|
26
|
+
private actionCounter;
|
|
27
|
+
private latencies;
|
|
28
|
+
private inputCharacters;
|
|
29
|
+
private inputTokens;
|
|
30
|
+
private inputImages;
|
|
31
|
+
private outputCharacters;
|
|
32
|
+
private outputTokens;
|
|
33
|
+
private thinkingTokens;
|
|
34
|
+
private outputImages;
|
|
35
|
+
tick(span: ReadableSpan, logInputAndOutput: boolean, projectId?: string): void;
|
|
36
|
+
private recordGenerateActionMetrics;
|
|
37
|
+
private recordGenerateActionConfigLogs;
|
|
38
|
+
private recordGenerateActionInputLogs;
|
|
39
|
+
private recordGenerateActionOutputLogs;
|
|
40
|
+
private toPartCounts;
|
|
41
|
+
private xOfY;
|
|
42
|
+
private toPartLogContent;
|
|
43
|
+
private toPartLogMedia;
|
|
44
|
+
private toPartLogToolRequest;
|
|
45
|
+
private toPartLogToolResponse;
|
|
46
|
+
/**
|
|
47
|
+
* Records all metrics associated with performing a GenerateAction.
|
|
48
|
+
*/
|
|
49
|
+
private doRecordGenerateActionMetrics;
|
|
50
|
+
}
|
|
51
|
+
declare const generateTelemetry: GenerateTelemetry;
|
|
52
|
+
|
|
53
|
+
export { generateTelemetry };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ReadableSpan } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
import { Telemetry } from '../metrics.js';
|
|
3
|
+
import '@opentelemetry/api';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright 2024 Google LLC
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare class GenerateTelemetry implements Telemetry {
|
|
22
|
+
/**
|
|
23
|
+
* Wraps the declared metrics in a Genkit-specific, internal namespace.
|
|
24
|
+
*/
|
|
25
|
+
private _N;
|
|
26
|
+
private actionCounter;
|
|
27
|
+
private latencies;
|
|
28
|
+
private inputCharacters;
|
|
29
|
+
private inputTokens;
|
|
30
|
+
private inputImages;
|
|
31
|
+
private outputCharacters;
|
|
32
|
+
private outputTokens;
|
|
33
|
+
private thinkingTokens;
|
|
34
|
+
private outputImages;
|
|
35
|
+
tick(span: ReadableSpan, logInputAndOutput: boolean, projectId?: string): void;
|
|
36
|
+
private recordGenerateActionMetrics;
|
|
37
|
+
private recordGenerateActionConfigLogs;
|
|
38
|
+
private recordGenerateActionInputLogs;
|
|
39
|
+
private recordGenerateActionOutputLogs;
|
|
40
|
+
private toPartCounts;
|
|
41
|
+
private xOfY;
|
|
42
|
+
private toPartLogContent;
|
|
43
|
+
private toPartLogMedia;
|
|
44
|
+
private toPartLogToolRequest;
|
|
45
|
+
private toPartLogToolResponse;
|
|
46
|
+
/**
|
|
47
|
+
* Records all metrics associated with performing a GenerateAction.
|
|
48
|
+
*/
|
|
49
|
+
private doRecordGenerateActionMetrics;
|
|
50
|
+
}
|
|
51
|
+
declare const generateTelemetry: GenerateTelemetry;
|
|
52
|
+
|
|
53
|
+
export { generateTelemetry };
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var generate_exports = {};
|
|
20
|
+
__export(generate_exports, {
|
|
21
|
+
generateTelemetry: () => generateTelemetry
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(generate_exports);
|
|
24
|
+
var import_api = require("@opentelemetry/api");
|
|
25
|
+
var import_crypto = require("crypto");
|
|
26
|
+
var import_genkit = require("genkit");
|
|
27
|
+
var import_logging = require("genkit/logging");
|
|
28
|
+
var import_tracing = require("genkit/tracing");
|
|
29
|
+
var import_metrics = require("../metrics.js");
|
|
30
|
+
var import_utils = require("../utils.js");
|
|
31
|
+
class GenerateTelemetry {
|
|
32
|
+
/**
|
|
33
|
+
* Wraps the declared metrics in a Genkit-specific, internal namespace.
|
|
34
|
+
*/
|
|
35
|
+
_N = import_metrics.internalMetricNamespaceWrap.bind(null, "ai");
|
|
36
|
+
actionCounter = new import_metrics.MetricCounter(this._N("generate/requests"), {
|
|
37
|
+
description: "Counts calls to genkit generate actions.",
|
|
38
|
+
valueType: import_api.ValueType.INT
|
|
39
|
+
});
|
|
40
|
+
latencies = new import_metrics.MetricHistogram(this._N("generate/latency"), {
|
|
41
|
+
description: "Latencies when interacting with a Genkit model.",
|
|
42
|
+
valueType: import_api.ValueType.DOUBLE,
|
|
43
|
+
unit: "ms"
|
|
44
|
+
});
|
|
45
|
+
inputCharacters = new import_metrics.MetricCounter(
|
|
46
|
+
this._N("generate/input/characters"),
|
|
47
|
+
{
|
|
48
|
+
description: "Counts input characters to any Genkit model.",
|
|
49
|
+
valueType: import_api.ValueType.INT
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
inputTokens = new import_metrics.MetricCounter(this._N("generate/input/tokens"), {
|
|
53
|
+
description: "Counts input tokens to a Genkit model.",
|
|
54
|
+
valueType: import_api.ValueType.INT
|
|
55
|
+
});
|
|
56
|
+
inputImages = new import_metrics.MetricCounter(this._N("generate/input/images"), {
|
|
57
|
+
description: "Counts input images to a Genkit model.",
|
|
58
|
+
valueType: import_api.ValueType.INT
|
|
59
|
+
});
|
|
60
|
+
outputCharacters = new import_metrics.MetricCounter(
|
|
61
|
+
this._N("generate/output/characters"),
|
|
62
|
+
{
|
|
63
|
+
description: "Counts output characters from a Genkit model.",
|
|
64
|
+
valueType: import_api.ValueType.INT
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
outputTokens = new import_metrics.MetricCounter(this._N("generate/output/tokens"), {
|
|
68
|
+
description: "Counts output tokens from a Genkit model.",
|
|
69
|
+
valueType: import_api.ValueType.INT
|
|
70
|
+
});
|
|
71
|
+
thinkingTokens = new import_metrics.MetricCounter(
|
|
72
|
+
this._N("generate/thinking/tokens"),
|
|
73
|
+
{
|
|
74
|
+
description: "Counts thinking tokens from a Genkit model.",
|
|
75
|
+
valueType: import_api.ValueType.INT
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
outputImages = new import_metrics.MetricCounter(this._N("generate/output/images"), {
|
|
79
|
+
description: "Count output images from a Genkit model.",
|
|
80
|
+
valueType: import_api.ValueType.INT
|
|
81
|
+
});
|
|
82
|
+
tick(span, logInputAndOutput, projectId) {
|
|
83
|
+
const attributes = span.attributes;
|
|
84
|
+
const modelName = (0, import_utils.truncate)(attributes["genkit:name"], 1024);
|
|
85
|
+
const path = attributes["genkit:path"] || "";
|
|
86
|
+
const input = "genkit:input" in attributes ? JSON.parse(
|
|
87
|
+
attributes["genkit:input"]
|
|
88
|
+
) : void 0;
|
|
89
|
+
const output = "genkit:output" in attributes ? JSON.parse(
|
|
90
|
+
attributes["genkit:output"]
|
|
91
|
+
) : void 0;
|
|
92
|
+
const errName = (0, import_utils.extractErrorName)(span.events);
|
|
93
|
+
let featureName = (0, import_utils.truncate)(
|
|
94
|
+
attributes["genkit:metadata:flow:name"] || (0, import_utils.extractOuterFeatureNameFromPath)(path)
|
|
95
|
+
);
|
|
96
|
+
if (!featureName || featureName === "<unknown>") {
|
|
97
|
+
featureName = "generate";
|
|
98
|
+
}
|
|
99
|
+
const sessionId = attributes["genkit:sessionId"];
|
|
100
|
+
const threadName = attributes["genkit:threadName"];
|
|
101
|
+
if (input) {
|
|
102
|
+
this.recordGenerateActionMetrics(modelName, featureName, path, {
|
|
103
|
+
response: output,
|
|
104
|
+
errName
|
|
105
|
+
});
|
|
106
|
+
this.recordGenerateActionConfigLogs(
|
|
107
|
+
span,
|
|
108
|
+
modelName,
|
|
109
|
+
featureName,
|
|
110
|
+
path,
|
|
111
|
+
input,
|
|
112
|
+
projectId,
|
|
113
|
+
sessionId,
|
|
114
|
+
threadName
|
|
115
|
+
);
|
|
116
|
+
if (logInputAndOutput) {
|
|
117
|
+
this.recordGenerateActionInputLogs(
|
|
118
|
+
span,
|
|
119
|
+
modelName,
|
|
120
|
+
featureName,
|
|
121
|
+
path,
|
|
122
|
+
input,
|
|
123
|
+
projectId,
|
|
124
|
+
sessionId,
|
|
125
|
+
threadName
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (output && logInputAndOutput) {
|
|
130
|
+
this.recordGenerateActionOutputLogs(
|
|
131
|
+
span,
|
|
132
|
+
modelName,
|
|
133
|
+
featureName,
|
|
134
|
+
path,
|
|
135
|
+
output,
|
|
136
|
+
projectId,
|
|
137
|
+
sessionId,
|
|
138
|
+
threadName
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
recordGenerateActionMetrics(modelName, featureName, path, opts) {
|
|
143
|
+
this.doRecordGenerateActionMetrics(modelName, opts.response?.usage || {}, {
|
|
144
|
+
featureName,
|
|
145
|
+
path,
|
|
146
|
+
latencyMs: opts.response?.latencyMs,
|
|
147
|
+
errName: opts.errName,
|
|
148
|
+
source: "ts",
|
|
149
|
+
sourceVersion: import_genkit.GENKIT_VERSION
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
recordGenerateActionConfigLogs(span, model, featureName, qualifiedPath, input, projectId, sessionId, threadName) {
|
|
153
|
+
const path = (0, import_utils.truncatePath)((0, import_tracing.toDisplayPath)(qualifiedPath));
|
|
154
|
+
const sharedMetadata = {
|
|
155
|
+
...(0, import_utils.createCommonLogAttributes)(span, projectId),
|
|
156
|
+
model,
|
|
157
|
+
path,
|
|
158
|
+
qualifiedPath,
|
|
159
|
+
featureName,
|
|
160
|
+
sessionId,
|
|
161
|
+
threadName
|
|
162
|
+
};
|
|
163
|
+
import_logging.logger.logStructured(`Config[${path}, ${model}]`, {
|
|
164
|
+
...sharedMetadata,
|
|
165
|
+
maxOutputTokens: input.config?.maxOutputTokens,
|
|
166
|
+
stopSequences: input.config?.stopSequences,
|
|
167
|
+
// array
|
|
168
|
+
source: "ts",
|
|
169
|
+
sourceVersion: import_genkit.GENKIT_VERSION
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
recordGenerateActionInputLogs(span, model, featureName, qualifiedPath, input, projectId, sessionId, threadName) {
|
|
173
|
+
const path = (0, import_utils.truncatePath)((0, import_tracing.toDisplayPath)(qualifiedPath));
|
|
174
|
+
const sharedMetadata = {
|
|
175
|
+
...(0, import_utils.createCommonLogAttributes)(span, projectId),
|
|
176
|
+
model,
|
|
177
|
+
path,
|
|
178
|
+
qualifiedPath,
|
|
179
|
+
featureName,
|
|
180
|
+
sessionId,
|
|
181
|
+
threadName
|
|
182
|
+
};
|
|
183
|
+
const messages = input.messages.length;
|
|
184
|
+
input.messages.forEach((msg, msgIdx) => {
|
|
185
|
+
const parts = msg.content.length;
|
|
186
|
+
msg.content.forEach((part, partIdx) => {
|
|
187
|
+
const partCounts = this.toPartCounts(partIdx, parts, msgIdx, messages);
|
|
188
|
+
import_logging.logger.logStructured(`Input[${path}, ${model}] ${partCounts}`, {
|
|
189
|
+
...sharedMetadata,
|
|
190
|
+
content: this.toPartLogContent(part),
|
|
191
|
+
role: msg.role,
|
|
192
|
+
partIndex: partIdx,
|
|
193
|
+
totalParts: parts,
|
|
194
|
+
messageIndex: msgIdx,
|
|
195
|
+
totalMessages: messages
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
recordGenerateActionOutputLogs(span, model, featureName, qualifiedPath, output, projectId, sessionId, threadName) {
|
|
201
|
+
const path = (0, import_utils.truncatePath)((0, import_tracing.toDisplayPath)(qualifiedPath));
|
|
202
|
+
const sharedMetadata = {
|
|
203
|
+
...(0, import_utils.createCommonLogAttributes)(span, projectId),
|
|
204
|
+
model,
|
|
205
|
+
path,
|
|
206
|
+
qualifiedPath,
|
|
207
|
+
featureName,
|
|
208
|
+
sessionId,
|
|
209
|
+
threadName
|
|
210
|
+
};
|
|
211
|
+
const message = output.message || output.candidates?.[0]?.message;
|
|
212
|
+
if (message?.content) {
|
|
213
|
+
const parts = message.content.length;
|
|
214
|
+
message.content.forEach((part, partIdx) => {
|
|
215
|
+
const partCounts = this.toPartCounts(partIdx, parts, 0, 1);
|
|
216
|
+
const initial = output.finishMessage ? { finishMessage: (0, import_utils.truncate)(output.finishMessage) } : {};
|
|
217
|
+
import_logging.logger.logStructured(`Output[${path}, ${model}] ${partCounts}`, {
|
|
218
|
+
...initial,
|
|
219
|
+
...sharedMetadata,
|
|
220
|
+
content: this.toPartLogContent(part),
|
|
221
|
+
role: message.role,
|
|
222
|
+
partIndex: partIdx,
|
|
223
|
+
totalParts: parts,
|
|
224
|
+
candidateIndex: 0,
|
|
225
|
+
totalCandidates: 1,
|
|
226
|
+
messageIndex: 0,
|
|
227
|
+
finishReason: output.finishReason
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
toPartCounts(partOrdinal, parts, msgOrdinal, messages) {
|
|
233
|
+
if (parts > 1 && messages > 1) {
|
|
234
|
+
return `(part ${this.xOfY(partOrdinal, parts)} in message ${this.xOfY(
|
|
235
|
+
msgOrdinal,
|
|
236
|
+
messages
|
|
237
|
+
)})`;
|
|
238
|
+
}
|
|
239
|
+
if (parts > 1) {
|
|
240
|
+
return `(part ${this.xOfY(partOrdinal, parts)})`;
|
|
241
|
+
}
|
|
242
|
+
if (messages > 1) {
|
|
243
|
+
return `(message ${this.xOfY(msgOrdinal, messages)})`;
|
|
244
|
+
}
|
|
245
|
+
return "";
|
|
246
|
+
}
|
|
247
|
+
xOfY(x, y) {
|
|
248
|
+
return `${x + 1} of ${y}`;
|
|
249
|
+
}
|
|
250
|
+
toPartLogContent(part) {
|
|
251
|
+
if (part.text) {
|
|
252
|
+
return (0, import_utils.truncate)(part.text);
|
|
253
|
+
}
|
|
254
|
+
if (part.data) {
|
|
255
|
+
return (0, import_utils.truncate)(JSON.stringify(part.data));
|
|
256
|
+
}
|
|
257
|
+
if (part.media) {
|
|
258
|
+
return this.toPartLogMedia(part);
|
|
259
|
+
}
|
|
260
|
+
if (part.toolRequest) {
|
|
261
|
+
return this.toPartLogToolRequest(part);
|
|
262
|
+
}
|
|
263
|
+
if (part.toolResponse) {
|
|
264
|
+
return this.toPartLogToolResponse(part);
|
|
265
|
+
}
|
|
266
|
+
if (part.custom) {
|
|
267
|
+
return (0, import_utils.truncate)(JSON.stringify(part.custom));
|
|
268
|
+
}
|
|
269
|
+
return "<unknown format>";
|
|
270
|
+
}
|
|
271
|
+
toPartLogMedia(part) {
|
|
272
|
+
if (part.media.url.startsWith("data:")) {
|
|
273
|
+
const splitIdx = part.media.url.indexOf("base64,");
|
|
274
|
+
if (splitIdx < 0) {
|
|
275
|
+
return "<unknown media format>";
|
|
276
|
+
}
|
|
277
|
+
const prefix = part.media.url.substring(0, splitIdx + 7);
|
|
278
|
+
const hashedContent = (0, import_crypto.createHash)("sha256").update(part.media.url.substring(splitIdx + 7)).digest("hex");
|
|
279
|
+
return `${prefix}<sha256(${hashedContent})>`;
|
|
280
|
+
}
|
|
281
|
+
return (0, import_utils.truncate)(part.media.url);
|
|
282
|
+
}
|
|
283
|
+
toPartLogToolRequest(part) {
|
|
284
|
+
const inputText = typeof part.toolRequest.input === "string" ? part.toolRequest.input : JSON.stringify(part.toolRequest.input);
|
|
285
|
+
return (0, import_utils.truncate)(
|
|
286
|
+
`Tool request: ${part.toolRequest.name}, ref: ${part.toolRequest.ref}, input: ${inputText}`
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
toPartLogToolResponse(part) {
|
|
290
|
+
const outputText = typeof part.toolResponse.output === "string" ? part.toolResponse.output : JSON.stringify(part.toolResponse.output);
|
|
291
|
+
return (0, import_utils.truncate)(
|
|
292
|
+
`Tool response: ${part.toolResponse.name}, ref: ${part.toolResponse.ref}, output: ${outputText}`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Records all metrics associated with performing a GenerateAction.
|
|
297
|
+
*/
|
|
298
|
+
doRecordGenerateActionMetrics(modelName, usage, dimensions) {
|
|
299
|
+
const shared = {
|
|
300
|
+
modelName,
|
|
301
|
+
featureName: dimensions.featureName,
|
|
302
|
+
path: dimensions.path,
|
|
303
|
+
source: dimensions.source,
|
|
304
|
+
sourceVersion: dimensions.sourceVersion,
|
|
305
|
+
status: dimensions.errName ? "failure" : "success"
|
|
306
|
+
};
|
|
307
|
+
this.actionCounter.add(1, {
|
|
308
|
+
error: dimensions.errName,
|
|
309
|
+
...shared
|
|
310
|
+
});
|
|
311
|
+
this.latencies.record(dimensions.latencyMs, shared);
|
|
312
|
+
this.inputTokens.add(usage.inputTokens, shared);
|
|
313
|
+
this.inputCharacters.add(usage.inputCharacters, shared);
|
|
314
|
+
this.inputImages.add(usage.inputImages, shared);
|
|
315
|
+
this.outputTokens.add(usage.outputTokens, shared);
|
|
316
|
+
this.outputCharacters.add(usage.outputCharacters, shared);
|
|
317
|
+
this.outputImages.add(usage.outputImages, shared);
|
|
318
|
+
this.thinkingTokens.add(usage.thoughtsTokens, shared);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const generateTelemetry = new GenerateTelemetry();
|
|
322
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
323
|
+
0 && (module.exports = {
|
|
324
|
+
generateTelemetry
|
|
325
|
+
});
|
|
326
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/telemetry/generate.ts"],"sourcesContent":["/**\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ValueType } from '@opentelemetry/api';\nimport type { ReadableSpan } from '@opentelemetry/sdk-trace-base';\nimport { createHash } from 'crypto';\nimport {\n GENKIT_VERSION,\n type GenerateRequestData,\n type GenerateResponseData,\n type GenerationUsage,\n type MediaPart,\n type Part,\n type ToolRequestPart,\n type ToolResponsePart,\n} from 'genkit';\nimport { logger } from 'genkit/logging';\nimport { toDisplayPath } from 'genkit/tracing';\nimport {\n MetricCounter,\n MetricHistogram,\n internalMetricNamespaceWrap,\n type Telemetry,\n} from '../metrics.js';\nimport {\n createCommonLogAttributes,\n extractErrorName,\n extractOuterFeatureNameFromPath,\n truncate,\n truncatePath,\n} from '../utils.js';\n\ntype SharedDimensions = {\n modelName?: string;\n featureName?: string;\n path?: string;\n status?: string;\n source?: string;\n sourceVersion?: string;\n};\n\nclass GenerateTelemetry implements Telemetry {\n /**\n * Wraps the declared metrics in a Genkit-specific, internal namespace.\n */\n private _N = internalMetricNamespaceWrap.bind(null, 'ai');\n\n private actionCounter = new MetricCounter(this._N('generate/requests'), {\n description: 'Counts calls to genkit generate actions.',\n valueType: ValueType.INT,\n });\n\n private latencies = new MetricHistogram(this._N('generate/latency'), {\n description: 'Latencies when interacting with a Genkit model.',\n valueType: ValueType.DOUBLE,\n unit: 'ms',\n });\n\n private inputCharacters = new MetricCounter(\n this._N('generate/input/characters'),\n {\n description: 'Counts input characters to any Genkit model.',\n valueType: ValueType.INT,\n }\n );\n\n private inputTokens = new MetricCounter(this._N('generate/input/tokens'), {\n description: 'Counts input tokens to a Genkit model.',\n valueType: ValueType.INT,\n });\n\n private inputImages = new MetricCounter(this._N('generate/input/images'), {\n description: 'Counts input images to a Genkit model.',\n valueType: ValueType.INT,\n });\n\n private outputCharacters = new MetricCounter(\n this._N('generate/output/characters'),\n {\n description: 'Counts output characters from a Genkit model.',\n valueType: ValueType.INT,\n }\n );\n\n private outputTokens = new MetricCounter(this._N('generate/output/tokens'), {\n description: 'Counts output tokens from a Genkit model.',\n valueType: ValueType.INT,\n });\n\n private thinkingTokens = new MetricCounter(\n this._N('generate/thinking/tokens'),\n {\n description: 'Counts thinking tokens from a Genkit model.',\n valueType: ValueType.INT,\n }\n );\n\n private outputImages = new MetricCounter(this._N('generate/output/images'), {\n description: 'Count output images from a Genkit model.',\n valueType: ValueType.INT,\n });\n\n tick(\n span: ReadableSpan,\n logInputAndOutput: boolean,\n projectId?: string\n ): void {\n const attributes = span.attributes;\n const modelName = truncate(attributes['genkit:name'] as string, 1024);\n const path = (attributes['genkit:path'] as string) || '';\n const input =\n 'genkit:input' in attributes\n ? (JSON.parse(\n attributes['genkit:input']! as string\n ) as GenerateRequestData)\n : undefined;\n const output =\n 'genkit:output' in attributes\n ? (JSON.parse(\n attributes['genkit:output']! as string\n ) as GenerateResponseData)\n : undefined;\n\n const errName = extractErrorName(span.events);\n let featureName = truncate(\n (attributes['genkit:metadata:flow:name'] ||\n extractOuterFeatureNameFromPath(path)) as string\n );\n if (!featureName || featureName === '<unknown>') {\n featureName = 'generate';\n }\n\n const sessionId = attributes['genkit:sessionId'] as string;\n const threadName = attributes['genkit:threadName'] as string;\n\n if (input) {\n this.recordGenerateActionMetrics(modelName, featureName, path, {\n response: output,\n errName,\n });\n this.recordGenerateActionConfigLogs(\n span,\n modelName,\n featureName,\n path,\n input,\n projectId,\n sessionId,\n threadName\n );\n\n if (logInputAndOutput) {\n this.recordGenerateActionInputLogs(\n span,\n modelName,\n featureName,\n path,\n input,\n projectId,\n sessionId,\n threadName\n );\n }\n }\n\n if (output && logInputAndOutput) {\n this.recordGenerateActionOutputLogs(\n span,\n modelName,\n featureName,\n path,\n output,\n projectId,\n sessionId,\n threadName\n );\n }\n }\n\n private recordGenerateActionMetrics(\n modelName: string,\n featureName: string,\n path: string,\n opts: {\n response?: GenerateResponseData;\n errName?: string;\n }\n ) {\n this.doRecordGenerateActionMetrics(modelName, opts.response?.usage || {}, {\n featureName,\n path,\n latencyMs: opts.response?.latencyMs,\n errName: opts.errName,\n source: 'ts',\n sourceVersion: GENKIT_VERSION,\n });\n }\n\n private recordGenerateActionConfigLogs(\n span: ReadableSpan,\n model: string,\n featureName: string,\n qualifiedPath: string,\n input: GenerateRequestData,\n projectId?: string,\n sessionId?: string,\n threadName?: string\n ) {\n const path = truncatePath(toDisplayPath(qualifiedPath));\n const sharedMetadata = {\n ...createCommonLogAttributes(span, projectId),\n model,\n path,\n qualifiedPath,\n featureName,\n sessionId,\n threadName,\n };\n logger.logStructured(`Config[${path}, ${model}]`, {\n ...sharedMetadata,\n maxOutputTokens: input.config?.maxOutputTokens,\n stopSequences: input.config?.stopSequences, // array\n source: 'ts',\n sourceVersion: GENKIT_VERSION,\n });\n }\n\n private recordGenerateActionInputLogs(\n span: ReadableSpan,\n model: string,\n featureName: string,\n qualifiedPath: string,\n input: GenerateRequestData,\n projectId?: string,\n sessionId?: string,\n threadName?: string\n ) {\n const path = truncatePath(toDisplayPath(qualifiedPath));\n const sharedMetadata = {\n ...createCommonLogAttributes(span, projectId),\n model,\n path,\n qualifiedPath,\n featureName,\n sessionId,\n threadName,\n };\n\n const messages = input.messages.length;\n input.messages.forEach((msg, msgIdx) => {\n const parts = msg.content.length;\n msg.content.forEach((part, partIdx) => {\n const partCounts = this.toPartCounts(partIdx, parts, msgIdx, messages);\n logger.logStructured(`Input[${path}, ${model}] ${partCounts}`, {\n ...sharedMetadata,\n content: this.toPartLogContent(part),\n role: msg.role,\n partIndex: partIdx,\n totalParts: parts,\n messageIndex: msgIdx,\n totalMessages: messages,\n });\n });\n });\n }\n\n private recordGenerateActionOutputLogs(\n span: ReadableSpan,\n model: string,\n featureName: string,\n qualifiedPath: string,\n output: GenerateResponseData,\n projectId?: string,\n sessionId?: string,\n threadName?: string\n ) {\n const path = truncatePath(toDisplayPath(qualifiedPath));\n const sharedMetadata = {\n ...createCommonLogAttributes(span, projectId),\n model,\n path,\n qualifiedPath,\n featureName,\n sessionId,\n threadName,\n };\n const message = output.message || output.candidates?.[0]?.message!;\n\n if (message?.content) {\n const parts = message.content.length;\n message.content.forEach((part, partIdx) => {\n const partCounts = this.toPartCounts(partIdx, parts, 0, 1);\n const initial = output.finishMessage\n ? { finishMessage: truncate(output.finishMessage) }\n : {};\n logger.logStructured(`Output[${path}, ${model}] ${partCounts}`, {\n ...initial,\n ...sharedMetadata,\n content: this.toPartLogContent(part),\n role: message.role,\n partIndex: partIdx,\n totalParts: parts,\n candidateIndex: 0,\n totalCandidates: 1,\n messageIndex: 0,\n finishReason: output.finishReason,\n });\n });\n }\n }\n\n private toPartCounts(\n partOrdinal: number,\n parts: number,\n msgOrdinal: number,\n messages: number\n ): string {\n if (parts > 1 && messages > 1) {\n return `(part ${this.xOfY(partOrdinal, parts)} in message ${this.xOfY(\n msgOrdinal,\n messages\n )})`;\n }\n if (parts > 1) {\n return `(part ${this.xOfY(partOrdinal, parts)})`;\n }\n if (messages > 1) {\n return `(message ${this.xOfY(msgOrdinal, messages)})`;\n }\n return '';\n }\n\n private xOfY(x: number, y: number): string {\n return `${x + 1} of ${y}`;\n }\n\n private toPartLogContent(part: Part): string {\n if (part.text) {\n return truncate(part.text);\n }\n if (part.data) {\n return truncate(JSON.stringify(part.data));\n }\n if (part.media) {\n return this.toPartLogMedia(part);\n }\n if (part.toolRequest) {\n return this.toPartLogToolRequest(part);\n }\n if (part.toolResponse) {\n return this.toPartLogToolResponse(part);\n }\n if (part.custom) {\n return truncate(JSON.stringify(part.custom));\n }\n return '<unknown format>';\n }\n\n private toPartLogMedia(part: MediaPart): string {\n if (part.media.url.startsWith('data:')) {\n const splitIdx = part.media.url.indexOf('base64,');\n if (splitIdx < 0) {\n return '<unknown media format>';\n }\n const prefix = part.media.url.substring(0, splitIdx + 7);\n const hashedContent = createHash('sha256')\n .update(part.media.url.substring(splitIdx + 7))\n .digest('hex');\n return `${prefix}<sha256(${hashedContent})>`;\n }\n return truncate(part.media.url);\n }\n\n private toPartLogToolRequest(part: ToolRequestPart): string {\n const inputText =\n typeof part.toolRequest.input === 'string'\n ? part.toolRequest.input\n : JSON.stringify(part.toolRequest.input);\n return truncate(\n `Tool request: ${part.toolRequest.name}, ref: ${part.toolRequest.ref}, input: ${inputText}`\n );\n }\n\n private toPartLogToolResponse(part: ToolResponsePart): string {\n const outputText =\n typeof part.toolResponse.output === 'string'\n ? part.toolResponse.output\n : JSON.stringify(part.toolResponse.output);\n return truncate(\n `Tool response: ${part.toolResponse.name}, ref: ${part.toolResponse.ref}, output: ${outputText}`\n );\n }\n\n /**\n * Records all metrics associated with performing a GenerateAction.\n */\n private doRecordGenerateActionMetrics(\n modelName: string,\n usage: GenerationUsage,\n dimensions: {\n featureName?: string;\n path?: string;\n latencyMs?: number;\n errName?: string;\n source?: string;\n sourceVersion: string;\n }\n ) {\n const shared: SharedDimensions = {\n modelName: modelName,\n featureName: dimensions.featureName,\n path: dimensions.path,\n source: dimensions.source,\n sourceVersion: dimensions.sourceVersion,\n status: dimensions.errName ? 'failure' : 'success',\n };\n\n this.actionCounter.add(1, {\n error: dimensions.errName,\n ...shared,\n });\n\n this.latencies.record(dimensions.latencyMs, shared);\n\n // inputs\n this.inputTokens.add(usage.inputTokens, shared);\n this.inputCharacters.add(usage.inputCharacters, shared);\n this.inputImages.add(usage.inputImages, shared);\n\n // outputs\n this.outputTokens.add(usage.outputTokens, shared);\n this.outputCharacters.add(usage.outputCharacters, shared);\n this.outputImages.add(usage.outputImages, shared);\n\n // thoughts\n this.thinkingTokens.add(usage.thoughtsTokens, shared);\n }\n}\n\nconst generateTelemetry = new GenerateTelemetry();\nexport { generateTelemetry };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,iBAA0B;AAE1B,oBAA2B;AAC3B,oBASO;AACP,qBAAuB;AACvB,qBAA8B;AAC9B,qBAKO;AACP,mBAMO;AAWP,MAAM,kBAAuC;AAAA;AAAA;AAAA;AAAA,EAInC,KAAK,2CAA4B,KAAK,MAAM,IAAI;AAAA,EAEhD,gBAAgB,IAAI,6BAAc,KAAK,GAAG,mBAAmB,GAAG;AAAA,IACtE,aAAa;AAAA,IACb,WAAW,qBAAU;AAAA,EACvB,CAAC;AAAA,EAEO,YAAY,IAAI,+BAAgB,KAAK,GAAG,kBAAkB,GAAG;AAAA,IACnE,aAAa;AAAA,IACb,WAAW,qBAAU;AAAA,IACrB,MAAM;AAAA,EACR,CAAC;AAAA,EAEO,kBAAkB,IAAI;AAAA,IAC5B,KAAK,GAAG,2BAA2B;AAAA,IACnC;AAAA,MACE,aAAa;AAAA,MACb,WAAW,qBAAU;AAAA,IACvB;AAAA,EACF;AAAA,EAEQ,cAAc,IAAI,6BAAc,KAAK,GAAG,uBAAuB,GAAG;AAAA,IACxE,aAAa;AAAA,IACb,WAAW,qBAAU;AAAA,EACvB,CAAC;AAAA,EAEO,cAAc,IAAI,6BAAc,KAAK,GAAG,uBAAuB,GAAG;AAAA,IACxE,aAAa;AAAA,IACb,WAAW,qBAAU;AAAA,EACvB,CAAC;AAAA,EAEO,mBAAmB,IAAI;AAAA,IAC7B,KAAK,GAAG,4BAA4B;AA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