Collect statistics about transaction explorer views

pull/7/head
Martin Boehm 2018-05-18 17:10:25 +02:00
parent e082ca3bb7
commit 049b4d21f0
2 changed files with 10 additions and 0 deletions

View File

@ -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++ {

View File

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