diff --git a/internal/lsp/debug/rpc.go b/internal/lsp/debug/rpc.go index 39574c10cb..86829069bc 100644 --- a/internal/lsp/debug/rpc.go +++ b/internal/lsp/debug/rpc.go @@ -11,6 +11,7 @@ import ( "log" "net/http" "sort" + "sync" tlm "golang.org/x/tools/internal/lsp/telemetry" "golang.org/x/tools/internal/telemetry" @@ -42,6 +43,7 @@ var rpcTmpl = template.Must(template.Must(baseTemplate.Clone()).Parse(` `)) type rpcs struct { + mu sync.Mutex Inbound []*rpcStats Outbound []*rpcStats } @@ -91,6 +93,8 @@ type rpcCodeBucket struct { } func (r *rpcs) Metric(ctx context.Context, data telemetry.MetricData) { + r.mu.Lock() + defer r.mu.Unlock() for i, group := range data.Groups() { set := &r.Inbound if group.Get(tlm.RPCDirection) == tlm.Outbound { diff --git a/internal/telemetry/metric.go b/internal/telemetry/metric.go index 071dbbcd7e..c21303752c 100644 --- a/internal/telemetry/metric.go +++ b/internal/telemetry/metric.go @@ -4,7 +4,7 @@ package telemetry -// Data represents a single point in the time series of a metric. +// MetricData represents a single point in the time series of a metric. // This provides the common interface to all metrics no matter their data // format. // To get the actual values for the metric you must type assert to a concrete