From 691b1e5f8e70b71ce60e5bf11e2213be11d7cad5 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 25 Apr 2019 13:47:30 +1000 Subject: [PATCH] Expose metrics views in a slice (#327) * 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. --- metrics/metrics.go | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/metrics/metrics.go b/metrics/metrics.go index da07e7019..bbe480154 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -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, - } -) + }, +}