2019-07-08 19:22:37 -06:00
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package debug
|
|
|
|
|
|
|
|
import (
|
2020-03-10 21:09:39 -06:00
|
|
|
"golang.org/x/tools/internal/lsp/debug/tag"
|
2020-03-07 11:38:47 -07:00
|
|
|
"golang.org/x/tools/internal/telemetry/event"
|
2019-08-13 13:07:39 -06:00
|
|
|
"golang.org/x/tools/internal/telemetry/metric"
|
2019-07-08 19:22:37 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// the distributions we use for histograms
|
|
|
|
bytesDistribution = []int64{1 << 10, 1 << 11, 1 << 12, 1 << 14, 1 << 16, 1 << 20}
|
|
|
|
millisecondsDistribution = []float64{0.1, 0.5, 1, 2, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000}
|
|
|
|
|
|
|
|
receivedBytes = metric.HistogramInt64{
|
|
|
|
Name: "received_bytes",
|
|
|
|
Description: "Distribution of received bytes, by method.",
|
2020-03-10 21:52:14 -06:00
|
|
|
Keys: []event.Key{tag.RPCDirection, tag.Method},
|
2019-07-08 19:22:37 -06:00
|
|
|
Buckets: bytesDistribution,
|
2020-03-10 21:09:39 -06:00
|
|
|
}.Record(tag.ReceivedBytes)
|
2019-07-08 19:22:37 -06:00
|
|
|
|
|
|
|
sentBytes = metric.HistogramInt64{
|
|
|
|
Name: "sent_bytes",
|
|
|
|
Description: "Distribution of sent bytes, by method.",
|
2020-03-10 21:52:14 -06:00
|
|
|
Keys: []event.Key{tag.RPCDirection, tag.Method},
|
2019-07-08 19:22:37 -06:00
|
|
|
Buckets: bytesDistribution,
|
2020-03-10 21:09:39 -06:00
|
|
|
}.Record(tag.SentBytes)
|
2019-07-08 19:22:37 -06:00
|
|
|
|
|
|
|
latency = metric.HistogramFloat64{
|
|
|
|
Name: "latency",
|
|
|
|
Description: "Distribution of latency in milliseconds, by method.",
|
2020-03-10 21:52:14 -06:00
|
|
|
Keys: []event.Key{tag.RPCDirection, tag.Method},
|
2019-07-08 19:22:37 -06:00
|
|
|
Buckets: millisecondsDistribution,
|
2020-03-10 21:09:39 -06:00
|
|
|
}.Record(tag.Latency)
|
2019-07-08 19:22:37 -06:00
|
|
|
|
|
|
|
started = metric.Scalar{
|
|
|
|
Name: "started",
|
|
|
|
Description: "Count of RPCs started by method.",
|
2020-03-10 21:52:14 -06:00
|
|
|
Keys: []event.Key{tag.RPCDirection, tag.Method},
|
2020-03-10 21:09:39 -06:00
|
|
|
}.CountInt64(tag.Started)
|
2019-07-08 19:22:37 -06:00
|
|
|
|
|
|
|
completed = metric.Scalar{
|
|
|
|
Name: "completed",
|
|
|
|
Description: "Count of RPCs completed by method and status.",
|
2020-03-10 21:52:14 -06:00
|
|
|
Keys: []event.Key{tag.RPCDirection, tag.Method, tag.StatusCode},
|
2020-03-10 21:09:39 -06:00
|
|
|
}.CountFloat64(tag.Latency)
|
2019-07-08 19:22:37 -06:00
|
|
|
)
|