Changes and fixes before the release (docs/small tweaks) (#750)

- update README.md with new docker instructions
- update docs/configuration.md
- update .github/workflows to have pinned action versions
- gofmt events package
- fix small bugs in CI scripts
- reduce config options for internal/perf/monitor and config. A ring buffer is used to keep 1hr of entries at max 5s granularity. For long term stats use prometheus monitoring on /metrics

Fixes #744
This commit is contained in:
Benson Wong
2026-05-13 21:18:19 -07:00
committed by GitHub
parent 3e3646f9f9
commit a4b91e08cf
23 changed files with 499 additions and 569 deletions
+4 -8
View File
@@ -31,7 +31,7 @@ type Monitor struct {
}
func ringCapacity(c config.PerformanceConfig) int {
n := int(c.MaxAge / c.Every)
n := int(time.Hour / c.Every)
if n < 1 {
n = 1
}
@@ -43,12 +43,6 @@ func New(c config.PerformanceConfig, logger *logmon.Monitor) (*Monitor, error) {
if c.Every < 100*time.Millisecond {
c.Every = 100 * time.Millisecond
}
if c.GC < 1*time.Second {
c.GC = 1 * time.Second
}
if c.MaxAge < 1*time.Minute {
c.MaxAge = 1 * time.Minute
}
if logger == nil {
return nil, errors.New("logger is required")
@@ -92,7 +86,9 @@ func (m *Monitor) UpdateConfig(newConf config.PerformanceConfig) {
m.sysRing = ring.NewBuffer[SysStat](capacity)
m.gpuRing = ring.NewBuffer[[]GpuStat](capacity)
m.mutex.Unlock()
m.Start()
if !newConf.Disabled {
m.Start()
}
}
// Subscribe returns channels to listen to system and GPU stats.
+2 -14
View File
@@ -24,26 +24,19 @@ func TestNew_DefaultConfig(t *testing.T) {
require.NotNil(t, m)
assert.Equal(t, 100*time.Millisecond, m.conf.Every)
assert.Equal(t, 1*time.Second, m.conf.GC)
assert.Equal(t, 1*time.Minute, m.conf.MaxAge)
}
func TestNew_CustomConfig(t *testing.T) {
logger := newTestLogger()
cfg := config.PerformanceConfig{
Enable: true,
Every: 500 * time.Millisecond,
GC: 5 * time.Second,
MaxAge: 10 * time.Minute,
Every: 500 * time.Millisecond,
}
m, err := New(cfg, logger)
require.NoError(t, err)
assert.Equal(t, 500*time.Millisecond, m.conf.Every)
assert.Equal(t, 5*time.Second, m.conf.GC)
assert.Equal(t, 10*time.Minute, m.conf.MaxAge)
}
func TestNew_NilLogger(t *testing.T) {
@@ -56,18 +49,13 @@ func TestNew_BelowMinimumConfig(t *testing.T) {
logger := newTestLogger()
cfg := config.PerformanceConfig{
Enable: true,
Every: 1 * time.Millisecond,
GC: 100 * time.Millisecond,
MaxAge: 1 * time.Second,
Every: 1 * time.Millisecond,
}
m, err := New(cfg, logger)
require.NoError(t, err)
assert.Equal(t, 100*time.Millisecond, m.conf.Every)
assert.Equal(t, 1*time.Second, m.conf.GC)
assert.Equal(t, 1*time.Minute, m.conf.MaxAge)
}
func TestSubscribe_ReturnsChannels(t *testing.T) {