[#451] metrics: Move to internal

`metrics` don't look like something others want to import.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-06-24 17:12:26 +03:00 committed by Evgenii Stratonikov
parent 11a38a0a84
commit 81ea91de52
35 changed files with 14 additions and 14 deletions

35
internal/metrics/grpc.go Normal file
View 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))
}