Debian Codegraph @

metric/syncint64.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package metric // import "go.opentelemetry.io/otel/metric"
5
6 import (
7 "context"
8
9 "go.opentelemetry.io/otel/metric/embedded"
10 )
11
12 // Int64Counter is an instrument that records increasing int64 values.
13 //
14 // Warning: Methods may be added to this interface in minor releases. See
15 // package documentation on API implementation for information on how to set
16 // default behavior for unimplemented methods.
17 type Int64Counter interface {
18 // Users of the interface can ignore this. This embedded type is only used
19 // by implementations of this interface. See the "API Implementations"
20 // section of the package documentation for more information.
21 embedded.Int64Counter
22
23 // Add records a change to the counter.
24 //
25 // Use the WithAttributeSet (or, if performance is not a concern,
26 // the WithAttributes) option to include measurement attributes.
27 //
28 // Implementations of this method need to be safe for a user to call
29 // concurrently.
30 Add(ctx context.Context, incr int64, options ...AddOption)
31
32 // Enabled reports whether the instrument will process measurements for the given context.
33 //
34 // This function can be used in places where measuring an instrument
35 // would result in computationally expensive operations.
36 //
37 // Implementations of this method need to be safe for a user to call
38 // concurrently.
39 Enabled(context.Context) bool
40 }
41
42 // Int64CounterConfig contains options for synchronous counter instruments that
43 // record int64 values.
44 type Int64CounterConfig struct {
45 description string
46 unit string
47 }
48
49 // NewInt64CounterConfig returns a new [Int64CounterConfig] with all opts
50 // applied.
51 func NewInt64CounterConfig(opts ...Int64CounterOption) Int64CounterConfig {
52 var config Int64CounterConfig
53 for _, o := range opts {
54 config = o.applyInt64Counter(config)
55 }
56 return config
57 }
58
59 // Description returns the configured description.
60 func (c Int64CounterConfig) Description() string {
61 return c.description
62 }
63
64 // Unit returns the configured unit.
65 func (c Int64CounterConfig) Unit() string {
66 return c.unit
67 }
68
69 // Int64CounterOption applies options to a [Int64CounterConfig]. See
70 // [InstrumentOption] for other options that can be used as an
71 // Int64CounterOption.
72 type Int64CounterOption interface {
73 applyInt64Counter(Int64CounterConfig) Int64CounterConfig
74 }
75
76 // Int64UpDownCounter is an instrument that records increasing or decreasing
77 // int64 values.
78 //
79 // Warning: Methods may be added to this interface in minor releases. See
80 // package documentation on API implementation for information on how to set
81 // default behavior for unimplemented methods.
82 type Int64UpDownCounter interface {
83 // Users of the interface can ignore this. This embedded type is only used
84 // by implementations of this interface. See the "API Implementations"
85 // section of the package documentation for more information.
86 embedded.Int64UpDownCounter
87
88 // Add records a change to the counter.
89 //
90 // Use the WithAttributeSet (or, if performance is not a concern,
91 // the WithAttributes) option to include measurement attributes.
92 //
93 // Implementations of this method need to be safe for a user to call
94 // concurrently.
95 Add(ctx context.Context, incr int64, options ...AddOption)
96
97 // Enabled reports whether the instrument will process measurements for the given context.
98 //
99 // This function can be used in places where measuring an instrument
100 // would result in computationally expensive operations.
101 //
102 // Implementations of this method need to be safe for a user to call
103 // concurrently.
104 Enabled(context.Context) bool
105 }
106
107 // Int64UpDownCounterConfig contains options for synchronous counter
108 // instruments that record int64 values.
109 type Int64UpDownCounterConfig struct {
110 description string
111 unit string
112 }
113
114 // NewInt64UpDownCounterConfig returns a new [Int64UpDownCounterConfig] with
115 // all opts applied.
116 func NewInt64UpDownCounterConfig(opts ...Int64UpDownCounterOption) Int64UpDownCounterConfig {
117 var config Int64UpDownCounterConfig
118 for _, o := range opts {
119 config = o.applyInt64UpDownCounter(config)
120 }
121 return config
122 }
123
124 // Description returns the configured description.
125 func (c Int64UpDownCounterConfig) Description() string {
126 return c.description
127 }
128
129 // Unit returns the configured unit.
130 func (c Int64UpDownCounterConfig) Unit() string {
131 return c.unit
132 }
133
134 // Int64UpDownCounterOption applies options to a [Int64UpDownCounterConfig].
135 // See [InstrumentOption] for other options that can be used as an
136 // Int64UpDownCounterOption.
137 type Int64UpDownCounterOption interface {
138 applyInt64UpDownCounter(Int64UpDownCounterConfig) Int64UpDownCounterConfig
139 }
140
141 // Int64Histogram is an instrument that records a distribution of int64
142 // values.
143 //
144 // Warning: Methods may be added to this interface in minor releases. See
145 // package documentation on API implementation for information on how to set
146 // default behavior for unimplemented methods.
147 type Int64Histogram interface {
148 // Users of the interface can ignore this. This embedded type is only used
149 // by implementations of this interface. See the "API Implementations"
150 // section of the package documentation for more information.
151 embedded.Int64Histogram
152
153 // Record adds an additional value to the distribution.
154 //
155 // Use the WithAttributeSet (or, if performance is not a concern,
156 // the WithAttributes) option to include measurement attributes.
157 //
158 // Implementations of this method need to be safe for a user to call
159 // concurrently.
160 Record(ctx context.Context, incr int64, options ...RecordOption)
161
162 // Enabled reports whether the instrument will process measurements for the given context.
163 //
164 // This function can be used in places where measuring an instrument
165 // would result in computationally expensive operations.
166 //
167 // Implementations of this method need to be safe for a user to call
168 // concurrently.
169 Enabled(context.Context) bool
170 }
171
172 // Int64HistogramConfig contains options for synchronous histogram instruments
173 // that record int64 values.
174 type Int64HistogramConfig struct {
175 description string
176 unit string
177 explicitBucketBoundaries []float64
178 }
179
180 // NewInt64HistogramConfig returns a new [Int64HistogramConfig] with all opts
181 // applied.
182 func NewInt64HistogramConfig(opts ...Int64HistogramOption) Int64HistogramConfig {
183 var config Int64HistogramConfig
184 for _, o := range opts {
185 config = o.applyInt64Histogram(config)
186 }
187 return config
188 }
189
190 // Description returns the configured description.
191 func (c Int64HistogramConfig) Description() string {
192 return c.description
193 }
194
195 // Unit returns the configured unit.
196 func (c Int64HistogramConfig) Unit() string {
197 return c.unit
198 }
199
200 // ExplicitBucketBoundaries returns the configured explicit bucket boundaries.
201 func (c Int64HistogramConfig) ExplicitBucketBoundaries() []float64 {
202 return c.explicitBucketBoundaries
203 }
204
205 // Int64HistogramOption applies options to a [Int64HistogramConfig]. See
206 // [InstrumentOption] for other options that can be used as an
207 // Int64HistogramOption.
208 type Int64HistogramOption interface {
209 applyInt64Histogram(Int64HistogramConfig) Int64HistogramConfig
210 }
211
212 // Int64Gauge is an instrument that records instantaneous int64 values.
213 //
214 // Warning: Methods may be added to this interface in minor releases. See
215 // package documentation on API implementation for information on how to set
216 // default behavior for unimplemented methods.
217 type Int64Gauge interface {
218 // Users of the interface can ignore this. This embedded type is only used
219 // by implementations of this interface. See the "API Implementations"
220 // section of the package documentation for more information.
221 embedded.Int64Gauge
222
223 // Record records the instantaneous value.
224 //
225 // Use the WithAttributeSet (or, if performance is not a concern,
226 // the WithAttributes) option to include measurement attributes.
227 //
228 // Implementations of this method need to be safe for a user to call
229 // concurrently.
230 Record(ctx context.Context, value int64, options ...RecordOption)
231
232 // Enabled reports whether the instrument will process measurements for the given context.
233 //
234 // This function can be used in places where measuring an instrument
235 // would result in computationally expensive operations.
236 //
237 // Implementations of this method need to be safe for a user to call
238 // concurrently.
239 Enabled(context.Context) bool
240 }
241
242 // Int64GaugeConfig contains options for synchronous gauge instruments that
243 // record int64 values.
244 type Int64GaugeConfig struct {
245 description string
246 unit string
247 }
248
249 // NewInt64GaugeConfig returns a new [Int64GaugeConfig] with all opts
250 // applied.
251 func NewInt64GaugeConfig(opts ...Int64GaugeOption) Int64GaugeConfig {
252 var config Int64GaugeConfig
253 for _, o := range opts {
254 config = o.applyInt64Gauge(config)
255 }
256 return config
257 }
258
259 // Description returns the configured description.
260 func (c Int64GaugeConfig) Description() string {
261 return c.description
262 }
263
264 // Unit returns the configured unit.
265 func (c Int64GaugeConfig) Unit() string {
266 return c.unit
267 }
268
269 // Int64GaugeOption applies options to a [Int64GaugeConfig]. See
270 // [InstrumentOption] for other options that can be used as a
271 // Int64GaugeOption.
272 type Int64GaugeOption interface {
273 applyInt64Gauge(Int64GaugeConfig) Int64GaugeConfig
274 }