Skip to content

Commit

Permalink
routing: measure route update latency (#3113)
Browse files Browse the repository at this point in the history
* add route update latency metric - the time it takes to apply
  routes update after receival.
* remove redundant setting of `created` location to UTC -
  its value is only exposed via Unix() which is always in UTC.

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov authored Jun 17, 2024
1 parent dbcb0fd commit 9eee9a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion routing/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@ func receiveRouteMatcher(o Options, out chan<- *routeTable, quit <-chan struct{}
for id := 1; ; id++ {
select {
case defs := <-updatesRelay:
start := time.Now()

o.Log.Infof("route settings received, id: %d", id)

for i := range o.PreProcessors {
Expand Down Expand Up @@ -588,7 +590,7 @@ func receiveRouteMatcher(o Options, out chan<- *routeTable, quit <-chan struct{}
routes: routes,
validRoutes: validRoutes,
invalidRoutes: invalidRoutes,
created: time.Now().UTC(),
created: start,
}
updatesRelay = nil
outRelay = out
Expand Down
3 changes: 2 additions & 1 deletion routing/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func New(o Options) *Routing {
initialMatcher, _ := newMatcher(nil, MatchingOptionsNone)
rt := &routeTable{
m: initialMatcher,
created: time.Now().UTC(),
created: time.Now(),
}
r.routeTable.Store(rt)
r.startReceivingUpdates(o)
Expand Down Expand Up @@ -357,6 +357,7 @@ func (r *Routing) startReceivingUpdates(o Options) {
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()))
r.metrics.MeasureSince("routes.update_latency", rt.created)
}
case <-r.quit:
var rt *routeTable
Expand Down

0 comments on commit 9eee9a3

Please sign in to comment.