feat(observability): 补齐运行追踪与脱敏导出链路
This commit is contained in:
31
frontend/src/api/__tests__/observability.spec.ts
Normal file
31
frontend/src/api/__tests__/observability.spec.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import {
|
||||
exportObservabilityTrace,
|
||||
getObservabilityTrace,
|
||||
listObservabilityModelCalls,
|
||||
listObservabilityRuns,
|
||||
} from '../observability';
|
||||
import { get } from '../request';
|
||||
|
||||
vi.mock('../request', () => ({
|
||||
get: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('observability api', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('maps observability endpoints correctly', () => {
|
||||
listObservabilityRuns();
|
||||
getObservabilityTrace('req-1001');
|
||||
listObservabilityModelCalls('req-1001');
|
||||
exportObservabilityTrace('req-1001');
|
||||
|
||||
expect(get).toHaveBeenCalledWith('/observability/runs');
|
||||
expect(get).toHaveBeenCalledWith('/observability/runs/req-1001');
|
||||
expect(get).toHaveBeenCalledWith('/observability/model-calls', { params: { requestId: 'req-1001' } });
|
||||
expect(get).toHaveBeenCalledWith('/observability/runs/req-1001/export');
|
||||
});
|
||||
});
|
||||
67
frontend/src/api/observability.ts
Normal file
67
frontend/src/api/observability.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { get } from './request';
|
||||
|
||||
export interface ObservabilityRunSummary {
|
||||
runId?: string;
|
||||
workflowId?: string;
|
||||
requestId: string;
|
||||
status?: string;
|
||||
durationMs?: number;
|
||||
estimatedCost?: number;
|
||||
}
|
||||
|
||||
export interface ObservabilityStepLog {
|
||||
nodeName: string;
|
||||
nodeType?: string;
|
||||
status?: string;
|
||||
durationMs?: number;
|
||||
outputSummary?: string;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
export interface ObservabilityModelCallSummary {
|
||||
requestId: string;
|
||||
callType?: string;
|
||||
status?: string;
|
||||
totalTokens?: number;
|
||||
durationMs?: number;
|
||||
estimatedCost?: number;
|
||||
errorCode?: string;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
export interface ObservabilityTrace {
|
||||
requestId: string;
|
||||
workflowStatus?: string;
|
||||
sessionStatus?: string;
|
||||
workflowStepCount?: number;
|
||||
messageCount?: number;
|
||||
modelCallCount?: number;
|
||||
totalDurationMs?: number;
|
||||
estimatedCost?: number;
|
||||
stepLogs: ObservabilityStepLog[];
|
||||
modelCalls: ObservabilityModelCallSummary[];
|
||||
}
|
||||
|
||||
export interface ObservabilityExport {
|
||||
requestId: string;
|
||||
workflowStatus?: string;
|
||||
maskedInputJson?: string;
|
||||
maskedOutputJson?: string;
|
||||
exportSummary?: string;
|
||||
}
|
||||
|
||||
export function listObservabilityRuns() {
|
||||
return get<ObservabilityRunSummary[]>('/observability/runs');
|
||||
}
|
||||
|
||||
export function getObservabilityTrace(requestId: string) {
|
||||
return get<ObservabilityTrace>(`/observability/runs/${requestId}`);
|
||||
}
|
||||
|
||||
export function listObservabilityModelCalls(requestId: string) {
|
||||
return get<ObservabilityModelCallSummary[]>('/observability/model-calls', { params: { requestId } });
|
||||
}
|
||||
|
||||
export function exportObservabilityTrace(requestId: string) {
|
||||
return get<ObservabilityExport>(`/observability/runs/${requestId}/export`);
|
||||
}
|
||||
Reference in New Issue
Block a user