1// Copyright The OpenTelemetry Authors
2// SPDX-License-Identifier: Apache-2.0
3
4package metric // import "go.opentelemetry.io/otel/metric"
5
6import (
7 "context"
8
9 "go.opentelemetry.io/otel/metric/embedded"
10)
11
12// Float64Counter is an instrument that records increasing float64 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.
17type Float64Counter 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.Float64Counter
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 Add(ctx context.Context, incr float64, options ...AddOption)
28}
29
30// Float64CounterConfig contains options for synchronous counter instruments that
31// record float64 values.
32type Float64CounterConfig struct {
33 description string
34 unit string
35}
36
37// NewFloat64CounterConfig returns a new [Float64CounterConfig] with all opts
38// applied.
39func NewFloat64CounterConfig(opts ...Float64CounterOption) Float64CounterConfig {
40 var config Float64CounterConfig
41 for _, o := range opts {
42 config = o.applyFloat64Counter(config)
43 }
44 return config
45}
46
47// Description returns the configured description.
48func (c Float64CounterConfig) Description() string {
49 return c.description
50}
51
52// Unit returns the configured unit.
53func (c Float64CounterConfig) Unit() string {
54 return c.unit
55}
56
57// Float64CounterOption applies options to a [Float64CounterConfig]. See
58// [InstrumentOption] for other options that can be used as a
59// Float64CounterOption.
60type Float64CounterOption interface {
61 applyFloat64Counter(Float64CounterConfig) Float64CounterConfig
62}
63
64// Float64UpDownCounter is an instrument that records increasing or decreasing
65// float64 values.
66//
67// Warning: Methods may be added to this interface in minor releases. See
68// package documentation on API implementation for information on how to set
69// default behavior for unimplemented methods.
70type Float64UpDownCounter interface {
71 // Users of the interface can ignore this. This embedded type is only used
72 // by implementations of this interface. See the "API Implementations"
73 // section of the package documentation for more information.
74 embedded.Float64UpDownCounter
75
76 // Add records a change to the counter.
77 //
78 // Use the WithAttributeSet (or, if performance is not a concern,
79 // the WithAttributes) option to include measurement attributes.
80 Add(ctx context.Context, incr float64, options ...AddOption)
81}
82
83// Float64UpDownCounterConfig contains options for synchronous counter
84// instruments that record float64 values.
85type Float64UpDownCounterConfig struct {
86 description string
87 unit string
88}
89
90// NewFloat64UpDownCounterConfig returns a new [Float64UpDownCounterConfig]
91// with all opts applied.
92func NewFloat64UpDownCounterConfig(opts ...Float64UpDownCounterOption) Float64UpDownCounterConfig {
93 var config Float64UpDownCounterConfig
94 for _, o := range opts {
95 config = o.applyFloat64UpDownCounter(config)
96 }
97 return config
98}
99
100// Description returns the configured description.
101func (c Float64UpDownCounterConfig) Description() string {
102 return c.description
103}
104
105// Unit returns the configured unit.
106func (c Float64UpDownCounterConfig) Unit() string {
107 return c.unit
108}
109
110// Float64UpDownCounterOption applies options to a
111// [Float64UpDownCounterConfig]. See [InstrumentOption] for other options that
112// can be used as a Float64UpDownCounterOption.
113type Float64UpDownCounterOption interface {
114 applyFloat64UpDownCounter(Float64UpDownCounterConfig) Float64UpDownCounterConfig
115}
116
117// Float64Histogram is an instrument that records a distribution of float64
118// values.
119//
120// Warning: Methods may be added to this interface in minor releases. See
121// package documentation on API implementation for information on how to set
122// default behavior for unimplemented methods.
123type Float64Histogram interface {
124 // Users of the interface can ignore this. This embedded type is only used
125 // by implementations of this interface. See the "API Implementations"
126 // section of the package documentation for more information.
127 embedded.Float64Histogram
128
129 // Record adds an additional value to the distribution.
130 //
131 // Use the WithAttributeSet (or, if performance is not a concern,
132 // the WithAttributes) option to include measurement attributes.
133 Record(ctx context.Context, incr float64, options ...RecordOption)
134}
135
136// Float64HistogramConfig contains options for synchronous histogram
137// instruments that record float64 values.
138type Float64HistogramConfig struct {
139 description string
140 unit string
141 explicitBucketBoundaries []float64
142}
143
144// NewFloat64HistogramConfig returns a new [Float64HistogramConfig] with all
145// opts applied.
146func NewFloat64HistogramConfig(opts ...Float64HistogramOption) Float64HistogramConfig {
147 var config Float64HistogramConfig
148 for _, o := range opts {
149 config = o.applyFloat64Histogram(config)
150 }
151 return config
152}
153
154// Description returns the configured description.
155func (c Float64HistogramConfig) Description() string {
156 return c.description
157}
158
159// Unit returns the configured unit.
160func (c Float64HistogramConfig) Unit() string {
161 return c.unit
162}
163
164// ExplicitBucketBoundaries returns the configured explicit bucket boundaries.
165func (c Float64HistogramConfig) ExplicitBucketBoundaries() []float64 {
166 return c.explicitBucketBoundaries
167}
168
169// Float64HistogramOption applies options to a [Float64HistogramConfig]. See
170// [InstrumentOption] for other options that can be used as a
171// Float64HistogramOption.
172type Float64HistogramOption interface {
173 applyFloat64Histogram(Float64HistogramConfig) Float64HistogramConfig
174}
175
176// Float64Gauge is an instrument that records instantaneous float64 values.
177//
178// Warning: Methods may be added to this interface in minor releases. See
179// package documentation on API implementation for information on how to set
180// default behavior for unimplemented methods.
181type Float64Gauge interface {
182 // Users of the interface can ignore this. This embedded type is only used
183 // by implementations of this interface. See the "API Implementations"
184 // section of the package documentation for more information.
185 embedded.Float64Gauge
186
187 // Record records the instantaneous value.
188 //
189 // Use the WithAttributeSet (or, if performance is not a concern,
190 // the WithAttributes) option to include measurement attributes.
191 Record(ctx context.Context, value float64, options ...RecordOption)
192}
193
194// Float64GaugeConfig contains options for synchronous gauge instruments that
195// record float64 values.
196type Float64GaugeConfig struct {
197 description string
198 unit string
199}
200
201// NewFloat64GaugeConfig returns a new [Float64GaugeConfig] with all opts
202// applied.
203func NewFloat64GaugeConfig(opts ...Float64GaugeOption) Float64GaugeConfig {
204 var config Float64GaugeConfig
205 for _, o := range opts {
206 config = o.applyFloat64Gauge(config)
207 }
208 return config
209}
210
211// Description returns the configured description.
212func (c Float64GaugeConfig) Description() string {
213 return c.description
214}
215
216// Unit returns the configured unit.
217func (c Float64GaugeConfig) Unit() string {
218 return c.unit
219}
220
221// Float64GaugeOption applies options to a [Float64GaugeConfig]. See
222// [InstrumentOption] for other options that can be used as a
223// Float64GaugeOption.
224type Float64GaugeOption interface {
225 applyFloat64Gauge(Float64GaugeConfig) Float64GaugeConfig
226}