fix(monitoring): stop allocating route metrics to domains when no request data exists

This commit is contained in:
2026-04-13 19:15:46 +00:00
parent 835537f789
commit cdc77305e5
4 changed files with 9 additions and 16 deletions

View File

@@ -806,20 +806,7 @@ export class MetricsManager {
const tp = throughputByRoute.get(routeName) || { in: 0, out: 0 };
const routeTotal = routeTotalRequests.get(routeName) || 0;
// Proportional share based on actual request counts
// Fall back to equal split only when no request data exists
let share: number;
if (routeTotal > 0 && domainReqs > 0) {
share = domainReqs / routeTotal;
} else {
// Count how many resolved domains share this route
let domainsInRoute = 0;
for (const [, routes] of domainToRoutes) {
if (routes.includes(routeName)) domainsInRoute++;
}
share = 1 / Math.max(domainsInRoute, 1);
}
const share = routeTotal > 0 ? domainReqs / routeTotal : 0;
totalConns += conns * share;
totalIn += tp.in * share;
totalOut += tp.out * share;