1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #40427 from thaJeztah/prometheus_remove_experimental

Do not require "experimental" for metrics API
This commit is contained in:
Tibor Vass 2020-05-08 11:10:53 -07:00 committed by GitHub
commit 298ba5b131
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View file

@ -205,8 +205,8 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
cli.d = d
if err := cli.startMetricsServer(cli.Config.MetricsAddress); err != nil {
return err
if err := startMetricsServer(cli.Config.MetricsAddress); err != nil {
return errors.Wrap(err, "failed to start metrics server")
}
c, err := createAndStartCluster(cli, d)

View file

@ -3,21 +3,16 @@ package main
import (
"net"
"net/http"
"strings"
metrics "github.com/docker/go-metrics"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
func (cli *DaemonCli) startMetricsServer(addr string) error {
func startMetricsServer(addr string) error {
if addr == "" {
return nil
}
if !cli.d.HasExperimental() {
return errors.New("metrics-addr is only supported when experimental is enabled")
}
if err := allocateDaemonPort(addr); err != nil {
return err
}
@ -28,8 +23,9 @@ func (cli *DaemonCli) startMetricsServer(addr string) error {
mux := http.NewServeMux()
mux.Handle("/metrics", metrics.Handler())
go func() {
if err := http.Serve(l, mux); err != nil {
logrus.Errorf("serve metrics api: %s", err)
logrus.Infof("metrics API listening on %s", l.Addr())
if err := http.Serve(l, mux); err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
logrus.WithError(err).Error("error serving metrics API")
}
}()
return nil

View file

@ -6,6 +6,7 @@ import (
"net"
"net/http"
"path/filepath"
"strings"
"github.com/docker/docker/pkg/plugingetter"
"github.com/docker/docker/pkg/plugins"
@ -28,7 +29,10 @@ func (daemon *Daemon) listenMetricsSock() (string, error) {
mux := http.NewServeMux()
mux.Handle("/metrics", metrics.Handler())
go func() {
http.Serve(l, mux)
logrus.Debugf("metrics API listening on %s", l.Addr())
if err := http.Serve(l, mux); err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
logrus.WithError(err).Error("error serving metrics API")
}
}()
daemon.metricsPluginListener = l
return path, nil