Add grpc prometheus metrics

This provideds generic grpc metrics via prometheus

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2017-03-14 16:16:49 -07:00
parent a85c28d248
commit f9212348e4
11 changed files with 921 additions and 2 deletions

View file

@ -6,6 +6,7 @@ import (
_ "github.com/docker/containerd/services/content"
_ "github.com/docker/containerd/services/execution"
_ "github.com/docker/containerd/services/healthcheck"
_ "github.com/docker/containerd/services/metrics"
_ "github.com/docker/containerd/snapshot/btrfs"
_ "github.com/docker/containerd/snapshot/overlay"
)

View file

@ -11,6 +11,7 @@ import (
"syscall"
"time"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
gocontext "golang.org/x/net/context"
"google.golang.org/grpc"
@ -296,7 +297,10 @@ func loadSnapshotter(store *content.Store) (snapshot.Snapshotter, error) {
}
func newGRPCServer() *grpc.Server {
s := grpc.NewServer(grpc.UnaryInterceptor(interceptor))
s := grpc.NewServer(
grpc.UnaryInterceptor(interceptor),
grpc.StreamInterceptor(grpc_prometheus.StreamServerInterceptor),
)
return s
}
@ -365,7 +369,7 @@ func interceptor(ctx gocontext.Context,
default:
fmt.Printf("unknown GRPC server type: %#v\n", info.Server)
}
return handler(ctx, req)
return grpc_prometheus.UnaryServerInterceptor(ctx, req, info, handler)
}
func handleSignals(signals chan os.Signal, server *grpc.Server) error {