Skip to content
Merged
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)
.output(z.void())
.mutation(async ({ input }) => {
return manager.addTrace(input);
}),

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