Initial commit

Initial public review release v0.10.0
This commit is contained in:
alexvanin 2020-07-10 17:17:51 +03:00 committed by Stanislav Bogatyrev
commit dadfd90dcd
276 changed files with 46331 additions and 0 deletions

45
lib/peers/metrics.go Normal file
View file

@ -0,0 +1,45 @@
package peers
import (
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc/connectivity"
)
const stateLabel = "state"
var grpcConnections = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Help: "gRPC connections",
Name: "grpc_connections",
Namespace: "neofs",
},
[]string{stateLabel},
)
var conStates = []connectivity.State{
connectivity.Idle,
connectivity.Connecting,
connectivity.Ready,
connectivity.TransientFailure,
connectivity.Shutdown,
}
func updateMetrics(items map[connectivity.State]float64) {
for _, state := range conStates {
grpcConnections.With(prometheus.Labels{
stateLabel: state.String(),
}).Set(items[state])
}
}
func init() {
prometheus.MustRegister(
grpcConnections,
)
for _, state := range conStates {
grpcConnections.With(prometheus.Labels{
stateLabel: state.String(),
}).Set(0)
}
}