From 06e3f5def565f60f0b9dd48a26dae439d168536d Mon Sep 17 00:00:00 2001 From: Travis Groth Date: Fri, 29 May 2020 15:57:58 -0400 Subject: [PATCH] Fix missing/incorrect grpc labels (#804) --- internal/cmd/pomerium/pomerium.go | 2 +- internal/controlplane/server.go | 4 ++-- internal/telemetry/grpc.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/cmd/pomerium/pomerium.go b/internal/cmd/pomerium/pomerium.go index a5b6c86d9..cb5785ec5 100644 --- a/internal/cmd/pomerium/pomerium.go +++ b/internal/cmd/pomerium/pomerium.go @@ -50,7 +50,7 @@ func Run(ctx context.Context, configFile string) error { } // setup the control plane - controlPlane, err := controlplane.NewServer() + controlPlane, err := controlplane.NewServer(opt.Services) if err != nil { return fmt.Errorf("error creating control plane: %w", err) } diff --git a/internal/controlplane/server.go b/internal/controlplane/server.go index 6a92fcbdd..6919ae297 100644 --- a/internal/controlplane/server.go +++ b/internal/controlplane/server.go @@ -47,7 +47,7 @@ type Server struct { } // NewServer creates a new Server. Listener ports are chosen by the OS. -func NewServer() (*Server, error) { +func NewServer(name string) (*Server, error) { srv := &Server{ configUpdated: make(chan struct{}, 1), } @@ -61,7 +61,7 @@ func NewServer() (*Server, error) { return nil, err } srv.GRPCServer = grpc.NewServer( - grpc.StatsHandler(telemetry.NewGRPCServerStatsHandler("control_plane")), + grpc.StatsHandler(telemetry.NewGRPCServerStatsHandler(name)), grpc.UnaryInterceptor(requestid.UnaryServerInterceptor()), grpc.StreamInterceptor(requestid.StreamServerInterceptor()), ) diff --git a/internal/telemetry/grpc.go b/internal/telemetry/grpc.go index 4e1940438..24c05e742 100644 --- a/internal/telemetry/grpc.go +++ b/internal/telemetry/grpc.go @@ -23,10 +23,10 @@ type GRPCServerStatsHandler struct { // TagRPC implements grpc.stats.Handler and adds metrics and tracing metadata to the context of a given RPC func (h *GRPCServerStatsHandler) TagRPC(ctx context.Context, tagInfo *grpcstats.RPCTagInfo) context.Context { - metricCtx := h.metricsHandler.TagRPC(ctx, tagInfo) - handledCtx := h.Handler.TagRPC(metricCtx, tagInfo) + handledCtx := h.Handler.TagRPC(ctx, tagInfo) + metricCtx := h.metricsHandler.TagRPC(handledCtx, tagInfo) - return handledCtx + return metricCtx } // NewGRPCServerStatsHandler creates a new GRPCServerStatsHandler for a pomerium service