From 128ec6dfca091cc7d4fe6d18d97911f37c95a590 Mon Sep 17 00:00:00 2001 From: Ian Cottrell Date: Tue, 16 Jul 2019 19:56:49 -0400 Subject: [PATCH] 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 Reviewed-by: Rebecca Stambler TryBot-Result: Gobot Gobot --- internal/lsp/cmd/serve.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/lsp/cmd/serve.go b/internal/lsp/cmd/serve.go index 5e7d46da..39cf087e 100644 --- a/internal/lsp/cmd/serve.go +++ b/internal/lsp/cmd/serve.go @@ -148,17 +148,18 @@ func (h *handler) Request(ctx context.Context, direction jsonrpc2.Direction, r * 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) Error(ctx context.Context, err error) { 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() {}, } }