Skip to content

Commit

Permalink
Add metrics for time taken to connected to m3db cluster during startup
Browse files Browse the repository at this point in the history
  • Loading branch information
pranithraparthi committed May 13, 2024
1 parent 75a402a commit 6f3e7ff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/dbnode/client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ type sessionMetrics struct {
topologyUpdatedSuccess tally.Counter
topologyUpdatedError tally.Counter
streamFromPeersMetrics map[shardMetricsKey]streamFromPeersMetrics
clusterConnectLatency tally.Histogram
}

func newSessionMetrics(scope tally.Scope) sessionMetrics {
Expand All @@ -225,6 +226,7 @@ func newSessionMetrics(scope tally.Scope) sessionMetrics {
topologyUpdatedSuccess: scope.Counter("topology.updated-success"),
topologyUpdatedError: scope.Counter("topology.updated-error"),
streamFromPeersMetrics: make(map[shardMetricsKey]streamFromPeersMetrics),
clusterConnectLatency: histogramWithDurationBuckets(scope, "cluster-connect.latency"),
}
}

Expand Down Expand Up @@ -895,6 +897,7 @@ func (s *session) hostQueues(
}
}()

startConnectAttempt := s.nowFn()
for {
if now := s.nowFn(); now.Sub(start) >= s.opts.ClusterConnectTimeout() {
switch firstConnectConsistencyLevel {
Expand Down Expand Up @@ -941,6 +944,7 @@ func (s *session) hostQueues(
}

connected = true
s.metrics.clusterConnectLatency.RecordDuration(s.nowFn().Sub(startConnectAttempt))
return queues, replicas, majority, nil
}

Expand Down

0 comments on commit 6f3e7ff

Please sign in to comment.