Skip to content

Commit ff66346

Browse files
author
arpechenin
committed
- move to the latest version of grpc-prometheus
Signed-off-by: arpechenin <[email protected]>
1 parent 92d2eb6 commit ff66346

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

backend/src/apiserver/main.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import (
2727
"strings"
2828
"sync"
2929

30-
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
31-
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
30+
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
3231

3332
"github.com/fsnotify/fsnotify"
3433
"github.com/golang/glog"
@@ -212,16 +211,23 @@ func startRpcServer(resourceManager *resource.ResourceManager) {
212211
glog.Fatalf("Failed to start RPC server: %v", err)
213212
}
214213

215-
grpc_prometheus.EnableHandlingTimeHistogram(
216-
grpc_prometheus.WithHistogramBuckets([]float64{
217-
0.01, 0.03, 0.1, 0.3, 1, 3, 10, 15, 30, 60, 120, 300, //10 ms -> 5 min
218-
}),
214+
metrics := grpc_prometheus.NewServerMetrics(
215+
grpc_prometheus.WithServerHandlingTimeHistogram(
216+
grpc_prometheus.WithHistogramBuckets([]float64{
217+
0.01, 0.03, 0.1, 0.3, 1, 3, 10, 15, 30, 60, 120, 300,
218+
}),
219+
),
219220
)
220-
m := grpc_middleware.WithUnaryServerChain(
221-
apiServerInterceptor,
222-
grpc_prometheus.UnaryServerInterceptor,
221+
222+
s := grpc.NewServer(
223+
grpc.ChainUnaryInterceptor(
224+
apiServerInterceptor,
225+
metrics.UnaryServerInterceptor(),
226+
),
227+
grpc.MaxRecvMsgSize(math.MaxInt32),
223228
)
224-
s := grpc.NewServer(m, grpc.MaxRecvMsgSize(math.MaxInt32))
229+
230+
metrics.InitializeMetrics(s)
225231

226232
sharedExperimentServer := server.NewExperimentServer(resourceManager, &server.ExperimentServerOptions{CollectMetrics: *collectMetricsFlag})
227233
sharedPipelineServer := server.NewPipelineServer(

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ require (
2525
github.com/google/go-cmp v0.6.0
2626
github.com/google/uuid v1.6.0
2727
github.com/gorilla/mux v1.8.0
28+
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0
2829
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2
2930
github.com/grpc-ecosystem/grpc-gateway v1.16.0
3031
github.com/jackc/pgx/v5 v5.5.4

go.sum

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)