complete performance and reliability follow-ups
This commit is contained in:
@@ -93,4 +93,14 @@ describe("observability integrations", () => {
|
||||
expect(await profile("render", () => "ok")).toBe("ok");
|
||||
expect(profiles[0]).toMatchObject({ name: "render", durationMs: 4 });
|
||||
});
|
||||
|
||||
test("operation exporter failures reach diagnostics without recursive telemetry", async () => {
|
||||
const diagnostics: string[] = [];
|
||||
const tracer = createOperationTracer({
|
||||
exporter: { export: () => Promise.reject(new Error("offline")) },
|
||||
diagnostic: (message) => diagnostics.push(message),
|
||||
});
|
||||
await expect(tracer.span("database", "query", async () => 1)).resolves.toBe(1);
|
||||
expect(diagnostics).toEqual(["operation span export failed"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,6 +8,8 @@ describe("@wrnexus/observability", () => {
|
||||
expect(client).toContain('addEventListener("pagehide", flush');
|
||||
expect(client).not.toContain('send("INP",max)');
|
||||
expect(client).not.toContain('send("LCP", last.startTime)');
|
||||
expect(client).toContain("web-vitals delivery failed");
|
||||
expect(client).toContain("PerformanceObserver unavailable for");
|
||||
});
|
||||
|
||||
test("records deterministic counters and histograms", () => {
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user