Fix error handling (#2316)

This commit is contained in:
Zoltan Papp 2024-07-24 13:27:01 +02:00 committed by GitHub
parent 268e801ec5
commit 63aeeb834d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -90,7 +90,7 @@ var (
return err
}
metricsServer := metrics.NewServer(metricsPort, "")
metricsServer, err := metrics.NewServer(metricsPort, "")
if err != nil {
return fmt.Errorf("setup metrics: %v", err)
}

View File

@ -26,10 +26,10 @@ type Metrics struct {
}
// NewServer initializes and returns a new Metrics instance
func NewServer(port int, endpoint string) *Metrics {
func NewServer(port int, endpoint string) (*Metrics, error) {
exporter, err := prometheus.New()
if err != nil {
return nil
return nil, err
}
provider := metric.NewMeterProvider(metric.WithReader(exporter))
@ -57,7 +57,7 @@ func NewServer(port int, endpoint string) *Metrics {
provider: provider,
Endpoint: endpoint,
Server: server,
}
}, nil
}
// Shutdown stops the metrics server