Enable grpc stats
Change-Id: I6a5f617510d33f1750b1aaea88d02df3ff78bb7a
Signed-off-by: Abhay Kumar <abhay.kumar@radisys.com>
diff --git a/internal/pkg/util/envutils/envutils.go b/internal/pkg/util/envutils/envutils.go
index 8ef7149..d31150e 100644
--- a/internal/pkg/util/envutils/envutils.go
+++ b/internal/pkg/util/envutils/envutils.go
@@ -79,6 +79,7 @@
// vgc environment variables
+ PrometheusPort = "PROMETHEUS_PORT"
DeviceListRefreshInterval = "DEVICE_LIST_REFRESH_INTERVAL" // in seconds
CPUProfile = "CPU_PROFILE"
MemProfile = "MEM_PROFILE"
diff --git a/internal/pkg/vpagent/connection.go b/internal/pkg/vpagent/connection.go
index e4f562b..c384cb2 100644
--- a/internal/pkg/vpagent/connection.go
+++ b/internal/pkg/vpagent/connection.go
@@ -23,7 +23,10 @@
"voltha-go-controller/log"
"github.com/golang/protobuf/ptypes/empty"
+ grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
+ grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/opencord/voltha-protos/v5/go/voltha"
+
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
@@ -39,8 +42,18 @@
vpa.volthaConnection = nil
vpa.volthaClient.Clear()
try := 1
+ grpc_prometheus.EnableClientHandlingTimeHistogram()
for vpa.ConnectionMaxRetries == 0 || try < vpa.ConnectionMaxRetries {
- conn, err := grpc.NewClient(vpa.VolthaAPIEndPoint, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(GrpcMaxSize)))
+ conn, err := grpc.NewClient(vpa.VolthaAPIEndPoint,
+ grpc.WithTransportCredentials(insecure.NewCredentials()),
+ grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(GrpcMaxSize)),
+ grpc.WithStreamInterceptor(grpc_middleware.ChainStreamClient(
+ grpc_prometheus.StreamClientInterceptor,
+ )),
+ grpc.WithUnaryInterceptor(grpc_middleware.ChainUnaryClient(
+ grpc_prometheus.UnaryClientInterceptor,
+ )))
+
if err == nil {
svc := voltha.NewVolthaServiceClient(conn)
if svc != nil {