Skip to content

Commit 06fc52a

Browse files
authored
Frontend full redesign (#128)
* server: allow cross origin ws calls when STATSVIZ_DEBUG=1 This is needed during frontend development * server: send plot config as first ws message. Also, wrap metrics to simplify decoding in the frontend. * server: allow printing websocket errors while developing * go.mod: bump gorilla/websocket and rogpeppe/go-internal * Align tests * Improve TestUnusedRuntimeMetrics * Add dependabot.yml * Update CONTRIBUTING.md * static: use vite to build assets Assets directory is 1.5MB uncompressed 475kB compressed. We compressed the go:embed'ed filesystem so that the final binary size doesn't increase too much. Add scripts to create the dist hash and to diff it CI: bump actions, add assets check workflow Package.json: remove jquery and bootstrap/js, use smaller plotly bundle. Add maximize/minimize plot. * static: regenerate assets * static: collapsable side-bar * static: force plots update when on ui actions * static: move stuff in ui.js * static: cleanup event handlers * static: regenerate assets zip * static: remove unused plot cards * static: use ring buffer for stats and add handle ui in nav.js * static: use Float64Buffer * static: move stuff in plotConfig.js * static: StatsManager * static: use private Class fields when necessary * static: lighten app.js by moving websocket stuff to socket.js * static: forEach -> map * static: use correct icons for minimize/maximize plot * static: remove unused variables * static: simplify app.js by carving PlotManager out of it * static: responsive plot dimensions * static: fix theme switch on plots and github logo * static: regenerate assets zip * Update examples_test.go * Update examples_test.go * static: cosmetics * static: plots background padding and color * static: give plots a default height Without that default height, plots were being created first empty and grew afterwards, which was not aesthetically pleasing * internal/plot: cosmetics * internal/plot: cosmetics * internal/plots: use metricIndices helper * static: merge useMetric with mapMetricsToIndices * internal/plot: plot configuration supports tags * internal/plot: rework plot registry * static: use Plotly.relayout when switching theme * static: regenerate assets * Cosmetics * internal/plot: remove unused parameter * internal/plot: simplify plot registering * Cosmetics * internal/plot: rewrite in a more declarative way * internal/plot: remove usedMetrics from global state * internal/plot: cosmetics * internal/plots: add plots tags * internal/static: style plot tags * internal/static: smaller buttons * internal/static: remove sidebar and move everything on top navbar * internal/static: improve navbar * internal/static: minimal navbar * internal/static: reduce gap * internal/static: navbar cosmetics * internal/static: polish css html * internal/static: don't update hidden plots * internal/plot: add GC (Scavenger) plot * internal/static: show plots unless all its tags are disabled * internal/static: add 'CPU' plot tag * internal/plot: CPU plots (gc, scavenger and overall) * internal/plot: make 'mutex wait' a bar plot * internal/static: add /cpu/classes/gc/total to 'cpu overall' plot * internal/plot: add a 'garbage collection' plot * internal/plot: improve plot tooltips * internal/plot: add alloc/free rates plot * internal/static: regenerate assets * Update README.md * Polish and document usage of STATSVIZ_DEBUG * Update README.md * Update CHANGELOG
1 parent 0141254 commit 06fc52a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+4116
-2337
lines changed

.github/scripts/modtidy-check.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

.github/workflows/assets.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Assets
2+
on: [push, pull_request]
3+
jobs:
4+
check-assets:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- name: Setup node
9+
uses: actions/setup-node@v4
10+
with:
11+
node-version-file: internal/static/.nvmrc
12+
- uses: actions/setup-go@v5
13+
- run: npm install
14+
working-directory: internal/static
15+
- run: npm run build
16+
working-directory: internal/static
17+
- name: Check assets zip is up to date
18+
run: ./internal/static/scripts/checkzip.sh

.github/workflows/coverage.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
on: [push]
22
name: Coverage
33
jobs:
4-
run:
4+
coverage:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v3
8-
- uses: actions/setup-go@v3
7+
- uses: actions/checkout@v4
8+
- uses: actions/setup-go@v5
99
with:
10-
go-version: 1.21.x
10+
go-version-file: go.mod
1111
- run: go test -coverprofile=coverage.txt
1212
- name: Upload coverage to Codecov
1313
uses: codecov/codecov-action@v3

.github/workflows/tests-linux.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
on: [push, pull_request]
22
name: Tests-linux
33
jobs:
4-
test:
4+
tests-linux:
55
strategy:
66
matrix:
7-
go-version: [1.20.x, 1.21.x]
7+
go-version: [1.22.x, 1.23.x]
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v3
11-
- uses: actions/setup-go@v3
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-go@v5
1212
with:
13-
go-version: ${{ matrix.go-version }}
13+
go-version-file: go.mod
1414
- name: go mod tidy check
15-
run: .github/scripts/modtidy-check.sh
15+
run: go mod tidy -diff
1616
- name: Tests
1717
run: go test -race -shuffle=on ./...

.github/workflows/tests-others.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
on: [pull_request]
22
name: Tests-others
33
jobs:
4-
test:
4+
tests-macos-windows:
55
strategy:
66
matrix:
77
os: [macos-latest, windows-latest]
88
runs-on: ${{ matrix.os }}
99
steps:
10-
- uses: actions/checkout@v3
11-
- uses: actions/setup-go@v3
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-go@v5
1212
with:
13-
go-version: 1.21.x
13+
go-version-file: go.mod
1414
- name: Tests
1515
run: go test -race -shuffle=on ./...

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ Unreleased
22
==============
33
* Make all examples use statsviz@latest (#112)
44

5+
v0.7.0 / 2025-07-26
6+
==============
7+
* New plots showing new go1.22 runtime/metrics:
8+
+ GC Memory Summary
9+
+ CPU (Garbage Collector)
10+
* Frontend redesign/refactor:
11+
+ Maximize plot button
12+
+ plot category selector
13+
514
v0.6.0 / 2023-10-08
615
==============
716
* New plots showing new go1.20/go1.21 runtime/metrics: (#111)

CONTRIBUTING.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,56 @@ Pull-requests are welcome!
88

99
## Go library
1010

11-
The Statsviz Go public API is relatively light so there's not much to do and at
12-
the moment it's unlikely that the API will change. However new options can be
13-
added to `statsviz.Register` and `statsviz.NewServer` without breaking
14-
compatibility.
15-
16-
That being said, there may be things to improve in the implementation, any
17-
contribution is very welcome!
11+
Statsviz Go public API surface is relatively limited, by design, and it's highly
12+
unlikely that that will change. However new options can be added to
13+
`statsviz.Register` and `statsviz.NewServer` without breaking compatibility.
1814

1915
Big changes should be discussed on the issue tracker prior to start working on
2016
the code.
2117

22-
If you've decided to contribute, thank you so much, please comment on the existing
23-
issue or create one stating what you want to tackle and why.
18+
If you've decided to contribute, thank you so much, please comment on the
19+
existing issue or create one stating what you want to tackle.
2420

2521

2622
## User interface (html/css/javascript)
2723

2824
The user interface aims to be simple, light and minimal.
2925

26+
To bootstrap the UI for development:
27+
- cd to `internal/static`
28+
- run `npm install`
29+
- run `npm dev` and leave it running
30+
- in another terminal, cd to an example, for example `_example/default`
31+
- run `go mod edit -replace=github.com/arl/statsviz=../../` to build the
32+
example with your local version of the Go code. If you haven't touched to the
33+
Go code you can skip this step.
34+
35+
To build the production UI:
36+
- cd to `internal/static`
37+
- run `npm run build`
38+
- run `./scripts.zip.sh`
39+
- only commit `dist.zip`. `dist` directory is ignored.
40+
41+
3042
Assets are located in the `internal/static` directory and are embedded with
31-
[`go:embed`](https://pkg.go.dev/embed).
43+
[`go:embed`](https://pkg.go.dev/embed). To reduce the space taken by the assets
44+
in the final binary, the `dist` directory is zipped into `dist.zip`. Use
45+
`scripts/zip.sh` to do it. At runtime, when Statsviz serves the UI, the
46+
`dist.zip` is then decompressed into a `fs.FS`, served via
47+
`http.FileServerFS()`.
48+
3249

33-
Depending on what your modifications are, it's always a good idea to check that
34-
some of the examples in [./_example](./_example/) work with your modifications
35-
to Statsviz. To do so `cd` to the directory of the example and run:
50+
## `STATSVIZ_DEBUG`
3651

37-
go mod edit -replace=github.com/arl/statsviz=../../
52+
Declare `STATSVIZ_DEBUG=1` environment variable when you develop in order to:
53+
- print websocket errors on standard output.
54+
- bypasses CORS checks
3855

56+
Obviously, this is not recommended for production use!
3957

4058
## Documentation
4159

42-
No contribution is too small, improvements to code comments and/or README
60+
No contribution is too small. Improvements to code, comments or README
4361
are welcome!
4462

4563

0 commit comments

Comments
 (0)