Skip to content

Commit

Permalink
Expose metrics views in a slice (#327)
Browse files Browse the repository at this point in the history
* Expose metrics views in a slice

* Rename Views to DefaultViews

This communicates that these aren't the only views that are possible, or that they should be considered mandatory.
  • Loading branch information
anacrolix authored Apr 25, 2019
1 parent 080cd52 commit 691b1e5
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,56 +41,55 @@ var (
SentBytes = stats.Int64("libp2p.io/dht/kad/sent_bytes", "Total sent bytes per RPC", stats.UnitBytes)
)

// Views
var (
ReceivedMessagesView = &view.View{
var DefaultViews = []*view.View{
&view.View{
Measure: ReceivedMessages,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: view.Count(),
}
ReceivedMessageErrorsView = &view.View{
},
&view.View{
Measure: ReceivedMessageErrors,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: view.Count(),
}
ReceivedBytesView = &view.View{
},
&view.View{
Measure: ReceivedBytes,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: defaultBytesDistribution,
}
InboundRequestLatencyView = &view.View{
},
&view.View{
Measure: InboundRequestLatency,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: defaultMillisecondsDistribution,
}
OutboundRequestLatencyView = &view.View{
},
&view.View{
Measure: OutboundRequestLatency,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: defaultMillisecondsDistribution,
}
SentMessagesView = &view.View{
},
&view.View{
Measure: SentMessages,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: view.Count(),
}
SentMessageErrorsView = &view.View{
},
&view.View{
Measure: SentMessageErrors,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: view.Count(),
}
SentRequestsView = &view.View{
},
&view.View{
Measure: SentRequests,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: view.Count(),
}
SentRequestErrorsView = &view.View{
},
&view.View{
Measure: SentRequestErrors,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: view.Count(),
}
SentBytesView = &view.View{
},
&view.View{
Measure: SentBytes,
TagKeys: []tag.Key{KeyMessageType, KeyPeerID, KeyInstanceID},
Aggregation: defaultBytesDistribution,
}
)
},
}

0 comments on commit 691b1e5

Please sign in to comment.