v0.32.6_fix2
This commit is contained in:
1 parent
e1ac899ec0
commit
fc8711d4d8
39 files changed
+695
-232
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
(() => {
|
||||
let loading = false, generation = 0, lastData = null;
|
||||
let liveChartScope = "", liveChartPrevious = null, liveChartPreviousAt = null;
|
||||
let liveChartScope = "", liveChartPrevious = null, liveChartPreviousAt = null, liveChartGeneration = null;
|
||||
const liveChartSamples = { applied: [], cache_hits: [], skipped: [], errors: [] };
|
||||
const LIVE_CHART_LIMITS = new Set([60, 120, 300, 600]);
|
||||
const LIVE_CHART_STORAGE_KEY = "rustproxy.transform.liveChartSamples";
|
||||
@@ -20,7 +20,7 @@
|
||||
};
|
||||
const emptyCounters = () => ({ examined: 0, applied: 0, skipped: 0, errors: 0, cache_hits: 0, original_bytes: 0, transformed_bytes: 0, saved_bytes: 0, duration_us: 0, by_kind: {}, reasons: {} });
|
||||
function resetLiveChart(selected = scope()) {
|
||||
liveChartScope = selected; liveChartPrevious = null; liveChartPreviousAt = null;
|
||||
liveChartScope = selected; liveChartPrevious = null; liveChartPreviousAt = null; liveChartGeneration = null;
|
||||
for (const values of Object.values(liveChartSamples)) values.length = 0;
|
||||
for (const id of ["transform-live-applied-line", "transform-live-cache-line", "transform-live-skipped-line", "transform-live-error-line"]) $(id)?.setAttribute("points", "0,170 900,170");
|
||||
for (const id of ["transform-live-applied-rate", "transform-live-cache-rate", "transform-live-skipped-rate", "transform-live-error-rate"]) if ($(id)) $(id).textContent = "0.0/s";
|
||||
@@ -54,19 +54,22 @@
|
||||
cache_hits: Math.max(0, Number(counters.cache_hits) || 0),
|
||||
skipped: Math.max(0, Number(counters.skipped) || 0),
|
||||
errors: Math.max(0, Number(counters.errors) || 0)
|
||||
}, rates = { applied: 0, cache_hits: 0, skipped: 0, errors: 0 };
|
||||
if (liveChartPrevious && liveChartPreviousAt != null) {
|
||||
const elapsed = Math.max(.001, (now - liveChartPreviousAt) / 1000);
|
||||
for (const key of Object.keys(rates)) if (current[key] >= liveChartPrevious[key]) rates[key] = (current[key] - liveChartPrevious[key]) / elapsed;
|
||||
};
|
||||
const keys = Object.keys(current);
|
||||
const previous = liveChartPrevious && liveChartPreviousAt != null
|
||||
? { values: keys.map(key => liveChartPrevious[key]), at: liveChartPreviousAt, generation: liveChartGeneration } : null;
|
||||
const sample = rustProxyRateSampling.difference(previous, keys.map(key => current[key]), now, 3);
|
||||
liveChartPrevious = current; liveChartPreviousAt = now; liveChartGeneration = sample.next.generation;
|
||||
if (sample.deltas) {
|
||||
keys.forEach((key, i) => { liveChartSamples[key].push(sample.deltas[i] / sample.seconds); liveChartSamples[key] = liveChartSamples[key].slice(-liveChartLimit); });
|
||||
}
|
||||
liveChartPrevious = current; liveChartPreviousAt = now;
|
||||
for (const key of Object.keys(rates)) { liveChartSamples[key].push(rates[key]); liveChartSamples[key] = liveChartSamples[key].slice(-liveChartLimit); }
|
||||
redrawLiveChart();
|
||||
$("transform-live-applied-rate").textContent = `${rates.applied.toFixed(1)}/s`;
|
||||
$("transform-live-cache-rate").textContent = `${rates.cache_hits.toFixed(1)}/s`;
|
||||
$("transform-live-skipped-rate").textContent = `${rates.skipped.toFixed(1)}/s`;
|
||||
$("transform-live-error-rate").textContent = `${rates.errors.toFixed(1)}/s`;
|
||||
$("transform-live-chart-value").textContent = `Σ ${(rates.applied + rates.cache_hits + rates.skipped + rates.errors).toFixed(1)}/s`;
|
||||
const rate = key => sample.deltas ? `${(sample.deltas[keys.indexOf(key)] / sample.seconds).toFixed(1)}/s` : "-";
|
||||
$("transform-live-applied-rate").textContent = rate("applied");
|
||||
$("transform-live-cache-rate").textContent = rate("cache_hits");
|
||||
$("transform-live-skipped-rate").textContent = rate("skipped");
|
||||
$("transform-live-error-rate").textContent = rate("errors");
|
||||
$("transform-live-chart-value").textContent = sample.deltas ? `Σ ${(sample.deltas.reduce((a, b) => a + b, 0) / sample.seconds).toFixed(1)}/s` : "-";
|
||||
}
|
||||
function countersFor(data) {
|
||||
if (scope() === "*") return data?.metrics?.total || emptyCounters();
|
||||
|
||||
Reference in new issue
Block a user