From b1cdfd15c4611b1a9daada5051f3ebb002de71f6 Mon Sep 17 00:00:00 2001 From: Ian Cottrell Date: Mon, 4 Nov 2019 16:58:21 -0500 Subject: [PATCH] internal/lsp: restore the rpc metrics The special handler was dropped in cl/191963 which moved the logging functionality, but was still needed for the rpc metrics Change-Id: I494ef47646fe0d705709694378dbc981b549622a Reviewed-on: https://go-review.googlesource.com/c/tools/+/205164 Run-TryBot: Ian Cottrell TryBot-Result: Gobot Gobot Reviewed-by: Rebecca Stambler --- internal/lsp/cmd/serve.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/lsp/cmd/serve.go b/internal/lsp/cmd/serve.go index ceca1f1d11..79b4546ee1 100644 --- a/internal/lsp/cmd/serve.go +++ b/internal/lsp/cmd/serve.go @@ -81,10 +81,11 @@ func (s *Serve) Run(ctx context.Context, args ...string) error { return s.forward() } - // For debugging purposes only. - run := func(ctx context.Context, srv *lsp.Server) { - go srv.Run(ctx) + prepare := func(ctx context.Context, srv *lsp.Server) *lsp.Server { + srv.Conn.AddHandler(&handler{}) + return srv } + run := func(ctx context.Context, srv *lsp.Server) { go prepare(ctx, srv).Run(ctx) } if s.Address != "" { return lsp.RunServerOnAddress(ctx, s.app.cache, s.Address, run) } @@ -96,7 +97,7 @@ func (s *Serve) Run(ctx context.Context, args ...string) error { stream = protocol.LoggingStream(stream, out) } ctx, srv := lsp.NewServer(ctx, s.app.cache, stream) - return srv.Run(ctx) + return prepare(ctx, srv).Run(ctx) } func (s *Serve) forward() error { @@ -119,9 +120,7 @@ func (s *Serve) forward() error { return <-errc } -type handler struct { - out io.Writer -} +type handler struct{} type rpcStats struct { method string