chore: record and raise problematic http protocols for each proxy (#15917)

Adds warnings to the proxy and proxy health pages on HTTP 1.1, 1.0, 0.9
protocols.


Only the performance API can return the HTTP protocol type. We already
use the performance API for latency timings, and each proxy could have
this issue.
This commit is contained in:
Steven Masley
2024-12-20 09:11:45 -06:00
committed by GitHub
parent f0e81ab455
commit 6e021b64b4
3 changed files with 41 additions and 4 deletions
+9 -1
View File
@@ -15,6 +15,11 @@ export interface ProxyLatencyReport {
latencyMS: number;
// at is when the latency was recorded.
at: Date;
/**
* nextHopProtocol can determine if HTTP/2 is being used.
* https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/nextHopProtocol
*/
nextHopProtocol?: string;
}
interface ProxyLatencyAction {
@@ -151,6 +156,7 @@ export const useProxyLatency = (
// https://developer.mozilla.org/en-US/docs/Web/API/Performance_API/Resource_timing
let latencyMS = 0;
let accurate = false;
let nextHopProtocol: string | undefined = undefined;
if (
"requestStart" in entry &&
(entry as PerformanceResourceTiming).requestStart !== 0
@@ -159,6 +165,7 @@ export const useProxyLatency = (
const timingEntry = entry as PerformanceResourceTiming;
latencyMS = timingEntry.responseStart - timingEntry.requestStart;
accurate = true;
nextHopProtocol = timingEntry.nextHopProtocol;
} else {
// This is the total duration of the request and will be off by a good margin.
// This is a fallback if the better timing is not available.
@@ -175,7 +182,8 @@ export const useProxyLatency = (
latencyMS,
accurate,
at: new Date(),
},
nextHopProtocol: nextHopProtocol,
} as ProxyLatencyReport,
};
dispatchProxyLatencies(update);
// Also save to local storage to persist the latency across page refreshes.