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 <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/internal/lsp/cmd/serve.go b/internal/lsp/cmd/serve.go index ceca1f1..79b4546 100644 --- a/internal/lsp/cmd/serve.go +++ b/internal/lsp/cmd/serve.go
@@ -81,10 +81,11 @@ 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 @@ 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 @@ return <-errc } -type handler struct { - out io.Writer -} +type handler struct{} type rpcStats struct { method string