perf(qa): isolate OTEL model-call test imports (#127420)

This commit is contained in:
Peter Steinberger
2026-08-21 12:33:02 -07:00
committed by GitHub
parent 61842af8c5
commit b9ebfeb950
3 changed files with 35 additions and 37 deletions
@@ -33,10 +33,8 @@ import {
waitForDiagnosticEventsDrained,
} from "openclaw/plugin-sdk/diagnostic-runtime";
import { afterEach, beforeEach, expect, test, vi } from "vitest";
import {
runModelCallAndCaptureTraceparent,
startLocalOtlpReceiver,
} from "../../../test/e2e/qa-lab/runtime/otel-test-support.js";
import { runModelCallAndCaptureTraceparent } from "../../../test/e2e/qa-lab/runtime/otel-model-call.test-support.js";
import { startLocalOtlpReceiver } from "../../../test/e2e/qa-lab/runtime/otel-test-support.js";
import { createDiagnosticsOtelService } from "./service.js";
import {
createOtelContext,
@@ -0,0 +1,33 @@
import type { StreamFn } from "openclaw/plugin-sdk/agent-core";
import type { DiagnosticTraceContext } from "openclaw/plugin-sdk/diagnostic-runtime";
import { wrapStreamFnWithDiagnosticModelCallEvents } from "../../../../src/agents/embedded-agent-runner/run/attempt.model-diagnostic-events.js";
export function runModelCallAndCaptureTraceparent(params: {
trace: DiagnosticTraceContext;
runId: string;
callId: string;
provider: string;
model: string;
}): string | undefined {
let outboundTraceparent: string | undefined;
const wrapped = wrapStreamFnWithDiagnosticModelCallEvents(
((
_model: Parameters<StreamFn>[0],
_context: Parameters<StreamFn>[1],
options: Parameters<StreamFn>[2],
) => {
outboundTraceparent = options?.headers?.traceparent;
return undefined as never;
}) as StreamFn,
{
runId: params.runId,
provider: params.provider,
model: params.model,
trace: params.trace,
nextCallId: () => params.callId,
suppressPluginHooks: true,
},
);
void wrapped({} as never, {} as never);
return outboundTraceparent;
}
@@ -1,9 +1,6 @@
import { createServer, type IncomingMessage, type ServerResponse } from "node:http";
import { Socket } from "node:net";
import { gunzipSync } from "node:zlib";
import type { StreamFn } from "openclaw/plugin-sdk/agent-core";
import type { DiagnosticTraceContext } from "openclaw/plugin-sdk/diagnostic-runtime";
import { wrapStreamFnWithDiagnosticModelCallEvents } from "../../../../src/agents/embedded-agent-runner/run/attempt.model-diagnostic-events.js";
export type OtlpSignal = "logs" | "metrics" | "traces";
@@ -116,36 +113,6 @@ export function createRecentTraceSummary() {
};
}
export function runModelCallAndCaptureTraceparent(params: {
trace: DiagnosticTraceContext;
runId: string;
callId: string;
provider: string;
model: string;
}): string | undefined {
let outboundTraceparent: string | undefined;
const wrapped = wrapStreamFnWithDiagnosticModelCallEvents(
((
_model: Parameters<StreamFn>[0],
_context: Parameters<StreamFn>[1],
options: Parameters<StreamFn>[2],
) => {
outboundTraceparent = options?.headers?.traceparent;
return undefined as never;
}) as StreamFn,
{
runId: params.runId,
provider: params.provider,
model: params.model,
trace: params.trace,
nextCallId: () => params.callId,
suppressPluginHooks: true,
},
);
void wrapped({} as never, {} as never);
return outboundTraceparent;
}
const OTLP_SIGNAL_PATHS = new Map<string, OtlpSignal>([
["/v1/traces", "traces"],
["/v1/metrics", "metrics"],