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>
This commit is contained in:
Ian Cottrell 2019-07-16 19:56:49 -04:00
parent e98af23098
commit 128ec6dfca
1 changed files with 8 additions and 3 deletions

View File

@ -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() {},
}
}