···3131 "text/tabwriter"
3232 "time"
33333434- grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/openmetrics/v2"
3434+ grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
3535 "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/retry"
3636 "github.com/peterbourgon/ff/v3/ffcli"
3737 "github.com/prometheus/client_golang/prometheus"
···129129 })
130130131131 clientMetricsOnce sync.Once
132132- clientMetrics *grpc_prometheus.ClientMetrics
132132+ clientMetrics *grpcprom.ClientMetrics
133133)
134134135135// set of repositories that we want to capture separate indexing metrics for
···14811481 opts := []grpc.DialOption{
14821482 grpc.WithTransportCredentials(insecure.NewCredentials()),
14831483 grpc.WithChainStreamInterceptor(
14841484- grpc_prometheus.StreamClientInterceptor(metrics),
14841484+ metrics.StreamClientInterceptor(),
14851485 internalActorStreamInterceptor(),
14861486 internalerrs.LoggingStreamClientInterceptor(logger),
14871487 internalerrs.PrometheusStreamClientInterceptor,
14881488 retry.StreamClientInterceptor(retryOpts...),
14891489 ),
14901490 grpc.WithChainUnaryInterceptor(
14911491- grpc_prometheus.UnaryClientInterceptor(metrics),
14911491+ metrics.UnaryClientInterceptor(),
14921492 internalActorUnaryInterceptor(),
14931493 internalerrs.LoggingUnaryClientInterceptor(logger),
14941494 internalerrs.PrometheusUnaryClientInterceptor,
···15241524//
15251525// This function panics if the metrics cannot be registered with the default
15261526// Prometheus registry.
15271527-func mustGetClientMetrics() *grpc_prometheus.ClientMetrics {
15271527+func mustGetClientMetrics() *grpcprom.ClientMetrics {
15281528 clientMetricsOnce.Do(func() {
15291529- clientMetrics = grpc_prometheus.NewRegisteredClientMetrics(prometheus.DefaultRegisterer,
15301530- grpc_prometheus.WithClientCounterOptions(),
15311531- grpc_prometheus.WithClientHandlingTimeHistogram(), // record the overall request latency for a gRPC request
15321532- grpc_prometheus.WithClientStreamRecvHistogram(), // record how long it takes for a client to receive a message during a streaming RPC
15331533- grpc_prometheus.WithClientStreamSendHistogram(), // record how long it takes for a client to send a message during a streaming RPC
15291529+ clientMetrics = grpcprom.NewClientMetrics(
15301530+ grpcprom.WithClientCounterOptions(),
15311531+ grpcprom.WithClientHandlingTimeHistogram(), // record the overall request latency for a gRPC request
15321532+ grpcprom.WithClientStreamRecvHistogram(), // record how long it takes for a client to receive a message during a streaming RPC
15331533+ grpcprom.WithClientStreamSendHistogram(), // record how long it takes for a client to send a message during a streaming RPC
15341534 )
15351535+15361536+ prometheus.DefaultRegisterer.MustRegister(clientMetrics)
15351537 })
1536153815371539 return clientMetrics
+10-8
cmd/zoekt-webserver/main.go
···3939 "sync"
4040 "time"
41414242- grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/openmetrics/v2"
4242+ grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
4343 "github.com/sourcegraph/mountinfo"
4444 zoektgrpc "github.com/sourcegraph/zoekt/cmd/zoekt-webserver/grpc/server"
4545 "github.com/sourcegraph/zoekt/grpc/internalerrs"
···647647 opts := []grpc.ServerOption{
648648 grpc.ChainStreamInterceptor(
649649 otelgrpc.StreamServerInterceptor(),
650650- grpc_prometheus.StreamServerInterceptor(metrics),
650650+ metrics.StreamServerInterceptor(),
651651 internalerrs.LoggingStreamServerInterceptor(logger),
652652 ),
653653 grpc.ChainUnaryInterceptor(
654654 otelgrpc.UnaryServerInterceptor(),
655655- grpc_prometheus.UnaryServerInterceptor(metrics),
655655+ metrics.UnaryServerInterceptor(),
656656 internalerrs.LoggingUnaryServerInterceptor(logger),
657657 ),
658658 }
···691691 })
692692693693 serverMetricsOnce sync.Once
694694- serverMetrics *grpc_prometheus.ServerMetrics
694694+ serverMetrics *grpcprom.ServerMetrics
695695)
696696697697// mustGetServerMetrics returns a singleton instance of the server metrics
···699699//
700700// This function panics if the metrics cannot be registered with the default
701701// Prometheus registry.
702702-func mustGetServerMetrics() *grpc_prometheus.ServerMetrics {
702702+func mustGetServerMetrics() *grpcprom.ServerMetrics {
703703 serverMetricsOnce.Do(func() {
704704- serverMetrics = grpc_prometheus.NewRegisteredServerMetrics(prometheus.DefaultRegisterer,
705705- grpc_prometheus.WithServerCounterOptions(),
706706- grpc_prometheus.WithServerHandlingTimeHistogram(), // record the overall response latency for a gRPC request)
704704+ serverMetrics = grpcprom.NewServerMetrics(
705705+ grpcprom.WithServerCounterOptions(),
706706+ grpcprom.WithServerHandlingTimeHistogram(), // record the overall response latency for a gRPC request)
707707 )
708708+709709+ prometheus.DefaultRegisterer.MustRegister(serverMetrics)
708710 })
709711710712 return serverMetrics
+7-16
go.mod
···1818 github.com/google/go-github/v27 v27.0.6
1919 github.com/google/slothfs v0.0.0-20190717100203-59c1163fd173
2020 github.com/grafana/regexp v0.0.0-20221123153739-15dc172cd2db
2121- github.com/grpc-ecosystem/go-grpc-middleware/providers/openmetrics/v2 v2.0.0-rc.3
2222- github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.2.0.20210128111500-3ff779b52992
2121+ github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.0-rc.0
2222+ github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0
2323 github.com/hashicorp/go-retryablehttp v0.7.4
2424 github.com/keegancsmith/rpc v1.3.0
2525 github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f
···3333 github.com/sourcegraph/go-ctags v0.0.0-20230111110657-c27675da7f71
3434 github.com/sourcegraph/log v0.0.0-20230711093019-40c57b632cca
3535 github.com/sourcegraph/mountinfo v0.0.0-20230106004439-7026e28cef67
3636- github.com/stretchr/testify v1.8.3
3636+ github.com/stretchr/testify v1.8.4
3737 github.com/uber/jaeger-client-go v2.30.0+incompatible
3838 github.com/uber/jaeger-lib v2.4.1+incompatible
3939 github.com/xanzy/go-gitlab v0.86.0
···5151 go.uber.org/atomic v1.11.0
5252 go.uber.org/automaxprocs v1.5.2
5353 golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
5454- golang.org/x/net v0.11.0
5454+ golang.org/x/net v0.14.0
5555 golang.org/x/oauth2 v0.9.0
5656 golang.org/x/sync v0.3.0
5757- golang.org/x/sys v0.9.0
5757+ golang.org/x/sys v0.11.0
5858 google.golang.org/grpc v1.56.1
5959 google.golang.org/protobuf v1.31.0
6060 gopkg.in/natefinch/lumberjack.v2 v2.2.1
···128128 go.opentelemetry.io/proto/otlp v0.20.0 // indirect
129129 go.uber.org/multierr v1.11.0 // indirect
130130 go.uber.org/zap v1.24.0 // indirect
131131- golang.org/x/crypto v0.10.0 // indirect
131131+ golang.org/x/crypto v0.12.0 // indirect
132132 golang.org/x/mod v0.11.0 // indirect
133133- golang.org/x/text v0.10.0 // indirect
133133+ golang.org/x/text v0.12.0 // indirect
134134 golang.org/x/time v0.3.0 // indirect
135135 golang.org/x/tools v0.10.0 // indirect
136136 google.golang.org/api v0.129.0 // indirect
···141141 gopkg.in/warnings.v0 v0.1.2 // indirect
142142 gopkg.in/yaml.v3 v3.0.1 // indirect
143143)
144144-145145-// As of https://github.com/grpc-ecosystem/go-grpc-middleware/blob/7ac0846398432dee083fd8bc4ad7abacf8147ff2/providers/openmetrics/go.mod#L7,
146146-// the latest release of the gRPC Prometheus middleware depends on a version of go-grpc-middleware that is two years old, and
147147-// is incompatible with the latest gRPC releases.
148148-//
149149-// The parent project is currently working around this by using a local replace directive in their go.mod file (which ensures
150150-// that they always use the current version of go-grpc-middleware that they're developing). Until this issue is fixed,
151151-// we'll need to ensure that we explicitly depend on the latest version of go-grpc-middleware (v2.0.0-rc.3) as of this writing.
152152-replace github.com/grpc-ecosystem/go-grpc-middleware/v2 => github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.3
153144154145go 1.18