feat(relay): enrich request lifecycle telemetry for retries and outcomes

This commit is contained in:
2026-03-24 12:54:07 +00:00
parent 0faf79945f
commit 1ba0cbe8a9
3 changed files with 205 additions and 5 deletions
+41
View File
@@ -1222,3 +1222,44 @@ Validation:
Follow-ups:
- Optional next iteration: add a PR template block in Azure DevOps mirroring the runbook governance gate checklist.
---
### CL-033: TASK22242 relay telemetry enrichment (lifecycle events + correlation fields)
date: 2026-03-24
author: Cline
scope: `pages/api/middleware/relayForwarding.js`, `tests/phase21/relay-forwarding-hardening.test.cjs`
type: change
rationale: Add richer relay observability so operations can correlate retries and outcomes per request and track latency/status patterns without changing endpoint contracts.
impact: Improves operational diagnostics and trend analysis for relay traffic while preserving existing API behavior.
status: completed
Summary:
- Enriched relay middleware telemetry with request lifecycle events:
- `relay_request_started`
- `relay_request_retrying`
- `relay_request_succeeded`
- `relay_request_failed`
- Added shared telemetry fields for correlation and analysis:
- `relayRequestId` (per request correlation id)
- `attemptsMade`, `retryCountUsed`, `remainingRetries`
- `elapsedMs`
- `statusClass` (`2xx/4xx/5xx` style buckets)
- resolved runtime knobs included at start event
- Kept existing retry policy and endpoint response contracts unchanged.
- Expanded phase21 relay hardening tests to assert telemetry behavior:
- started/retrying/succeeded event presence
- failed event telemetry fields
- stable `relayRequestId` across lifecycle events for one request
Validation:
- `node tests/phase21/relay-forwarding-hardening.test.cjs` -> pass (7/7)
- `node tests/phase21/endpoint-handler-contract.test.cjs` -> pass (152/152)
- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
Follow-ups:
- Optional next step: map these lifecycle fields into central dashboards/alerts (retry rate, status-class distribution, p95 elapsedMs).