Skip to content

Commit

Permalink
Update log levels and remove redundant resource count check
Browse files Browse the repository at this point in the history
  • Loading branch information
bcmmbaga committed Aug 23, 2024
1 parent 6bd0947 commit 04e6a3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 6 additions & 0 deletions management/server/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,12 @@ func (a *Account) GetPeerNetworkMap(
objectCount := int64(len(peersToConnect) + len(expiredPeers) + len(routesUpdate) + len(firewallRules))
metrics.CountNetworkMapObjects(objectCount)
metrics.CountGetPeerNetworkMapDuration(time.Since(start))

if objectCount > 5000 {
log.WithContext(ctx).Tracef("account: %s has a total resource count of %d objects, "+
"peers to connect: %d, expired peers: %d, routes: %d, firewall rules: %d",
a.Id, objectCount, len(peersToConnect), len(expiredPeers), len(routesUpdate), len(firewallRules))
}
}

return nm
Expand Down
14 changes: 2 additions & 12 deletions management/server/sql_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (s *SqlStore) SaveAccount(ctx context.Context, account *Account) error {
defer func() {
elapsed := time.Since(start)
if elapsed > 1*time.Second {
log.WithContext(ctx).Warnf("SaveAccount for account %s exceeded 1s, took: %v", account.Id, elapsed)
log.WithContext(ctx).Tracef("SaveAccount for account %s exceeded 1s, took: %v", account.Id, elapsed)
}
}()

Expand Down Expand Up @@ -523,7 +523,7 @@ func (s *SqlStore) GetAccount(ctx context.Context, accountID string) (*Account,
defer func() {
elapsed := time.Since(start)
if elapsed > 1*time.Second {
log.WithContext(ctx).Warnf("GetAccount for account %s exceeded 1s, took: %v", accountID, elapsed)
log.WithContext(ctx).Tracef("GetAccount for account %s exceeded 1s, took: %v", accountID, elapsed)
}
}()

Expand Down Expand Up @@ -590,16 +590,6 @@ func (s *SqlStore) GetAccount(ctx context.Context, accountID string) (*Account,
}
account.NameServerGroupsG = nil

totalObjects := len(account.Policies) +
len(account.RoutesG) +
len(account.SetupKeysG) +
len(account.PeersG) +
len(account.NameServerGroupsG) +
len(account.Policies)
if totalObjects > 5000 {
log.WithContext(ctx).Debugf("account: %s has a total resource count of %d objects, exceeding 5,000", accountID, totalObjects)
}

return &account, nil
}

Expand Down

0 comments on commit 04e6a3d

Please sign in to comment.