Skip to content

Commit a6430ad

Browse files
committed
Write logs for all action types except indexer and embedder
1 parent 079049d commit a6430ad

File tree

2 files changed

+36
-44
lines changed

2 files changed

+36
-44
lines changed

js/plugins/google-cloud/src/telemetry/action.ts

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -31,53 +31,46 @@ class ActionTelemetry implements Telemetry {
3131
logInputAndOutput: boolean,
3232
projectId?: string
3333
): void {
34-
if (!logInputAndOutput) {
35-
return;
36-
}
3734
const attributes = span.attributes;
38-
const actionName = (attributes['genkit:name'] as string) || '<unknown>';
3935
const type = attributes['genkit:type'] as string;
40-
const subtype = attributes['genkit:metadata:subtype'] as string;
36+
if (!logInputAndOutput || type === 'embedder' || type === 'indexer') {
37+
return;
38+
}
4139

42-
if (
43-
type === 'promptTemplate' ||
44-
subtype === 'tool' ||
45-
actionName === 'generate'
46-
) {
47-
const path = (attributes['genkit:path'] as string) || '<unknown>';
48-
const input = truncate(attributes['genkit:input'] as string);
49-
const output = truncate(attributes['genkit:output'] as string);
50-
const sessionId = attributes['genkit:sessionId'] as string;
51-
const threadName = attributes['genkit:threadName'] as string;
52-
let featureName = extractOuterFeatureNameFromPath(path);
53-
if (!featureName || featureName === '<unknown>') {
54-
featureName = actionName;
55-
}
40+
const actionName = (attributes['genkit:name'] as string) || '<unknown>';
41+
const path = (attributes['genkit:path'] as string) || '<unknown>';
42+
const input = truncate(attributes['genkit:input'] as string);
43+
const output = truncate(attributes['genkit:output'] as string);
44+
const sessionId = attributes['genkit:sessionId'] as string;
45+
const threadName = attributes['genkit:threadName'] as string;
46+
let featureName = extractOuterFeatureNameFromPath(path);
47+
if (!featureName || featureName === '<unknown>') {
48+
featureName = actionName;
49+
}
5650

57-
if (input) {
58-
this.writeLog(
59-
span,
60-
'Input',
61-
featureName,
62-
path,
63-
input,
64-
projectId,
65-
sessionId,
66-
threadName
67-
);
68-
}
69-
if (output) {
70-
this.writeLog(
71-
span,
72-
'Output',
73-
featureName,
74-
path,
75-
output,
76-
projectId,
77-
sessionId,
78-
threadName
79-
);
80-
}
51+
if (input) {
52+
this.writeLog(
53+
span,
54+
'Input',
55+
featureName,
56+
path,
57+
input,
58+
projectId,
59+
sessionId,
60+
threadName
61+
);
62+
}
63+
if (output) {
64+
this.writeLog(
65+
span,
66+
'Output',
67+
featureName,
68+
path,
69+
output,
70+
projectId,
71+
sessionId,
72+
threadName
73+
);
8174
}
8275
}
8376

js/plugins/google-cloud/tests/logs_test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ describe('GoogleCloudLogs', () => {
395395
await getExportedSpans();
396396

397397
const logs = await getLogs(1, 100, logLines);
398-
expect(logs.length).toEqual(9);
399398
const logObjectMessages = getStructuredLogMessages(logs);
400399
expect(logObjectMessages).toContain(
401400
'Config[testFlow > sub1 > sub2 > generate > testModel, testModel]'

0 commit comments

Comments
 (0)