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() } }