Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions genkit-tools/common/src/manager/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,17 @@ export class RuntimeManager {
return response.data as TraceData;
}

/**
* Adds a trace to the trace store
*/
async addTrace(input: TraceData): Promise<void> {
await axios
.post(`${this.telemetryServerUrl}/api/traces/`, input)
.catch((err) =>
this.httpErrorHandler(err, 'Error writing trace to store.')
);
}

/**
* Notifies the runtime of dependencies it may need (e.g. telemetry server URL).
*/
Expand Down
9 changes: 9 additions & 0 deletions genkit-tools/common/src/server/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '../eval';
import type { RuntimeManager } from '../manager/manager';
import { GenkitToolsError, type RuntimeInfo } from '../manager/types';
import { TraceDataSchema } from '../types';
import type { Action } from '../types/action';
import * as apis from '../types/apis';
import type { EnvironmentVariable } from '../types/env';
Expand Down Expand Up @@ -164,6 +165,14 @@ export const TOOLS_SERVER_ROUTER = (manager: RuntimeManager) =>
return manager.getTrace(input);
}),

/** Adds a trace to the trace store */
addTrace: loggedProcedure
.input(TraceDataSchema)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is specific for Genkit traces? The schema does not say anything Genkit specific but recent conversations with Pavel has led me to believe that there is no universal format here....

This is fine, wondering if we should surface this requirement to the user somewhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ssbushi yes that's right. these are genkit traces. Are you thinking just a comment for now? Or something more (like a specific TS type)?

.output(z.void())
.mutation(async ({ input }) => {
return manager.addTrace(input);
}),

/** Retrieves all eval run keys */
listEvalRunKeys: loggedProcedure
.input(apis.ListEvalKeysRequestSchema)
Expand Down
Loading