Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / internal / event / export / metric / info.go
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.
4
5 package metric
6
7 import (
8         "golang.org/x/tools/internal/event/keys"
9         "golang.org/x/tools/internal/event/label"
10 )
11
12 // Scalar represents the construction information for a scalar metric.
13 type Scalar struct {
14         // Name is the unique name of this metric.
15         Name string
16         // Description can be used by observers to describe the metric to users.
17         Description string
18         // Keys is the set of labels that collectively describe rows of the metric.
19         Keys []label.Key
20 }
21
22 // HistogramInt64 represents the construction information for an int64 histogram metric.
23 type HistogramInt64 struct {
24         // Name is the unique name of this metric.
25         Name string
26         // Description can be used by observers to describe the metric to users.
27         Description string
28         // Keys is the set of labels that collectively describe rows of the metric.
29         Keys []label.Key
30         // Buckets holds the inclusive upper bound of each bucket in the histogram.
31         Buckets []int64
32 }
33
34 // HistogramFloat64 represents the construction information for an float64 histogram metric.
35 type HistogramFloat64 struct {
36         // Name is the unique name of this metric.
37         Name string
38         // Description can be used by observers to describe the metric to users.
39         Description string
40         // Keys is the set of labels that collectively describe rows of the metric.
41         Keys []label.Key
42         // Buckets holds the inclusive upper bound of each bucket in the histogram.
43         Buckets []float64
44 }
45
46 // Count creates a new metric based on the Scalar information that counts
47 // the number of times the supplied int64 measure is set.
48 // Metrics of this type will use Int64Data.
49 func (info Scalar) Count(e *Config, key label.Key) {
50         data := &Int64Data{Info: &info, key: nil}
51         e.subscribe(key, data.count)
52 }
53
54 // SumInt64 creates a new metric based on the Scalar information that sums all
55 // the values recorded on the int64 measure.
56 // Metrics of this type will use Int64Data.
57 func (info Scalar) SumInt64(e *Config, key *keys.Int64) {
58         data := &Int64Data{Info: &info, key: key}
59         e.subscribe(key, data.sum)
60 }
61
62 // LatestInt64 creates a new metric based on the Scalar information that tracks
63 // the most recent value recorded on the int64 measure.
64 // Metrics of this type will use Int64Data.
65 func (info Scalar) LatestInt64(e *Config, key *keys.Int64) {
66         data := &Int64Data{Info: &info, IsGauge: true, key: key}
67         e.subscribe(key, data.latest)
68 }
69
70 // SumFloat64 creates a new metric based on the Scalar information that sums all
71 // the values recorded on the float64 measure.
72 // Metrics of this type will use Float64Data.
73 func (info Scalar) SumFloat64(e *Config, key *keys.Float64) {
74         data := &Float64Data{Info: &info, key: key}
75         e.subscribe(key, data.sum)
76 }
77
78 // LatestFloat64 creates a new metric based on the Scalar information that tracks
79 // the most recent value recorded on the float64 measure.
80 // Metrics of this type will use Float64Data.
81 func (info Scalar) LatestFloat64(e *Config, key *keys.Float64) {
82         data := &Float64Data{Info: &info, IsGauge: true, key: key}
83         e.subscribe(key, data.latest)
84 }
85
86 // Record creates a new metric based on the HistogramInt64 information that
87 // tracks the bucketized counts of values recorded on the int64 measure.
88 // Metrics of this type will use HistogramInt64Data.
89 func (info HistogramInt64) Record(e *Config, key *keys.Int64) {
90         data := &HistogramInt64Data{Info: &info, key: key}
91         e.subscribe(key, data.record)
92 }
93
94 // Record creates a new metric based on the HistogramFloat64 information that
95 // tracks the bucketized counts of values recorded on the float64 measure.
96 // Metrics of this type will use HistogramFloat64Data.
97 func (info HistogramFloat64) Record(e *Config, key *keys.Float64) {
98         data := &HistogramFloat64Data{Info: &info, key: key}
99         e.subscribe(key, data.record)
100 }