gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

syncfloat64.go (6222B)


      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 
     15 package metric // import "go.opentelemetry.io/otel/metric"
     16 
     17 import (
     18 	"context"
     19 
     20 	"go.opentelemetry.io/otel/metric/embedded"
     21 )
     22 
     23 // Float64Counter is an instrument that records increasing float64 values.
     24 //
     25 // Warning: Methods may be added to this interface in minor releases. See
     26 // package documentation on API implementation for information on how to set
     27 // default behavior for unimplemented methods.
     28 type Float64Counter interface {
     29 	// Users of the interface can ignore this. This embedded type is only used
     30 	// by implementations of this interface. See the "API Implementations"
     31 	// section of the package documentation for more information.
     32 	embedded.Float64Counter
     33 
     34 	// Add records a change to the counter.
     35 	//
     36 	// Use the WithAttributeSet (or, if performance is not a concern,
     37 	// the WithAttributes) option to include measurement attributes.
     38 	Add(ctx context.Context, incr float64, options ...AddOption)
     39 }
     40 
     41 // Float64CounterConfig contains options for synchronous counter instruments that
     42 // record int64 values.
     43 type Float64CounterConfig struct {
     44 	description string
     45 	unit        string
     46 }
     47 
     48 // NewFloat64CounterConfig returns a new [Float64CounterConfig] with all opts
     49 // applied.
     50 func NewFloat64CounterConfig(opts ...Float64CounterOption) Float64CounterConfig {
     51 	var config Float64CounterConfig
     52 	for _, o := range opts {
     53 		config = o.applyFloat64Counter(config)
     54 	}
     55 	return config
     56 }
     57 
     58 // Description returns the configured description.
     59 func (c Float64CounterConfig) Description() string {
     60 	return c.description
     61 }
     62 
     63 // Unit returns the configured unit.
     64 func (c Float64CounterConfig) Unit() string {
     65 	return c.unit
     66 }
     67 
     68 // Float64CounterOption applies options to a [Float64CounterConfig]. See
     69 // [InstrumentOption] for other options that can be used as a
     70 // Float64CounterOption.
     71 type Float64CounterOption interface {
     72 	applyFloat64Counter(Float64CounterConfig) Float64CounterConfig
     73 }
     74 
     75 // Float64UpDownCounter is an instrument that records increasing or decreasing
     76 // float64 values.
     77 //
     78 // Warning: Methods may be added to this interface in minor releases. See
     79 // package documentation on API implementation for information on how to set
     80 // default behavior for unimplemented methods.
     81 type Float64UpDownCounter interface {
     82 	// Users of the interface can ignore this. This embedded type is only used
     83 	// by implementations of this interface. See the "API Implementations"
     84 	// section of the package documentation for more information.
     85 	embedded.Float64UpDownCounter
     86 
     87 	// Add records a change to the counter.
     88 	//
     89 	// Use the WithAttributeSet (or, if performance is not a concern,
     90 	// the WithAttributes) option to include measurement attributes.
     91 	Add(ctx context.Context, incr float64, options ...AddOption)
     92 }
     93 
     94 // Float64UpDownCounterConfig contains options for synchronous counter
     95 // instruments that record int64 values.
     96 type Float64UpDownCounterConfig struct {
     97 	description string
     98 	unit        string
     99 }
    100 
    101 // NewFloat64UpDownCounterConfig returns a new [Float64UpDownCounterConfig]
    102 // with all opts applied.
    103 func NewFloat64UpDownCounterConfig(opts ...Float64UpDownCounterOption) Float64UpDownCounterConfig {
    104 	var config Float64UpDownCounterConfig
    105 	for _, o := range opts {
    106 		config = o.applyFloat64UpDownCounter(config)
    107 	}
    108 	return config
    109 }
    110 
    111 // Description returns the configured description.
    112 func (c Float64UpDownCounterConfig) Description() string {
    113 	return c.description
    114 }
    115 
    116 // Unit returns the configured unit.
    117 func (c Float64UpDownCounterConfig) Unit() string {
    118 	return c.unit
    119 }
    120 
    121 // Float64UpDownCounterOption applies options to a
    122 // [Float64UpDownCounterConfig]. See [InstrumentOption] for other options that
    123 // can be used as a Float64UpDownCounterOption.
    124 type Float64UpDownCounterOption interface {
    125 	applyFloat64UpDownCounter(Float64UpDownCounterConfig) Float64UpDownCounterConfig
    126 }
    127 
    128 // Float64Histogram is an instrument that records a distribution of float64
    129 // values.
    130 //
    131 // Warning: Methods may be added to this interface in minor releases. See
    132 // package documentation on API implementation for information on how to set
    133 // default behavior for unimplemented methods.
    134 type Float64Histogram interface {
    135 	// Users of the interface can ignore this. This embedded type is only used
    136 	// by implementations of this interface. See the "API Implementations"
    137 	// section of the package documentation for more information.
    138 	embedded.Float64Histogram
    139 
    140 	// Record adds an additional value to the distribution.
    141 	//
    142 	// Use the WithAttributeSet (or, if performance is not a concern,
    143 	// the WithAttributes) option to include measurement attributes.
    144 	Record(ctx context.Context, incr float64, options ...RecordOption)
    145 }
    146 
    147 // Float64HistogramConfig contains options for synchronous counter instruments
    148 // that record int64 values.
    149 type Float64HistogramConfig struct {
    150 	description string
    151 	unit        string
    152 }
    153 
    154 // NewFloat64HistogramConfig returns a new [Float64HistogramConfig] with all
    155 // opts applied.
    156 func NewFloat64HistogramConfig(opts ...Float64HistogramOption) Float64HistogramConfig {
    157 	var config Float64HistogramConfig
    158 	for _, o := range opts {
    159 		config = o.applyFloat64Histogram(config)
    160 	}
    161 	return config
    162 }
    163 
    164 // Description returns the configured description.
    165 func (c Float64HistogramConfig) Description() string {
    166 	return c.description
    167 }
    168 
    169 // Unit returns the configured unit.
    170 func (c Float64HistogramConfig) Unit() string {
    171 	return c.unit
    172 }
    173 
    174 // Float64HistogramOption applies options to a [Float64HistogramConfig]. See
    175 // [InstrumentOption] for other options that can be used as a
    176 // Float64HistogramOption.
    177 type Float64HistogramOption interface {
    178 	applyFloat64Histogram(Float64HistogramConfig) Float64HistogramConfig
    179 }