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:
parent
e98af23098
commit
128ec6dfca
|
@ -148,17 +148,18 @@ func (h *handler) Request(ctx context.Context, direction jsonrpc2.Direction, r *
|
||||||
if r.Method == "" {
|
if r.Method == "" {
|
||||||
panic("no method in rpc stats")
|
panic("no method in rpc stats")
|
||||||
}
|
}
|
||||||
s := &rpcStats{
|
stats := &rpcStats{
|
||||||
method: r.Method,
|
method: r.Method,
|
||||||
start: time.Now(),
|
start: time.Now(),
|
||||||
direction: direction,
|
direction: direction,
|
||||||
payload: r.Params,
|
payload: r.Params,
|
||||||
}
|
}
|
||||||
|
ctx = context.WithValue(ctx, statsKey, stats)
|
||||||
mode := telemetry.Outbound
|
mode := telemetry.Outbound
|
||||||
if direction == jsonrpc2.Receive {
|
if direction == jsonrpc2.Receive {
|
||||||
mode = telemetry.Inbound
|
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.Method, Value: r.Method},
|
||||||
tag.Tag{Key: telemetry.RPCDirection, Value: mode},
|
tag.Tag{Key: telemetry.RPCDirection, Value: mode},
|
||||||
tag.Tag{Key: telemetry.RPCID, Value: r.ID},
|
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 {
|
func (h *handler) getStats(ctx context.Context) *rpcStats {
|
||||||
stats, ok := ctx.Value(statsKey).(*rpcStats)
|
stats, ok := ctx.Value(statsKey).(*rpcStats)
|
||||||
if !ok || stats == nil {
|
if !ok || stats == nil {
|
||||||
|
method, ok := ctx.Value(telemetry.Method).(string)
|
||||||
|
if !ok {
|
||||||
|
method = "???"
|
||||||
|
}
|
||||||
stats = &rpcStats{
|
stats = &rpcStats{
|
||||||
method: "???",
|
method: method,
|
||||||
close: func() {},
|
close: func() {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue