complete performance and reliability follow-ups

This commit is contained in:
2026-08-09 23:04:36 +05:30
parent 8f19a5eb2b
commit 232d8e6734
31 changed files with 525 additions and 726 deletions
@@ -81,6 +81,22 @@ describe("production observability operations", () => {
expect(failures).toHaveLength(1);
});
test("reports exporter failures through the non-recursive diagnostic hook", async () => {
const diagnostics: Array<{ message: string; error: unknown }> = [];
const ctx = createContext(
new Request("https://example.test/"),
new URL("https://example.test/"),
);
const middleware = traceMiddleware({
random: (target) => target.fill(8),
exporter: { export: () => Promise.reject(new Error("offline")) },
diagnostic: (message, error) => diagnostics.push({ message, error }),
});
expect((await middleware(ctx, () => new Response("ok"))).status).toBe(200);
expect(diagnostics).toHaveLength(1);
expect(diagnostics[0]?.message).toBe("trace export failed");
});
test("exports OTLP JSON traces and metrics", async () => {
const requests: unknown[] = [];
const send = (async (_url: URL | RequestInfo, init?: RequestInit) => {