From 049b4d21f0437e928a8dc0846b81d757ae7e4cea Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Fri, 18 May 2018 17:10:25 +0200 Subject: [PATCH] Collect statistics about transaction explorer views --- common/metrics.go | 9 +++++++++ server/socketio.go | 1 + 2 files changed, 10 insertions(+) diff --git a/common/metrics.go b/common/metrics.go index e2100e75..51b5f970 100644 --- a/common/metrics.go +++ b/common/metrics.go @@ -17,6 +17,7 @@ type Metrics struct { RPCLatency *prometheus.HistogramVec IndexResyncErrors *prometheus.CounterVec IndexDBSize prometheus.Gauge + TxExplorerRedirects *prometheus.CounterVec } type Labels = prometheus.Labels @@ -104,6 +105,14 @@ func GetMetrics(coin string) (*Metrics, error) { ConstLabels: Labels{"coin": coin}, }, ) + metrics.TxExplorerRedirects = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Name: "blockbook_tx_explorer_views", + Help: "Number of views of the transaction explorer", + ConstLabels: Labels{"coin": coin}, + }, + []string{}, + ) v := reflect.ValueOf(metrics) for i := 0; i < v.NumField(); i++ { diff --git a/server/socketio.go b/server/socketio.go index d6835dfc..bade3398 100644 --- a/server/socketio.go +++ b/server/socketio.go @@ -128,6 +128,7 @@ func (s *SocketIoServer) Shutdown(ctx context.Context) error { func (s *SocketIoServer) txRedirect(w http.ResponseWriter, r *http.Request) { if s.explorerURL != "" { http.Redirect(w, r, s.explorerURL+r.URL.Path, 302) + s.metrics.TxExplorerRedirects.With(common.Labels{}).Inc() } }