Collect statistics about transaction explorer views
This commit is contained in:
parent
e082ca3bb7
commit
049b4d21f0
@ -17,6 +17,7 @@ type Metrics struct {
|
|||||||
RPCLatency *prometheus.HistogramVec
|
RPCLatency *prometheus.HistogramVec
|
||||||
IndexResyncErrors *prometheus.CounterVec
|
IndexResyncErrors *prometheus.CounterVec
|
||||||
IndexDBSize prometheus.Gauge
|
IndexDBSize prometheus.Gauge
|
||||||
|
TxExplorerRedirects *prometheus.CounterVec
|
||||||
}
|
}
|
||||||
|
|
||||||
type Labels = prometheus.Labels
|
type Labels = prometheus.Labels
|
||||||
@ -104,6 +105,14 @@ func GetMetrics(coin string) (*Metrics, error) {
|
|||||||
ConstLabels: Labels{"coin": coin},
|
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)
|
v := reflect.ValueOf(metrics)
|
||||||
for i := 0; i < v.NumField(); i++ {
|
for i := 0; i < v.NumField(); i++ {
|
||||||
|
|||||||
@ -128,6 +128,7 @@ func (s *SocketIoServer) Shutdown(ctx context.Context) error {
|
|||||||
func (s *SocketIoServer) txRedirect(w http.ResponseWriter, r *http.Request) {
|
func (s *SocketIoServer) txRedirect(w http.ResponseWriter, r *http.Request) {
|
||||||
if s.explorerURL != "" {
|
if s.explorerURL != "" {
|
||||||
http.Redirect(w, r, s.explorerURL+r.URL.Path, 302)
|
http.Redirect(w, r, s.explorerURL+r.URL.Path, 302)
|
||||||
|
s.metrics.TxExplorerRedirects.With(common.Labels{}).Inc()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user