Skip to content

Commit

Permalink
routing: log route update id (#3112)
Browse files Browse the repository at this point in the history
Add and log route update counter to observe delay between receiving and
applying routes.

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov authored Jun 17, 2024
1 parent 9bf6f02 commit 47c3db1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions routing/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ func processRouteDefs(o Options, fr filters.Registry, defs []*eskip.Route) (rout
}

type routeTable struct {
id int
m *matcher
once sync.Once
routes []*Route // only used for closing
Expand Down Expand Up @@ -543,10 +544,10 @@ func receiveRouteMatcher(o Options, out chan<- *routeTable, quit <-chan struct{}
updatesRelay <-chan []*eskip.Route
)
updatesRelay = updates
for {
for id := 1; ; id++ {
select {
case defs := <-updatesRelay:
o.Log.Info("route settings received")
o.Log.Infof("route settings received, id: %d", id)

for i := range o.PreProcessors {
defs = o.PreProcessors[i].Do(defs)
Expand Down Expand Up @@ -582,6 +583,7 @@ func receiveRouteMatcher(o Options, out chan<- *routeTable, quit <-chan struct{}
})

rt = &routeTable{
id: id,
m: m,
routes: routes,
validRoutes: validRoutes,
Expand Down
2 changes: 1 addition & 1 deletion routing/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (r *Routing) startReceivingUpdates(o Options) {
r.firstLoadSignaled = true
}
}
r.log.Info("route settings applied")
r.log.Infof("route settings applied, id: %d", rt.id)
if r.metrics != nil { // existing codebases might not supply metrics instance
r.metrics.UpdateGauge("routes.total", float64(len(rt.validRoutes)))
r.metrics.UpdateGauge("routes.updated_timestamp", float64(rt.created.Unix()))
Expand Down

0 comments on commit 47c3db1

Please sign in to comment.