Skip to content

Commit

Permalink
[ws-manager] Replace our own gRPC prom metrics with grpc_ecosystem
Browse files Browse the repository at this point in the history
Fixes #3090
  • Loading branch information
Christian Weichel committed Feb 8, 2021
1 parent 39a3c78 commit e4f611d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 170 deletions.
43 changes: 0 additions & 43 deletions components/common-go/grpc/metrics.go

This file was deleted.

12 changes: 7 additions & 5 deletions components/ws-manager/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -66,21 +67,21 @@ var runCmd = &cobra.Command{
ratelimits := grpc_gitpod.NewRatelimitingInterceptor(cfg.RPCServer.RateLimits)

reg := prometheus.NewRegistry()
callMetrics, err := grpc_gitpod.NewUnaryCallMetricsInterceptor(prometheus.WrapRegistererWithPrefix("gitpod_ws_manager_", reg))
if err != nil {
log.WithError(err).Fatal("cannot register gRPC call metrics")
}
grpcMetrics := grpc_prometheus.NewServerMetrics()
grpcMetrics.EnableHandlingTimeHistogram()
reg.MustRegister(grpcMetrics)

grpcOpts := []grpc.ServerOption{
// We don't know how good our cients are at closing connections. If they don't close them properly
// we'll be leaking goroutines left and right. Closing Idle connections should prevent that.
grpc.KeepaliveParams(keepalive.ServerParameters{MaxConnectionIdle: 30 * time.Minute}),
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
grpcMetrics.StreamServerInterceptor(),
grpc_opentracing.StreamServerInterceptor(grpc_opentracing.WithTracer(opentracing.GlobalTracer())),
)),
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
// add call metrics first to capture ratelimit errors
callMetrics,
grpcMetrics.UnaryServerInterceptor(),
ratelimits.UnaryInterceptor(),
grpc_opentracing.UnaryServerInterceptor(grpc_opentracing.WithTracer(opentracing.GlobalTracer())),
)),
Expand All @@ -98,6 +99,7 @@ var runCmd = &cobra.Command{

grpcServer := grpc.NewServer(grpcOpts...)
defer grpcServer.Stop()
grpc_prometheus.Register(grpcServer)

manager.Register(grpcServer, mgmt)
lis, err := net.Listen("tcp", cfg.RPCServer.Addr)
Expand Down
7 changes: 1 addition & 6 deletions components/ws-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ replace github.com/Sirupsen/logrus v1.6.0 => github.com/sirupsen/logrus v1.6.0 /
require (
github.com/alecthomas/jsonschema v0.0.0-20190504002508-159cbd5dba26
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 // indirect
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/coreos/go-etcd v2.0.0+incompatible // indirect
github.com/cpuguy83/go-md2man v1.0.10 // indirect
github.com/gitpod-io/gitpod/common-go v0.0.0-00010101000000-000000000000
github.com/gitpod-io/gitpod/content-service v0.0.0-00010101000000-000000000000
github.com/gitpod-io/gitpod/content-service/api v0.0.0-00010101000000-000000000000
Expand All @@ -27,15 +24,13 @@ require (
github.com/golang/protobuf v1.4.3
github.com/google/uuid v1.1.4
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/imdario/mergo v0.3.8
github.com/minio/minio-go/v6 v6.0.56 // indirect
github.com/opentracing/opentracing-go v1.1.0
github.com/prometheus/client_golang v1.1.0
github.com/sirupsen/logrus v1.7.0
github.com/spf13/afero v1.2.2
github.com/spf13/cobra v1.1.1
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8 // indirect
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 // indirect
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
google.golang.org/grpc v1.34.0
Expand Down
Loading

0 comments on commit e4f611d

Please sign in to comment.