mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-21 07:33:21 +01:00
[management] Add metric for peer meta update (#2913)
This commit is contained in:
parent
5dd6a08ea6
commit
f66bbcc54c
@ -667,6 +667,7 @@ func (am *DefaultAccountManager) SyncPeer(ctx context.Context, sync PeerSync, ac
|
|||||||
|
|
||||||
updated := peer.UpdateMetaIfNew(sync.Meta)
|
updated := peer.UpdateMetaIfNew(sync.Meta)
|
||||||
if updated {
|
if updated {
|
||||||
|
am.metrics.AccountManagerMetrics().CountPeerMetUpdate()
|
||||||
account.Peers[peer.ID] = peer
|
account.Peers[peer.ID] = peer
|
||||||
log.WithContext(ctx).Tracef("peer %s metadata updated", peer.ID)
|
log.WithContext(ctx).Tracef("peer %s metadata updated", peer.ID)
|
||||||
err = am.Store.SavePeer(ctx, account.Id, peer)
|
err = am.Store.SavePeer(ctx, account.Id, peer)
|
||||||
@ -801,6 +802,7 @@ func (am *DefaultAccountManager) LoginPeer(ctx context.Context, login PeerLogin)
|
|||||||
|
|
||||||
updated := peer.UpdateMetaIfNew(login.Meta)
|
updated := peer.UpdateMetaIfNew(login.Meta)
|
||||||
if updated {
|
if updated {
|
||||||
|
am.metrics.AccountManagerMetrics().CountPeerMetUpdate()
|
||||||
shouldStorePeer = true
|
shouldStorePeer = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ type AccountManagerMetrics struct {
|
|||||||
updateAccountPeersDurationMs metric.Float64Histogram
|
updateAccountPeersDurationMs metric.Float64Histogram
|
||||||
getPeerNetworkMapDurationMs metric.Float64Histogram
|
getPeerNetworkMapDurationMs metric.Float64Histogram
|
||||||
networkMapObjectCount metric.Int64Histogram
|
networkMapObjectCount metric.Int64Histogram
|
||||||
|
peerMetaUpdateCount metric.Int64Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAccountManagerMetrics creates an instance of AccountManagerMetrics
|
// NewAccountManagerMetrics creates an instance of AccountManagerMetrics
|
||||||
@ -44,11 +45,17 @@ func NewAccountManagerMetrics(ctx context.Context, meter metric.Meter) (*Account
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peerMetaUpdateCount, err := meter.Int64Counter("management.account.peer.meta.update.counter", metric.WithUnit("1"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &AccountManagerMetrics{
|
return &AccountManagerMetrics{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
getPeerNetworkMapDurationMs: getPeerNetworkMapDurationMs,
|
getPeerNetworkMapDurationMs: getPeerNetworkMapDurationMs,
|
||||||
updateAccountPeersDurationMs: updateAccountPeersDurationMs,
|
updateAccountPeersDurationMs: updateAccountPeersDurationMs,
|
||||||
networkMapObjectCount: networkMapObjectCount,
|
networkMapObjectCount: networkMapObjectCount,
|
||||||
|
peerMetaUpdateCount: peerMetaUpdateCount,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -67,3 +74,8 @@ func (metrics *AccountManagerMetrics) CountGetPeerNetworkMapDuration(duration ti
|
|||||||
func (metrics *AccountManagerMetrics) CountNetworkMapObjects(count int64) {
|
func (metrics *AccountManagerMetrics) CountNetworkMapObjects(count int64) {
|
||||||
metrics.networkMapObjectCount.Record(metrics.ctx, count)
|
metrics.networkMapObjectCount.Record(metrics.ctx, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CountPeerMetUpdate counts the number of peer meta updates
|
||||||
|
func (metrics *AccountManagerMetrics) CountPeerMetUpdate() {
|
||||||
|
metrics.peerMetaUpdateCount.Add(metrics.ctx, 1)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user