Просмотр исходного кода

fix(charts): draw aggregated buckets as steps, not slopes (#1901) (#1908)

* build(agent): remove the output before building so packing is idempotent

* fix(ui): draw bucketed traffic as steps instead of invented ramps (#1901)

* docs(changelog): cover the step shape for bucketed charts (#1901)
Nacho 4 недель назад
Родитель
Сommit
3288e0587e

+ 2 - 0
CHANGELOG.md

@@ -13,6 +13,8 @@ y este proyecto se adhiere a [Versionado Semántico](https://semver.org/lang/es/
 
 ### Fixed
 
+- Traffic charts no longer invent a ramp between two buckets (#1901). A point in these series means "the highest rate seen inside this bucket", so a straight segment to the next point claims the link spent the whole gap climbing, and a one minute burst inside an hour renders as a triangle that spans the neighbouring hours. The WAN chart, the fleet sparkline and the aggregated port ranges now draw steps, which say exactly what was measured and no more. The 24h port chart keeps its straight segments because it reads raw instantaneous samples, and the latency chart is untouched since it is not a max-per-bucket series. One detail differs from the report: every WAN range is bucketed, including 1h, whose points are three minute maxima, so the step applies there too instead of only to the hourly view.
+
 - Discovery no longer offers a unit that is already in the fleet (#1895). A candidate was marked as already added only when its IP was byte-identical to the host string in the configuration, so a unit added by DNS name, by a name with different case or a trailing dot, or by an IP with a port showed up with an Add button while the gateway, added by plain IP, was the only one recognised. The comparison now normalises case, port and the trailing dot, resolves configured names to their addresses, and also matches the reverse DNS name of the candidate, with name resolution bounded so a stale name cannot slow the scan down.
 - A config backup no longer stays on the unit after it is uploaded (#1897). Every manual or scheduled backup wrote its tarball under `/tmp` and left it there, and on a router `/tmp` is RAM, so each snapshot took memory away until the next reboot. The agent now deletes the local file once the operation ends, whether the upload succeeded or not, since the copy that matters is the one the server keeps with retention. The firmware flow keeps its local backup on purpose: that one is reported in the result so it can be recovered by hand when sysupgrade fails.
 

+ 3 - 1
app/src/components/routers/FleetCard.tsx

@@ -307,7 +307,9 @@ export function FleetCard({ router, index = 0, refreshKey = 0 }: FleetCardProps)
                 </defs>
                 <Tooltip content={<TrafficTooltip unit={trafficUnit} />} cursor={{ stroke: 'rgb(var(--border-strong))', strokeWidth: 1 }} />
                 <Area
-                  type="linear"
+                  // #1901: sparkline horario (MAX del bucket), no muestras
+                  // instantáneas: el escalón no inventa minutos de rampa.
+                  type="stepAfter"
                   dataKey="v"
                   stroke="#22D3EE"
                   strokeWidth={1.75}

+ 7 - 2
app/src/components/routers/PortSeriesChart.tsx

@@ -210,6 +210,11 @@ export function PortSeriesChart({
     })
   }, [visiblePorts, ports])
 
+  // #1901: solo 24h lee `raw` (muestras instantáneas, `Resolution()` en
+  // portseries.go). 7d y 30d leen buckets de 5 m y 12m buckets diarios, así
+  // que esos se dibujan como escalones: un pico por bucket no es una rampa.
+  const curveType = range === '24h' ? 'linear' : 'stepAfter'
+
   const fetchData = useCallback(async () => {
     if (!portId) return
     setLoading(true)
@@ -460,7 +465,7 @@ export function PortSeriesChart({
               <XAxis dataKey="t" hide />
               <Tooltip content={<PortTooltip unit={effUnit} />} cursor={{ stroke: 'rgb(var(--border-strong))', strokeWidth: 1 }} />
               <Area
-                type="linear"
+                type={curveType}
                 dataKey="rx"
                 name="RX"
                 stroke="#3b82f6"
@@ -471,7 +476,7 @@ export function PortSeriesChart({
                 isAnimationActive={false}
               />
               <Area
-                type="linear"
+                type={curveType}
                 dataKey="tx"
                 name="TX"
                 stroke="#10b981"

+ 7 - 2
app/src/sections/WanTraffic.tsx

@@ -93,6 +93,11 @@ export function WanTraffic() {
     return () => window.clearInterval(id)
   }, [range, isDemo])
 
+  // #1901: TODOS los rangos de esta gráfica son MAX por bucket (1h usa
+  // buckets de 3 min, 24h de 1 h, 7d de 1 d, 30d de 6 h), no muestras
+  // instantáneas. Un segmento en rampa entre dos picos afirma que el enlace
+  // estuvo subiendo durante todo el hueco: inventa duración. El escalón
+  // dibuja exactamente lo que el dato dice, "este ritmo se vio en este bucket".
   const liveDotDown = useMemo(() => makeLiveDot(liveData.length, '#22D3EE'), [liveData.length])
   const liveDotUp = useMemo(() => makeLiveDot(liveData.length, '#A78BFA'), [liveData.length])
 
@@ -176,7 +181,7 @@ export function WanTraffic() {
               />
             ) : null}
             <Area
-              type="linear"
+              type="stepAfter"
               dataKey="down"
               stroke="#22D3EE"
               strokeWidth={2}
@@ -187,7 +192,7 @@ export function WanTraffic() {
               animationEasing="ease-out"
             />
             <Area
-              type="linear"
+              type="stepAfter"
               dataKey="up"
               stroke="#A78BFA"
               strokeWidth={2}

+ 5 - 0
scripts/build-agents.sh

@@ -35,6 +35,11 @@ export GOOS=linux
 
 build() {
 	local arch=$1 extra=$2
+	# go build does not always rewrite an existing -o target when the build is
+	# cached, and a target that is already UPX packed makes the packing step
+	# fail with AlreadyPackedException. Removing it first keeps the script
+	# idempotent: two runs in a row must both work.
+	rm -f "$OUT/netpulse-agent-$arch"
 	# shellcheck disable=SC2086
 	(cd agent && env GOARCH="$arch" $extra "$GO" build -trimpath \
 		-ldflags "-s -w -X main.Version=$VERSION" \