Skip to content

Commit b1cdfd1

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
1 parent 64da2da commit b1cdfd1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

internal/lsp/cmd/serve.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ func (s *Serve) Run(ctx context.Context, args ...string) error {
8181
return s.forward()
8282
}
8383

84-
// For debugging purposes only.
85-
run := func(ctx context.Context, srv *lsp.Server) {
86-
go srv.Run(ctx)
84+
prepare := func(ctx context.Context, srv *lsp.Server) *lsp.Server {
85+
srv.Conn.AddHandler(&handler{})
86+
return srv
8787
}
88+
run := func(ctx context.Context, srv *lsp.Server) { go prepare(ctx, srv).Run(ctx) }
8889
if s.Address != "" {
8990
return lsp.RunServerOnAddress(ctx, s.app.cache, s.Address, run)
9091
}
@@ -96,7 +97,7 @@ func (s *Serve) Run(ctx context.Context, args ...string) error {
9697
stream = protocol.LoggingStream(stream, out)
9798
}
9899
ctx, srv := lsp.NewServer(ctx, s.app.cache, stream)
99-
return srv.Run(ctx)
100+
return prepare(ctx, srv).Run(ctx)
100101
}
101102

102103
func (s *Serve) forward() error {
@@ -119,9 +120,7 @@ func (s *Serve) forward() error {
119120
return <-errc
120121
}
121122

122-
type handler struct {
123-
out io.Writer
124-
}
123+
type handler struct{}
125124

126125
type rpcStats struct {
127126
method string

0 commit comments

Comments
 (0)