diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2022-06-03 13:25:31 +0300 |
---|---|---|
committer | Vladimir Shushlin <vshushlin@gitlab.com> | 2022-06-03 13:25:31 +0300 |
commit | fd62cfc0771c627bd1bda001fd1fa71178dd447b (patch) | |
tree | dc70546496ad01228802f6fa6298c7ae7f7827ea /app.go | |
parent | 3c89945269c643b8b3b55d1d967c19922101c48c (diff) | |
parent | 1ddad1bd6ab55120e7862c61e033632b20e66d6f (diff) |
Merge branch 'tls-metrics' into 'master'
Add TLS for metrics
See merge request gitlab-org/gitlab-pages!772
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -277,8 +277,8 @@ func (a *theApp) Run() error { } // Serve metrics for Prometheus - if a.config.General.MetricsAddress != "" { - s := a.listenMetrics(eg, a.config.General.MetricsAddress) + if a.config.Metrics.Address != "" { + s := a.listenMetrics(eg, a.config.Metrics) servers = append(servers, s) } @@ -322,13 +322,17 @@ func (a *theApp) listen(eg *errgroup.Group, addr string, h http.Handler, errTrac return server } -func (a *theApp) listenMetrics(eg *errgroup.Group, addr string) *http.Server { +func (a *theApp) listenMetrics(eg *errgroup.Group, config cfg.Metrics) *http.Server { server := &http.Server{} eg.Go(func() error { - l, err := net.Listen("tcp", addr) + l, err := net.Listen("tcp", config.Address) if err != nil { errortracking.CaptureErrWithStackTrace(err, errortracking.WithField("listener", "metrics")) - return fmt.Errorf("failed to listen on addr %s: %w", addr, err) + return fmt.Errorf("failed to listen on addr %s: %w", config.Address, err) + } + + if config.TLSConfig != nil { + l = cryptotls.NewListener(l, config.TLSConfig) } monitoringOpts := []monitoring.Option{ |