Skip to content

Commit

Permalink
rpc info removes metric if not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricfung committed Nov 1, 2023
1 parent 06fb49c commit db2fe59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions network/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func (p *Peer) disconnect() {
}

func (me *Peer) Metric() map[string]*MetricPool {
if !me.sentMetric.enabled && me.receivedMetric.enabled {
return nil
}
return map[string]*MetricPool{
"sent": me.sentMetric,
"received": me.receivedMetric,
Expand Down
6 changes: 4 additions & 2 deletions rpc/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ func getInfo(store storage.Store, node *kernel.Node) (map[string]any, error) {
"caches": caches,
"state": state,
}
info["metric"] = map[string]any{
"transport": node.Peer.Metric(),
if metric := node.Peer.Metric(); metric != nil {
info["metric"] = map[string]any{
"transport": metric,
}
}
return info, nil
}
Expand Down

0 comments on commit db2fe59

Please sign in to comment.