2023-01-06 19:20:49 +02:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2024-02-29 08:05:28 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2023-01-06 19:20:49 +02:00
|
|
|
|
2023-04-27 20:25:48 +02:00
|
|
|
package metric // import "go.opentelemetry.io/otel/metric"
|
2023-01-06 19:20:49 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2023-03-21 15:16:57 +02:00
|
|
|
func TestFloat64Configuration(t *testing.T) {
|
2023-01-06 19:20:49 +02:00
|
|
|
const (
|
|
|
|
token float64 = 43
|
|
|
|
desc = "Instrument description."
|
2023-02-27 18:10:56 +02:00
|
|
|
uBytes = "By"
|
2023-01-06 19:20:49 +02:00
|
|
|
)
|
|
|
|
|
2023-03-21 15:16:57 +02:00
|
|
|
run := func(got float64Config) func(*testing.T) {
|
|
|
|
return func(t *testing.T) {
|
|
|
|
assert.Equal(t, desc, got.Description(), "description")
|
|
|
|
assert.Equal(t, uBytes, got.Unit(), "unit")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t.Run("Float64Counter", run(
|
|
|
|
NewFloat64CounterConfig(WithDescription(desc), WithUnit(uBytes)),
|
|
|
|
))
|
|
|
|
|
|
|
|
t.Run("Float64UpDownCounter", run(
|
|
|
|
NewFloat64UpDownCounterConfig(WithDescription(desc), WithUnit(uBytes)),
|
|
|
|
))
|
|
|
|
|
|
|
|
t.Run("Float64Histogram", run(
|
|
|
|
NewFloat64HistogramConfig(WithDescription(desc), WithUnit(uBytes)),
|
|
|
|
))
|
2024-05-16 18:56:40 +02:00
|
|
|
|
|
|
|
t.Run("Float64Gauge", run(
|
|
|
|
NewFloat64GaugeConfig(WithDescription(desc), WithUnit(uBytes)),
|
|
|
|
))
|
2023-03-21 15:16:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type float64Config interface {
|
|
|
|
Description() string
|
|
|
|
Unit() string
|
2023-01-06 19:20:49 +02:00
|
|
|
}
|
2023-10-26 19:18:37 +02:00
|
|
|
|
|
|
|
func TestFloat64ExplicitBucketHistogramConfiguration(t *testing.T) {
|
|
|
|
bounds := []float64{0.1, 0.5, 1.0}
|
|
|
|
got := NewFloat64HistogramConfig(WithExplicitBucketBoundaries(bounds...))
|
|
|
|
assert.Equal(t, bounds, got.ExplicitBucketBoundaries(), "boundaries")
|
|
|
|
}
|