mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-24 09:03:14 +01:00
Fix error handling (#2316)
This commit is contained in:
parent
268e801ec5
commit
63aeeb834d
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user