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:
commit
298ba5b131
3 changed files with 12 additions and 12 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue