github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/cmd/dockerd/metrics.go (about) 1 package main 2 3 import ( 4 "net" 5 "net/http" 6 7 metrics "github.com/docker/go-metrics" 8 "github.com/sirupsen/logrus" 9 ) 10 11 func startMetricsServer(addr string) error { 12 if err := allocateDaemonPort(addr); err != nil { 13 return err 14 } 15 l, err := net.Listen("tcp", addr) 16 if err != nil { 17 return err 18 } 19 mux := http.NewServeMux() 20 mux.Handle("/metrics", metrics.Handler()) 21 go func() { 22 if err := http.Serve(l, mux); err != nil { 23 logrus.Errorf("serve metrics api: %s", err) 24 } 25 }() 26 return nil 27 }