internal/lsp: fixed broken tracing
I dropped the line that added the stats to the context when merging the recent changes.
Change-Id: I66ab2958b0737360896b40bf30c5ca3c2cebbae5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/186300
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/cmd/serve.go b/internal/lsp/cmd/serve.go
index 5e7d46d..39cf087 100644
--- a/internal/lsp/cmd/serve.go
+++ b/internal/lsp/cmd/serve.go
@@ -148,17 +148,18 @@
if r.Method == "" {
panic("no method in rpc stats")
}
- s := &rpcStats{
+ stats := &rpcStats{
method: r.Method,
start: time.Now(),
direction: direction,
payload: r.Params,
}
+ ctx = context.WithValue(ctx, statsKey, stats)
mode := telemetry.Outbound
if direction == jsonrpc2.Receive {
mode = telemetry.Inbound
}
- ctx, s.close = trace.StartSpan(ctx, r.Method,
+ ctx, stats.close = trace.StartSpan(ctx, r.Method,
tag.Tag{Key: telemetry.Method, Value: r.Method},
tag.Tag{Key: telemetry.RPCDirection, Value: mode},
tag.Tag{Key: telemetry.RPCID, Value: r.ID},
@@ -207,8 +208,12 @@
func (h *handler) getStats(ctx context.Context) *rpcStats {
stats, ok := ctx.Value(statsKey).(*rpcStats)
if !ok || stats == nil {
+ method, ok := ctx.Value(telemetry.Method).(string)
+ if !ok {
+ method = "???"
+ }
stats = &rpcStats{
- method: "???",
+ method: method,
close: func() {},
}
}