...

Source file src/go.opentelemetry.io/otel/metric/syncfloat64_test.go

Documentation: go.opentelemetry.io/otel/metric

     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  	"testing"
    19  
    20  	"github.com/stretchr/testify/assert"
    21  )
    22  
    23  func TestFloat64Configuration(t *testing.T) {
    24  	const (
    25  		token  float64 = 43
    26  		desc           = "Instrument description."
    27  		uBytes         = "By"
    28  	)
    29  
    30  	run := func(got float64Config) func(*testing.T) {
    31  		return func(t *testing.T) {
    32  			assert.Equal(t, desc, got.Description(), "description")
    33  			assert.Equal(t, uBytes, got.Unit(), "unit")
    34  		}
    35  	}
    36  
    37  	t.Run("Float64Counter", run(
    38  		NewFloat64CounterConfig(WithDescription(desc), WithUnit(uBytes)),
    39  	))
    40  
    41  	t.Run("Float64UpDownCounter", run(
    42  		NewFloat64UpDownCounterConfig(WithDescription(desc), WithUnit(uBytes)),
    43  	))
    44  
    45  	t.Run("Float64Histogram", run(
    46  		NewFloat64HistogramConfig(WithDescription(desc), WithUnit(uBytes)),
    47  	))
    48  }
    49  
    50  type float64Config interface {
    51  	Description() string
    52  	Unit() string
    53  }
    54  
    55  func TestFloat64ExplicitBucketHistogramConfiguration(t *testing.T) {
    56  	bounds := []float64{0.1, 0.5, 1.0}
    57  	got := NewFloat64HistogramConfig(WithExplicitBucketBoundaries(bounds...))
    58  	assert.Equal(t, bounds, got.ExplicitBucketBoundaries(), "boundaries")
    59  }
    60  

View as plain text