syncfloat64.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // Copyright The OpenTelemetry Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package metric // import "go.opentelemetry.io/otel/metric"
  15. import (
  16. "context"
  17. "go.opentelemetry.io/otel/metric/embedded"
  18. )
  19. // Float64Counter is an instrument that records increasing float64 values.
  20. //
  21. // Warning: Methods may be added to this interface in minor releases. See
  22. // package documentation on API implementation for information on how to set
  23. // default behavior for unimplemented methods.
  24. type Float64Counter interface {
  25. // Users of the interface can ignore this. This embedded type is only used
  26. // by implementations of this interface. See the "API Implementations"
  27. // section of the package documentation for more information.
  28. embedded.Float64Counter
  29. // Add records a change to the counter.
  30. //
  31. // Use the WithAttributeSet (or, if performance is not a concern,
  32. // the WithAttributes) option to include measurement attributes.
  33. Add(ctx context.Context, incr float64, options ...AddOption)
  34. }
  35. // Float64CounterConfig contains options for synchronous counter instruments that
  36. // record int64 values.
  37. type Float64CounterConfig struct {
  38. description string
  39. unit string
  40. }
  41. // NewFloat64CounterConfig returns a new [Float64CounterConfig] with all opts
  42. // applied.
  43. func NewFloat64CounterConfig(opts ...Float64CounterOption) Float64CounterConfig {
  44. var config Float64CounterConfig
  45. for _, o := range opts {
  46. config = o.applyFloat64Counter(config)
  47. }
  48. return config
  49. }
  50. // Description returns the configured description.
  51. func (c Float64CounterConfig) Description() string {
  52. return c.description
  53. }
  54. // Unit returns the configured unit.
  55. func (c Float64CounterConfig) Unit() string {
  56. return c.unit
  57. }
  58. // Float64CounterOption applies options to a [Float64CounterConfig]. See
  59. // [InstrumentOption] for other options that can be used as a
  60. // Float64CounterOption.
  61. type Float64CounterOption interface {
  62. applyFloat64Counter(Float64CounterConfig) Float64CounterConfig
  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.
  70. type 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. // Add records a change to the counter.
  76. //
  77. // Use the WithAttributeSet (or, if performance is not a concern,
  78. // the WithAttributes) option to include measurement attributes.
  79. Add(ctx context.Context, incr float64, options ...AddOption)
  80. }
  81. // Float64UpDownCounterConfig contains options for synchronous counter
  82. // instruments that record int64 values.
  83. type Float64UpDownCounterConfig struct {
  84. description string
  85. unit string
  86. }
  87. // NewFloat64UpDownCounterConfig returns a new [Float64UpDownCounterConfig]
  88. // with all opts applied.
  89. func NewFloat64UpDownCounterConfig(opts ...Float64UpDownCounterOption) Float64UpDownCounterConfig {
  90. var config Float64UpDownCounterConfig
  91. for _, o := range opts {
  92. config = o.applyFloat64UpDownCounter(config)
  93. }
  94. return config
  95. }
  96. // Description returns the configured description.
  97. func (c Float64UpDownCounterConfig) Description() string {
  98. return c.description
  99. }
  100. // Unit returns the configured unit.
  101. func (c Float64UpDownCounterConfig) Unit() string {
  102. return c.unit
  103. }
  104. // Float64UpDownCounterOption applies options to a
  105. // [Float64UpDownCounterConfig]. See [InstrumentOption] for other options that
  106. // can be used as a Float64UpDownCounterOption.
  107. type Float64UpDownCounterOption interface {
  108. applyFloat64UpDownCounter(Float64UpDownCounterConfig) Float64UpDownCounterConfig
  109. }
  110. // Float64Histogram is an instrument that records a distribution of float64
  111. // values.
  112. //
  113. // Warning: Methods may be added to this interface in minor releases. See
  114. // package documentation on API implementation for information on how to set
  115. // default behavior for unimplemented methods.
  116. type Float64Histogram interface {
  117. // Users of the interface can ignore this. This embedded type is only used
  118. // by implementations of this interface. See the "API Implementations"
  119. // section of the package documentation for more information.
  120. embedded.Float64Histogram
  121. // Record adds an additional value to the distribution.
  122. //
  123. // Use the WithAttributeSet (or, if performance is not a concern,
  124. // the WithAttributes) option to include measurement attributes.
  125. Record(ctx context.Context, incr float64, options ...RecordOption)
  126. }
  127. // Float64HistogramConfig contains options for synchronous counter instruments
  128. // that record int64 values.
  129. type Float64HistogramConfig struct {
  130. description string
  131. unit string
  132. }
  133. // NewFloat64HistogramConfig returns a new [Float64HistogramConfig] with all
  134. // opts applied.
  135. func NewFloat64HistogramConfig(opts ...Float64HistogramOption) Float64HistogramConfig {
  136. var config Float64HistogramConfig
  137. for _, o := range opts {
  138. config = o.applyFloat64Histogram(config)
  139. }
  140. return config
  141. }
  142. // Description returns the configured description.
  143. func (c Float64HistogramConfig) Description() string {
  144. return c.description
  145. }
  146. // Unit returns the configured unit.
  147. func (c Float64HistogramConfig) Unit() string {
  148. return c.unit
  149. }
  150. // Float64HistogramOption applies options to a [Float64HistogramConfig]. See
  151. // [InstrumentOption] for other options that can be used as a
  152. // Float64HistogramOption.
  153. type Float64HistogramOption interface {
  154. applyFloat64Histogram(Float64HistogramConfig) Float64HistogramConfig
  155. }