The web app now sends its frontend counters when a URL is set, and nothing without one
The web app of BRUTAL counted its calls to the server and its mutation attempts, but nothing ever called the function that starts sending them. The counters grew only in memory and never left the browser, even with a target URL set. The fix wired them up, but only for a URL that is set explicitly.
A page switches the counters on by setting a global variable to an http or https URL, absolute or relative to the page, before the bundle loads. Any other value keeps them off, and off means off: nothing is counted, and no timer, listener or request exists. When on, the app sends at start, every 30 s, when the page becomes hidden and when it is left. Each send carries the cumulative totals in the Prometheus text format, so a repeated send does no harm. If the browser refuses the beacon, one POST with keepalive goes out instead, and a failure never reaches the interface.
Five series go out: a heartbeat, the uptime, view loads, calls and mutation attempts, the last two by procedure and status. No label carries repository names, paths, refs, subjects or tokens. A beacon to a path on the same origin carries the page's cookies, so a proxy in front of the receiver should not forward them. Two telemetry functions that had no caller were removed.
Five contract tests and three tests of the real app in a browser cover the switch, the off state and each send. Without the start call, both browser cases with a URL fail. The web tests went from 166 to 174 passing, with 22 skipped. No receiver ships with BRUTAL and nothing in the repository sets the URL, so in operation the counters stay off.
Sources
- #177 643fbac