mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-05 08:54:11 -04:00
[management] only count login request duration for successful logins (#5545)
This commit is contained in:
@@ -330,13 +330,12 @@ func (s *Server) Sync(req *proto.EncryptedMessage, srv proto.ManagementService_S
|
|||||||
|
|
||||||
s.secretsManager.SetupRefresh(ctx, accountID, peer.ID)
|
s.secretsManager.SetupRefresh(ctx, accountID, peer.ID)
|
||||||
|
|
||||||
if s.appMetrics != nil {
|
|
||||||
s.appMetrics.GRPCMetrics().CountSyncRequestDuration(time.Since(reqStart), accountID)
|
|
||||||
}
|
|
||||||
|
|
||||||
unlock()
|
unlock()
|
||||||
unlock = nil
|
unlock = nil
|
||||||
|
|
||||||
|
if s.appMetrics != nil {
|
||||||
|
s.appMetrics.GRPCMetrics().CountSyncRequestDuration(time.Since(reqStart), accountID)
|
||||||
|
}
|
||||||
log.WithContext(ctx).Debugf("Sync took %s", time.Since(reqStart))
|
log.WithContext(ctx).Debugf("Sync took %s", time.Since(reqStart))
|
||||||
|
|
||||||
s.syncSem.Add(-1)
|
s.syncSem.Add(-1)
|
||||||
@@ -743,13 +742,6 @@ func (s *Server) Login(ctx context.Context, req *proto.EncryptedMessage) (*proto
|
|||||||
|
|
||||||
log.WithContext(ctx).Debugf("Login request from peer [%s] [%s]", req.WgPubKey, sRealIP)
|
log.WithContext(ctx).Debugf("Login request from peer [%s] [%s]", req.WgPubKey, sRealIP)
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if s.appMetrics != nil {
|
|
||||||
s.appMetrics.GRPCMetrics().CountLoginRequestDuration(time.Since(reqStart), accountID)
|
|
||||||
}
|
|
||||||
log.WithContext(ctx).Debugf("Login took %s", time.Since(reqStart))
|
|
||||||
}()
|
|
||||||
|
|
||||||
if loginReq.GetMeta() == nil {
|
if loginReq.GetMeta() == nil {
|
||||||
msg := status.Errorf(codes.FailedPrecondition,
|
msg := status.Errorf(codes.FailedPrecondition,
|
||||||
"peer system meta has to be provided to log in. Peer %s, remote addr %s", peerKey.String(), realIP)
|
"peer system meta has to be provided to log in. Peer %s, remote addr %s", peerKey.String(), realIP)
|
||||||
@@ -799,6 +791,11 @@ func (s *Server) Login(ctx context.Context, req *proto.EncryptedMessage) (*proto
|
|||||||
return nil, status.Errorf(codes.Internal, "failed logging in peer")
|
return nil, status.Errorf(codes.Internal, "failed logging in peer")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.appMetrics != nil {
|
||||||
|
s.appMetrics.GRPCMetrics().CountLoginRequestDuration(time.Since(reqStart), accountID)
|
||||||
|
}
|
||||||
|
log.WithContext(ctx).Debugf("Login took %s", time.Since(reqStart))
|
||||||
|
|
||||||
return &proto.EncryptedMessage{
|
return &proto.EncryptedMessage{
|
||||||
WgPubKey: key.PublicKey().String(),
|
WgPubKey: key.PublicKey().String(),
|
||||||
Body: encryptedResp,
|
Body: encryptedResp,
|
||||||
|
|||||||
Reference in New Issue
Block a user