fix(telemetry): keep a never-sent unauthenticated request out of api.request.failed (03-07)
With no credential V3 sends nothing and returns UNAUTHENTICATED without a status, yet it was counted as an API failure, so signed-out states raised the failure rate. Diagnostics still record it once; telemetry does not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
84effd0cd8
commit
f329cc8042
@@ -51,7 +51,9 @@ vendor 결정 전에는 안전한 기본값이 아니다.
|
||||
key와 닫힌 value policy를 contract·fixture·이 ADR에 동시에 추가한 뒤에만
|
||||
전달한다.
|
||||
5-2. caller cancellation과 scope fence는 API failure가 아니다. diagnostics는 한
|
||||
번 남기고 `api.request.failed`는 발행하지 않는다.
|
||||
번 남기고 `api.request.failed`는 발행하지 않는다. 자격증명이 없어 한 번도
|
||||
보내지 않은 `UNAUTHENTICATED`(응답 status 없음)도 같다(03-07,
|
||||
`src/bootstrap/runtime-adapters.ts` `isTerminalNonAbortFailure`).
|
||||
5-3. `routeId`는 installed operation-executor 경계의 필수 입력이다. feature
|
||||
gateway가 소유한 low-cardinality route identity를 URL에서 재구성하지 않는다.
|
||||
6. `app.boot.failed`, `ui.render.failed`, `release.mismatch.detected`,
|
||||
|
||||
@@ -285,6 +285,13 @@ function isTerminalNonAbortFailure(
|
||||
): boolean {
|
||||
if (observation.outcome === "SUCCESS") return false;
|
||||
if (observation.outcome === "CANCELLED") return false;
|
||||
// 03-07. No credential, nothing sent: a client state, not an API failure.
|
||||
if (
|
||||
observation.outcome === "UNAUTHENTICATED" &&
|
||||
observation.status === undefined
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
observation.cancellationOwner !== undefined &&
|
||||
CALLER_OWNED_CANCELLATION.has(observation.cancellationOwner)
|
||||
|
||||
@@ -210,6 +210,44 @@ describe("V3 HTTP observability projection", () => {
|
||||
expect(JSON.stringify(sinks.telemetry)).not.toContain("server-ref-7");
|
||||
});
|
||||
|
||||
it("keeps a never-sent unauthenticated request out of telemetry (03-07)", async () => {
|
||||
const sinks = recordingSinks();
|
||||
const fetcher = vi.fn();
|
||||
const executor = createContractHttpExecutor({
|
||||
baseUrl: "https://api.example/",
|
||||
maxRetryAttempts: 0,
|
||||
attachCredentials: () => ({ kind: "UNAUTHENTICATED" as const }),
|
||||
fetcher: fetcher as unknown as typeof fetch,
|
||||
observe: sinks.projector,
|
||||
});
|
||||
|
||||
const outcome = await executor.execute(
|
||||
TEST_LIST_HTTP_CONTRACT,
|
||||
{ limit: 5 },
|
||||
{ routeId: ROUTE_ID, scope: scopeSnapshot() },
|
||||
);
|
||||
|
||||
expect(outcome.kind).toBe("UNAUTHENTICATED");
|
||||
expect(fetcher).not.toHaveBeenCalled();
|
||||
expect(sinks.diagnostics).toHaveLength(1);
|
||||
expect(sinks.telemetry).toHaveLength(0);
|
||||
|
||||
// A server 401 is still an API failure.
|
||||
const answered = recordingSinks();
|
||||
await createContractHttpExecutor({
|
||||
baseUrl: "https://api.example/",
|
||||
maxRetryAttempts: 0,
|
||||
attachCredentials: () => ({ kind: "READY" as const, headers: {} }),
|
||||
fetcher: (async () => new Response(null, { status: 401 })) as unknown as typeof fetch,
|
||||
observe: answered.projector,
|
||||
}).execute(
|
||||
TEST_LIST_HTTP_CONTRACT,
|
||||
{ limit: 5 },
|
||||
{ routeId: ROUTE_ID, scope: scopeSnapshot() },
|
||||
);
|
||||
expect(answered.telemetry).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("does not emit failure telemetry for caller cancellation or scope fencing", async () => {
|
||||
const cancelled = recordingSinks();
|
||||
const callerController = new AbortController();
|
||||
|
||||
Reference in New Issue
Block a user