mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-21 10:18:50 +02:00
added dbg logs
This commit is contained in:
parent
ce8e651eb9
commit
fd25265967
@ -168,9 +168,11 @@ func (s *GRPCServer) Sync(req *proto.EncryptedMessage, srv proto.ManagementServi
|
|||||||
defer func() {
|
defer func() {
|
||||||
if s.appMetrics != nil {
|
if s.appMetrics != nil {
|
||||||
s.appMetrics.GRPCMetrics().CountSyncRequestDuration(time.Since(reqStart))
|
s.appMetrics.GRPCMetrics().CountSyncRequestDuration(time.Since(reqStart))
|
||||||
|
log.WithContext(ctx).Infof("Sync request from peer %s took %v", peerKey.String(), time.Since(reqStart))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
syncbody := time.Now()
|
||||||
// nolint:staticcheck
|
// nolint:staticcheck
|
||||||
ctx = context.WithValue(ctx, nbContext.PeerIDKey, peerKey.String())
|
ctx = context.WithValue(ctx, nbContext.PeerIDKey, peerKey.String())
|
||||||
|
|
||||||
@ -224,6 +226,8 @@ func (s *GRPCServer) Sync(req *proto.EncryptedMessage, srv proto.ManagementServi
|
|||||||
|
|
||||||
log.WithContext(ctx).Debugf("Sync: took %v", time.Since(reqStart))
|
log.WithContext(ctx).Debugf("Sync: took %v", time.Since(reqStart))
|
||||||
|
|
||||||
|
log.WithContext(ctx).Info("Sync body after the filter for peer %s took %v", peerKey.String(), time.Since(syncbody))
|
||||||
|
|
||||||
return s.handleUpdates(ctx, accountID, peerKey, peer, updates, srv)
|
return s.handleUpdates(ctx, accountID, peerKey, peer, updates, srv)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,10 +487,13 @@ func (s *GRPCServer) Login(ctx context.Context, req *proto.EncryptedMessage) (*p
|
|||||||
if s.appMetrics != nil {
|
if s.appMetrics != nil {
|
||||||
s.appMetrics.GRPCMetrics().CountLoginRequestDuration(time.Since(reqStart))
|
s.appMetrics.GRPCMetrics().CountLoginRequestDuration(time.Since(reqStart))
|
||||||
}
|
}
|
||||||
|
log.WithContext(ctx).Infof("Login request from peer %s took %v", peerKey.String(), time.Since(reqStart))
|
||||||
}()
|
}()
|
||||||
if s.appMetrics != nil {
|
if s.appMetrics != nil {
|
||||||
s.appMetrics.GRPCMetrics().CountLoginRequest()
|
s.appMetrics.GRPCMetrics().CountLoginRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bodytime := time.Now()
|
||||||
//nolint
|
//nolint
|
||||||
ctx = context.WithValue(ctx, nbContext.PeerIDKey, peerKey.String())
|
ctx = context.WithValue(ctx, nbContext.PeerIDKey, peerKey.String())
|
||||||
accountID, err := s.accountManager.GetAccountIDForPeerKey(ctx, peerKey.String())
|
accountID, err := s.accountManager.GetAccountIDForPeerKey(ctx, peerKey.String())
|
||||||
@ -544,6 +551,7 @@ func (s *GRPCServer) Login(ctx context.Context, req *proto.EncryptedMessage) (*p
|
|||||||
log.WithContext(ctx).Warnf("failed encrypting peer %s message", peer.ID)
|
log.WithContext(ctx).Warnf("failed encrypting peer %s message", peer.ID)
|
||||||
return nil, status.Errorf(codes.Internal, "failed logging in peer")
|
return nil, status.Errorf(codes.Internal, "failed logging in peer")
|
||||||
}
|
}
|
||||||
|
log.WithContext(ctx).Info("Login body after the filter for peer %s took %v", peerKey.String(), time.Since(bodytime))
|
||||||
|
|
||||||
return &proto.EncryptedMessage{
|
return &proto.EncryptedMessage{
|
||||||
WgPubKey: s.wgKey.PublicKey().String(),
|
WgPubKey: s.wgKey.PublicKey().String(),
|
||||||
|
@ -66,6 +66,7 @@ func newLoginFilterWithCfg(cfg *config) *loginFilter {
|
|||||||
func (l *loginFilter) allowLogin(wgPubKey string, metaHash uint64) bool {
|
func (l *loginFilter) allowLogin(wgPubKey string, metaHash uint64) bool {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
l.mu.RLock()
|
l.mu.RLock()
|
||||||
|
// defer l.mu.RUnlock()
|
||||||
defer func() {
|
defer func() {
|
||||||
l.mu.RUnlock()
|
l.mu.RUnlock()
|
||||||
log.Infof("allowLogin duration for %s: %v", wgPubKey, time.Since(now))
|
log.Infof("allowLogin duration for %s: %v", wgPubKey, time.Since(now))
|
||||||
@ -88,6 +89,7 @@ func (l *loginFilter) allowLogin(wgPubKey string, metaHash uint64) bool {
|
|||||||
func (l *loginFilter) addLogin(wgPubKey string, metaHash uint64) {
|
func (l *loginFilter) addLogin(wgPubKey string, metaHash uint64) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
l.mu.Lock()
|
l.mu.Lock()
|
||||||
|
// defer l.mu.Unlock()
|
||||||
defer func() {
|
defer func() {
|
||||||
l.mu.Unlock()
|
l.mu.Unlock()
|
||||||
log.Infof("addLogin duration for %s: %v", wgPubKey, time.Since(now))
|
log.Infof("addLogin duration for %s: %v", wgPubKey, time.Since(now))
|
||||||
|
@ -3,6 +3,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"hash/fnv"
|
"hash/fnv"
|
||||||
"math"
|
"math"
|
||||||
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -249,3 +250,26 @@ func getMacAddress(nas []nbpeer.NetworkAddress) string {
|
|||||||
}
|
}
|
||||||
return strings.Join(macs, "/")
|
return strings.Join(macs, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkLoginFilter_ParallelLoad(b *testing.B) {
|
||||||
|
filter := newLoginFilterWithCfg(testAdvancedCfg())
|
||||||
|
numKeys := 100000
|
||||||
|
pubKeys := make([]string, numKeys)
|
||||||
|
for i := range numKeys {
|
||||||
|
pubKeys[i] = "PUB_KEY_" + strconv.Itoa(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
b.ResetTimer()
|
||||||
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
|
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
|
|
||||||
|
for pb.Next() {
|
||||||
|
key := pubKeys[r.Intn(numKeys)]
|
||||||
|
meta := r.Uint64()
|
||||||
|
|
||||||
|
if filter.allowLogin(key, meta) {
|
||||||
|
filter.addLogin(key, meta)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user