watchdog: migrate to Cobra and Viper for config management; search /etc for configs
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I65dbf466cb030dccc7025585d6282bd26a6a6964
This commit is contained in:
parent
951ed9c36f
commit
f988174145
9 changed files with 187 additions and 61 deletions
|
|
@ -15,7 +15,7 @@ var prometheusLabelPattern = regexp.MustCompile(`^[a-zA-Z0-9_/:.-]*$`)
|
|||
type MetricsAggregator struct {
|
||||
pathRegistry *PathRegistry
|
||||
eventRegistry *CustomEventRegistry
|
||||
cfg config.Config
|
||||
cfg *config.Config
|
||||
pageviews *prometheus.CounterVec
|
||||
customEvents *prometheus.CounterVec
|
||||
pathOverflow prometheus.Counter
|
||||
|
|
@ -30,7 +30,7 @@ type MetricsAggregator struct {
|
|||
func NewMetricsAggregator(
|
||||
pathRegistry *PathRegistry,
|
||||
eventRegistry *CustomEventRegistry,
|
||||
cfg config.Config,
|
||||
cfg *config.Config,
|
||||
) *MetricsAggregator {
|
||||
// Build label names based on what's enabled in config
|
||||
labels := []string{"path"} // path is always included
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ func TestMetricsAggregator_RecordPageview(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), &cfg)
|
||||
|
||||
// Record pageview with all dimensions
|
||||
agg.RecordPageview("/home", "US", "desktop", "google.com", "")
|
||||
|
|
@ -51,7 +51,7 @@ func TestMetricsAggregator_RecordPageview_MinimalDimensions(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), &cfg)
|
||||
|
||||
// Record pageview with only path
|
||||
agg.RecordPageview("/home", "", "", "", "")
|
||||
|
|
@ -78,7 +78,7 @@ func TestMetricsAggregator_PathOverflow(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), &cfg)
|
||||
|
||||
// Add two paths successfully
|
||||
registry.Add("/path1")
|
||||
|
|
@ -114,7 +114,7 @@ func TestMetricsAggregator_RecordCustomEvent(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), &cfg)
|
||||
|
||||
// Record custom event
|
||||
agg.RecordCustomEvent("signup")
|
||||
|
|
@ -141,7 +141,7 @@ func TestMetricsAggregator_RecordCustomEvent_MultipleEvents(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), &cfg)
|
||||
|
||||
// Record multiple events
|
||||
agg.RecordCustomEvent("signup")
|
||||
|
|
@ -170,7 +170,7 @@ func TestMetricsAggregator_MustRegister(t *testing.T) {
|
|||
}
|
||||
|
||||
promRegistry := prometheus.NewRegistry()
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), cfg)
|
||||
agg := NewMetricsAggregator(registry, NewCustomEventRegistry(100), &cfg)
|
||||
|
||||
// Register metrics
|
||||
agg.MustRegister(promRegistry)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue