mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-27 05:42:56 +00:00
31 lines
582 B
Go
31 lines
582 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
// Metrics used in monitoring service.
|
|
var rpcCounter = map[string]prometheus.Counter{}
|
|
|
|
func incCounter(name string) {
|
|
ctr, ok := rpcCounter[name]
|
|
if ok {
|
|
ctr.Inc()
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
for call := range rpcHandlers {
|
|
ctr := prometheus.NewCounter(
|
|
prometheus.CounterOpts{
|
|
Help: fmt.Sprintf("Number of calls to %s rpc endpoint", call),
|
|
Name: fmt.Sprintf("%s_called", call),
|
|
Namespace: "neogo",
|
|
},
|
|
)
|
|
prometheus.MustRegister(ctr)
|
|
rpcCounter[call] = ctr
|
|
}
|
|
}
|