mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-07 08:44:07 +01:00
[signal] Fix signal active peers metrics (#2591)
This commit is contained in:
parent
82739e2832
commit
730dd1733e
@ -82,8 +82,11 @@ func (registry *Registry) Register(peer *Peer) {
|
||||
log.Warnf("peer [%s] is already registered [new streamID %d, previous StreamID %d]. Will override stream.",
|
||||
peer.Id, peer.StreamID, pp.StreamID)
|
||||
registry.Peers.Store(peer.Id, peer)
|
||||
return
|
||||
}
|
||||
|
||||
log.Debugf("peer registered [%s]", peer.Id)
|
||||
registry.metrics.ActivePeers.Add(context.Background(), 1)
|
||||
|
||||
// record time as milliseconds
|
||||
registry.metrics.RegistrationDelay.Record(context.Background(), float64(time.Since(start).Nanoseconds())/1e6)
|
||||
@ -105,8 +108,8 @@ func (registry *Registry) Deregister(peer *Peer) {
|
||||
peer.Id, pp.StreamID, peer.StreamID)
|
||||
return
|
||||
}
|
||||
registry.metrics.ActivePeers.Add(context.Background(), -1)
|
||||
log.Debugf("peer deregistered [%s]", peer.Id)
|
||||
registry.metrics.Deregistrations.Add(context.Background(), 1)
|
||||
}
|
||||
log.Debugf("peer deregistered [%s]", peer.Id)
|
||||
|
||||
registry.metrics.Deregistrations.Add(context.Background(), 1)
|
||||
}
|
||||
|
@ -133,8 +133,6 @@ func (s *Server) RegisterPeer(stream proto.SignalExchange_ConnectStreamServer) (
|
||||
s.registry.Register(p)
|
||||
s.dispatcher.ListenForMessages(stream.Context(), p.Id, s.forwardMessageToPeer)
|
||||
|
||||
s.metrics.ActivePeers.Add(stream.Context(), 1)
|
||||
|
||||
return p, nil
|
||||
} else {
|
||||
s.metrics.RegistrationFailures.Add(stream.Context(), 1, metric.WithAttributes(attribute.String(labelError, labelErrorMissingId)))
|
||||
@ -151,7 +149,6 @@ func (s *Server) DeregisterPeer(p *peer.Peer) {
|
||||
s.registry.Deregister(p)
|
||||
|
||||
s.metrics.PeerConnectionDuration.Record(p.Stream.Context(), int64(time.Since(p.RegisteredAt).Seconds()))
|
||||
s.metrics.ActivePeers.Add(context.Background(), -1)
|
||||
}
|
||||
|
||||
func (s *Server) forwardMessageToPeer(ctx context.Context, msg *proto.EncryptedMessage) {
|
||||
|
Loading…
Reference in New Issue
Block a user