forked from TrueCloudLab/frostfs-node
[#565] Add metrics for current GRPC endpoint status
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
c3e23a1448
commit
4ad0ebb32f
5 changed files with 50 additions and 0 deletions
35
pkg/metrics/grpc.go
Normal file
35
pkg/metrics/grpc.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
type GrpcServerMetrics interface {
|
||||
MarkHealthy(endpoint string)
|
||||
MarkUnhealthy(endpoint string)
|
||||
}
|
||||
|
||||
type grpcServerMetrics struct {
|
||||
endpointHealth *prometheus.GaugeVec
|
||||
}
|
||||
|
||||
func newGrpcServerMetrics() *grpcServerMetrics {
|
||||
return &grpcServerMetrics{
|
||||
endpointHealth: metrics.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: namespace,
|
||||
Subsystem: grpcServerSubsystem,
|
||||
Name: "health",
|
||||
Help: "GRPC Server Endpoint health",
|
||||
}, []string{endpointLabel}),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *grpcServerMetrics) MarkHealthy(endpoint string) {
|
||||
m.endpointHealth.With(prometheus.Labels{endpointLabel: endpoint}).Set(float64(1))
|
||||
}
|
||||
|
||||
func (m *grpcServerMetrics) MarkUnhealthy(endpoint string) {
|
||||
m.endpointHealth.With(prometheus.Labels{endpointLabel: endpoint}).Set(float64(0))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue