Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed Feb 4, 2025
1 parent 60d30e3 commit cf81cc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion otlptranslator/prometheusremotewrite/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import (
"strconv"
"unicode/utf8"

"github.com/cespare/xxhash/v2"
"github.com/prometheus/common/model"

"github.com/cespare/xxhash/v2"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
conventions "go.opentelemetry.io/collector/semconv/v1.6.1"
Expand Down
17 changes: 9 additions & 8 deletions otlptranslator/prometheusremotewrite/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"

Expand Down Expand Up @@ -320,15 +321,15 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
metric := tt.metric()
converter := NewPrometheusConverter()

converter.addSummaryDataPoints(
require.NoError(t, converter.addSummaryDataPoints(
context.Background(),
metric.Summary().DataPoints(),
pcommon.NewResource(),
Settings{
ExportCreatedMetric: true,
},
metric.Name(),
)
))

assert.Equal(t, tt.want(), converter.unique)
assert.Empty(t, converter.conflicts)
Expand Down Expand Up @@ -431,15 +432,15 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
metric := tt.metric()
converter := NewPrometheusConverter()

converter.addHistogramDataPoints(
require.NoError(t, converter.addHistogramDataPoints(
context.Background(),
metric.Histogram().DataPoints(),
pcommon.NewResource(),
Settings{
ExportCreatedMetric: true,
},
metric.Name(),
)
))

assert.Equal(t, tt.want(), converter.unique)
assert.Empty(t, converter.conflicts)
Expand All @@ -457,9 +458,9 @@ func TestGetPromExemplars(t *testing.T) {
exemplar.SetTimestamp(pcommon.Timestamp(time.Now().UnixNano()))
exemplar.SetIntValue(42)
exemplars, err := getPromExemplars(ctx, everyN, pt)
assert.NoError(t, err)
require.NoError(t, err)
assert.Len(t, exemplars, 1)
assert.Equal(t, float64(42), exemplars[0].Value)
require.InEpsilon(t, float64(42), exemplars[0].Value, 0.000001)
})

t.Run("Exemplars with double value", func(t *testing.T) {
Expand All @@ -468,9 +469,9 @@ func TestGetPromExemplars(t *testing.T) {
exemplar.SetTimestamp(pcommon.Timestamp(time.Now().UnixNano()))
exemplar.SetDoubleValue(69.420)
exemplars, err := getPromExemplars(ctx, everyN, pt)
assert.NoError(t, err)
require.NoError(t, err)
assert.Len(t, exemplars, 1)
assert.Equal(t, 69.420, exemplars[0].Value)
require.InEpsilon(t, 69.420, exemplars[0].Value, 0.000001)
})

t.Run("Exemplars with unsupported value type", func(t *testing.T) {
Expand Down

0 comments on commit cf81cc3

Please sign in to comment.