Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions pkg/router/template/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ type templateRouter struct {
stateChanged bool
// metricReload tracks reloads
metricReload prometheus.Summary
// metricReloadFails tracks reload failures
metricReloadFails prometheus.Counter
// metricWriteConfig tracks writing config
metricWriteConfig prometheus.Summary
// dynamicConfigManager configures route changes dynamically on the
Expand Down Expand Up @@ -178,6 +180,12 @@ func newTemplateRouter(cfg templateRouterCfg) (*templateRouter, error) {
Help: "Measures the time spent reloading the router in seconds.",
})
prometheus.MustRegister(metricsReload)
metricReloadFails := prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "template_router",
Name: "reload_fails",
Help: "Tracks the number of failed router reloads",
})
prometheus.MustRegister(metricReloadFails)
metricWriteConfig := prometheus.NewSummary(prometheus.SummaryOpts{
Namespace: "template_router",
Name: "write_config_seconds",
Expand Down Expand Up @@ -207,6 +215,7 @@ func newTemplateRouter(cfg templateRouterCfg) (*templateRouter, error) {
dynamicConfigManager: cfg.dynamicConfigManager,

metricReload: metricsReload,
metricReloadFails: metricReloadFails,
metricWriteConfig: metricWriteConfig,

rateLimitedCommitFunction: nil,
Expand All @@ -221,10 +230,7 @@ func newTemplateRouter(cfg templateRouterCfg) (*templateRouter, error) {
log.V(0).Info("initializing dynamic config manager ... ")
router.dynamicConfigManager.Initialize(router, router.defaultCertificatePath)
}
log.V(4).Info("committing state")
// Bypass the rate limiter to ensure the first sync will be
// committed without delay.
router.commitAndReload()

return router, nil
}

Expand Down Expand Up @@ -434,6 +440,8 @@ func (r *templateRouter) commitAndReload() error {
if r.dynamicConfigManager != nil {
r.dynamicConfigManager.Notify(RouterEventReloadError)
}
// Increment the failed reload counter when a reload fails
r.metricReloadFails.Inc()
return err
}

Expand Down