1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
8 "golang.org/x/tools/internal/event/export/metric"
9 "golang.org/x/tools/internal/event/label"
10 "golang.org/x/tools/internal/lsp/debug/tag"
14 // the distributions we use for histograms
15 bytesDistribution = []int64{1 << 10, 1 << 11, 1 << 12, 1 << 14, 1 << 16, 1 << 20}
16 millisecondsDistribution = []float64{0.1, 0.5, 1, 2, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000}
18 receivedBytes = metric.HistogramInt64{
19 Name: "received_bytes",
20 Description: "Distribution of received bytes, by method.",
21 Keys: []label.Key{tag.RPCDirection, tag.Method},
22 Buckets: bytesDistribution,
25 sentBytes = metric.HistogramInt64{
27 Description: "Distribution of sent bytes, by method.",
28 Keys: []label.Key{tag.RPCDirection, tag.Method},
29 Buckets: bytesDistribution,
32 latency = metric.HistogramFloat64{
34 Description: "Distribution of latency in milliseconds, by method.",
35 Keys: []label.Key{tag.RPCDirection, tag.Method},
36 Buckets: millisecondsDistribution,
39 started = metric.Scalar{
41 Description: "Count of RPCs started by method.",
42 Keys: []label.Key{tag.RPCDirection, tag.Method},
45 completed = metric.Scalar{
47 Description: "Count of RPCs completed by method and status.",
48 Keys: []label.Key{tag.RPCDirection, tag.Method, tag.StatusCode},
52 func registerMetrics(m *metric.Config) {
53 receivedBytes.Record(m, tag.ReceivedBytes)
54 sentBytes.Record(m, tag.SentBytes)
55 latency.Record(m, tag.Latency)
56 started.Count(m, tag.Started)
57 completed.Count(m, tag.Latency)