Merge pull request #1003 from crosbymichael/gprc-metrics

Register grpc metrics in main
This commit is contained in:
Derek McGowan 2017-06-14 13:04:59 -07:00 committed by GitHub
commit 6bbed2c125
3 changed files with 2 additions and 27 deletions

View File

@ -9,7 +9,6 @@ import (
_ "github.com/containerd/containerd/services/execution" _ "github.com/containerd/containerd/services/execution"
_ "github.com/containerd/containerd/services/healthcheck" _ "github.com/containerd/containerd/services/healthcheck"
_ "github.com/containerd/containerd/services/images" _ "github.com/containerd/containerd/services/images"
_ "github.com/containerd/containerd/services/metrics"
_ "github.com/containerd/containerd/services/namespaces" _ "github.com/containerd/containerd/services/namespaces"
_ "github.com/containerd/containerd/services/snapshot" _ "github.com/containerd/containerd/services/snapshot"
_ "github.com/containerd/containerd/services/version" _ "github.com/containerd/containerd/services/version"

View File

@ -147,6 +147,8 @@ func main() {
return err return err
} }
} }
// register metrics last after all other services
grpc_prometheus.Register(server)
log.G(global).Info("starting GRPC API server...") log.G(global).Info("starting GRPC API server...")
if err := serveGRPC(server); err != nil { if err := serveGRPC(server); err != nil {
return err return err

View File

@ -1,26 +0,0 @@
package metrics
import (
"github.com/containerd/containerd/plugin"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"google.golang.org/grpc"
)
func init() {
plugin.Register("metrics-grpc", &plugin.Registration{
Type: plugin.GRPCPlugin,
Init: New,
})
}
func New(_ *plugin.InitContext) (interface{}, error) {
return &Service{}, nil
}
type Service struct {
}
func (s *Service) Register(server *grpc.Server) error {
grpc_prometheus.Register(server)
return nil
}