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:
@@ -223,11 +223,8 @@ func LoadConfigFromReader(r io.Reader) (Config, error) {
|
||||
}
|
||||
|
||||
// Apply defaults for performance config when section is missing
|
||||
if !config.Performance.Enable && config.Performance.Every == 0 && config.Performance.MaxAge == 0 && config.Performance.GC == 0 {
|
||||
config.Performance.Enable = true
|
||||
config.Performance.Every = 15 * time.Second
|
||||
config.Performance.MaxAge = 1 * time.Hour
|
||||
config.Performance.GC = 5 * time.Minute
|
||||
if config.Performance.Every == 0 {
|
||||
config.Performance.Every = 5 * time.Second
|
||||
}
|
||||
if err = config.Performance.Validate(); err != nil {
|
||||
return Config{}, fmt.Errorf("performance: %w", err)
|
||||
|
||||
@@ -231,10 +231,7 @@ groups:
|
||||
MetricsMaxInMemory: 1000,
|
||||
CaptureBuffer: 5,
|
||||
Performance: PerformanceConfig{
|
||||
Enable: true,
|
||||
Every: 15 * time.Second,
|
||||
MaxAge: 1 * time.Hour,
|
||||
GC: 5 * time.Minute,
|
||||
Every: 5 * time.Second,
|
||||
},
|
||||
Profiles: map[string][]string{
|
||||
"test": {"model1", "model2"},
|
||||
|
||||
@@ -220,10 +220,7 @@ groups:
|
||||
MetricsMaxInMemory: 1000,
|
||||
CaptureBuffer: 5,
|
||||
Performance: PerformanceConfig{
|
||||
Enable: true,
|
||||
Every: 15 * time.Second,
|
||||
MaxAge: 1 * time.Hour,
|
||||
GC: 5 * time.Minute,
|
||||
Every: 5 * time.Second,
|
||||
},
|
||||
Profiles: map[string][]string{
|
||||
"test": {"model1", "model2"},
|
||||
|
||||
@@ -7,19 +7,14 @@ import (
|
||||
|
||||
// PerformanceConfig holds configuration for system performance monitoring
|
||||
type PerformanceConfig struct {
|
||||
Enable bool `yaml:"enable"`
|
||||
Every time.Duration `yaml:"every"`
|
||||
MaxAge time.Duration `yaml:"maxAge"`
|
||||
GC time.Duration `yaml:"gc"`
|
||||
Disabled bool `yaml:"disabled"`
|
||||
Every time.Duration `yaml:"every"`
|
||||
}
|
||||
|
||||
func (p *PerformanceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
type rawPerformanceConfig PerformanceConfig
|
||||
defaults := rawPerformanceConfig{
|
||||
Enable: true,
|
||||
Every: 15 * time.Second,
|
||||
MaxAge: 1 * time.Hour,
|
||||
GC: 5 * time.Minute,
|
||||
Every: 5 * time.Second,
|
||||
}
|
||||
|
||||
if err := unmarshal(&defaults); err != nil {
|
||||
@@ -32,14 +27,8 @@ func (p *PerformanceConfig) UnmarshalYAML(unmarshal func(interface{}) error) err
|
||||
|
||||
// Validate checks the PerformanceConfig values and returns an error if invalid
|
||||
func (p *PerformanceConfig) Validate() error {
|
||||
if p.Every < time.Second {
|
||||
return fmt.Errorf("every must be at least 1s, got %v", p.Every)
|
||||
}
|
||||
if p.MaxAge <= 0 {
|
||||
return fmt.Errorf("maxAge must be greater than 0, got %v", p.MaxAge)
|
||||
}
|
||||
if p.GC <= 0 {
|
||||
return fmt.Errorf("gc must be greater than 0, got %v", p.GC)
|
||||
if p.Every < 5*time.Second {
|
||||
return fmt.Errorf("every must be at least 5s, got %v", p.Every)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -18,10 +18,8 @@ models:
|
||||
assert.NoError(t, err)
|
||||
|
||||
// When performance section is missing, defaults should be applied
|
||||
assert.True(t, config.Performance.Enable)
|
||||
assert.Equal(t, 15*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, 1*time.Hour, config.Performance.MaxAge)
|
||||
assert.Equal(t, 5*time.Minute, config.Performance.GC)
|
||||
assert.False(t, config.Performance.Disabled)
|
||||
assert.Equal(t, 5*time.Second, config.Performance.Every)
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_CustomValues(t *testing.T) {
|
||||
@@ -29,8 +27,6 @@ func TestPerformanceConfig_CustomValues(t *testing.T) {
|
||||
performance:
|
||||
enable: true
|
||||
every: 30s
|
||||
maxAge: 12h
|
||||
gc: 10m
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
@@ -38,16 +34,14 @@ models:
|
||||
config, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.True(t, config.Performance.Enable)
|
||||
assert.False(t, config.Performance.Disabled)
|
||||
assert.Equal(t, 30*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, 12*time.Hour, config.Performance.MaxAge)
|
||||
assert.Equal(t, 10*time.Minute, config.Performance.GC)
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_Disabled(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
enable: false
|
||||
disabled: true
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
@@ -55,18 +49,15 @@ models:
|
||||
config, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.False(t, config.Performance.Enable)
|
||||
assert.True(t, config.Performance.Disabled)
|
||||
// Duration defaults should still apply
|
||||
assert.Equal(t, 15*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, 1*time.Hour, config.Performance.MaxAge)
|
||||
assert.Equal(t, 5*time.Minute, config.Performance.GC)
|
||||
assert.Equal(t, 5*time.Second, config.Performance.Every)
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_PartialValues(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
every: 10s
|
||||
maxAge: 6h
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
@@ -75,58 +66,27 @@ models:
|
||||
assert.NoError(t, err)
|
||||
|
||||
// enable should default to true
|
||||
assert.True(t, config.Performance.Enable)
|
||||
assert.False(t, config.Performance.Disabled)
|
||||
assert.Equal(t, 10*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, 6*time.Hour, config.Performance.MaxAge)
|
||||
// gc should use default
|
||||
assert.Equal(t, 5*time.Minute, config.Performance.GC)
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_InvalidEvery(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
every: 500ms
|
||||
every: 4s
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
`
|
||||
_, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "every must be at least 1s")
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_InvalidMaxAge(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
maxAge: 0s
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
`
|
||||
_, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "maxAge must be greater than 0")
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_InvalidGC(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
gc: 0s
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
`
|
||||
_, err := LoadConfigFromReader(strings.NewReader(content))
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "gc must be greater than 0")
|
||||
assert.Contains(t, err.Error(), "every must be at least 5s")
|
||||
}
|
||||
|
||||
func TestPerformanceConfig_ComplexDurations(t *testing.T) {
|
||||
content := `
|
||||
performance:
|
||||
every: 1m30s
|
||||
maxAge: 2h10m
|
||||
gc: 1m
|
||||
models:
|
||||
model1:
|
||||
cmd: path/to/cmd --port ${PORT}
|
||||
@@ -135,6 +95,4 @@ models:
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, 90*time.Second, config.Performance.Every)
|
||||
assert.Equal(t, (2*time.Hour)+(10*time.Minute), config.Performance.MaxAge)
|
||||
assert.Equal(t, 1*time.Minute, config.Performance.GC)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user