1
0
Fork 0

Use ServiceName in traefik_service_server_up metric

This commit is contained in:
krishna sindhur 2024-07-29 15:22:05 +05:30 committed by GitHub
parent 266a2d8b91
commit 386c2ffb20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 15 deletions

View file

@ -50,11 +50,12 @@ type ServiceHealthChecker struct {
metrics metricsHealthCheck
client *http.Client
targets map[string]*url.URL
client *http.Client
targets map[string]*url.URL
serviceName string
}
func NewServiceHealthChecker(ctx context.Context, metrics metricsHealthCheck, config *dynamic.ServerHealthCheck, service StatusSetter, info *runtime.ServiceInfo, transport http.RoundTripper, targets map[string]*url.URL) *ServiceHealthChecker {
func NewServiceHealthChecker(ctx context.Context, metrics metricsHealthCheck, config *dynamic.ServerHealthCheck, service StatusSetter, info *runtime.ServiceInfo, transport http.RoundTripper, targets map[string]*url.URL, serviceName string) *ServiceHealthChecker {
logger := log.Ctx(ctx)
interval := time.Duration(config.Interval)
@ -80,14 +81,15 @@ func NewServiceHealthChecker(ctx context.Context, metrics metricsHealthCheck, co
}
return &ServiceHealthChecker{
balancer: service,
info: info,
config: config,
interval: interval,
timeout: timeout,
targets: targets,
client: client,
metrics: metrics,
balancer: service,
info: info,
config: config,
interval: interval,
timeout: timeout,
targets: targets,
serviceName: serviceName,
client: client,
metrics: metrics,
}
}
@ -136,7 +138,7 @@ func (shc *ServiceHealthChecker) Launch(ctx context.Context) {
shc.info.UpdateServerStatus(target.String(), statusStr)
shc.metrics.ServiceServerUpGauge().
With("service", proxyName, "url", target.String()).
With("service", shc.serviceName, "url", target.String()).
Set(serverUpMetricValue)
}
}