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