Skip to content

Commit 965694c

Browse files
committed
lint
1 parent cf81cc3 commit 965694c

File tree

9 files changed

+26
-25
lines changed

9 files changed

+26
-25
lines changed

assets/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/prometheus/common/assets
22

3-
go 1.21
3+
go 1.22.7
44

55
require github.com/stretchr/testify v1.10.0
66

otlptranslator/prometheus/testutils_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ import (
2323
var ilm pmetric.ScopeMetrics
2424

2525
func init() {
26-
2726
metrics := pmetric.NewMetrics()
2827
resourceMetrics := metrics.ResourceMetrics().AppendEmpty()
2928
ilm = resourceMetrics.ScopeMetrics().AppendEmpty()
30-
3129
}
3230

3331
// Returns a new Metric of type "Gauge" with specified name and unit

otlptranslator/prometheusremotewrite/helper.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ var seps = []byte{'\xff'}
117117
// Unpaired string values are ignored. String pairs overwrite OTLP labels if collisions happen and
118118
// if logOnOverwrite is true, the overwrite is logged. Resulting label names are sanitized.
119119
// If settings.PromoteResourceAttributes is not empty, it's a set of resource attributes that should be promoted to labels.
120-
func createAttributes(resource pcommon.Resource, attributes pcommon.Map, settings Settings,
121-
ignoreAttrs []string, logOnOverwrite bool, extras ...string) []prompb.Label {
120+
func createAttributes(resource pcommon.Resource, attributes pcommon.Map, settings Settings, ignoreAttrs []string, logOnOverwrite bool, extras ...string) []prompb.Label {
122121
resourceAttrs := resource.Attributes()
123122
serviceName, haveServiceName := resourceAttrs.Get(conventions.AttributeServiceName)
124123
instance, haveInstanceID := resourceAttrs.Get(conventions.AttributeServiceInstanceID)
@@ -249,8 +248,7 @@ func isValidAggregationTemporality(metric pmetric.Metric) bool {
249248
// with the user defined bucket boundaries of non-exponential OTel histograms.
250249
// However, work is under way to resolve this shortcoming through a feature called native histograms custom buckets:
251250
// https://github.com/prometheus/prometheus/issues/13485.
252-
func (c *PrometheusConverter) addHistogramDataPoints(ctx context.Context, dataPoints pmetric.HistogramDataPointSlice,
253-
resource pcommon.Resource, settings Settings, baseName string) error {
251+
func (c *PrometheusConverter) addHistogramDataPoints(ctx context.Context, dataPoints pmetric.HistogramDataPointSlice, resource pcommon.Resource, settings Settings, baseName string) error {
254252
for x := 0; x < dataPoints.Len(); x++ {
255253
if err := c.everyN.checkContext(ctx); err != nil {
256254
return err
@@ -449,8 +447,7 @@ func mostRecentTimestampInMetric(metric pmetric.Metric) pcommon.Timestamp {
449447
return ts
450448
}
451449

452-
func (c *PrometheusConverter) addSummaryDataPoints(ctx context.Context, dataPoints pmetric.SummaryDataPointSlice, resource pcommon.Resource,
453-
settings Settings, baseName string) error {
450+
func (c *PrometheusConverter) addSummaryDataPoints(ctx context.Context, dataPoints pmetric.SummaryDataPointSlice, resource pcommon.Resource, settings Settings, baseName string) error {
454451
for x := 0; x < dataPoints.Len(); x++ {
455452
if err := c.everyN.checkContext(ctx); err != nil {
456453
return err

otlptranslator/prometheusremotewrite/histograms.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"math"
2323

2424
"github.com/prometheus/common/model"
25+
2526
"go.opentelemetry.io/collector/pdata/pcommon"
2627
"go.opentelemetry.io/collector/pdata/pmetric"
2728

@@ -34,8 +35,7 @@ const defaultZeroThreshold = 1e-128
3435

3536
// addExponentialHistogramDataPoints adds OTel exponential histogram data points to the corresponding time series
3637
// as native histogram samples.
37-
func (c *PrometheusConverter) addExponentialHistogramDataPoints(ctx context.Context, dataPoints pmetric.ExponentialHistogramDataPointSlice,
38-
resource pcommon.Resource, settings Settings, promName string) (annotations.Annotations, error) {
38+
func (c *PrometheusConverter) addExponentialHistogramDataPoints(ctx context.Context, dataPoints pmetric.ExponentialHistogramDataPointSlice, resource pcommon.Resource, settings Settings, promName string) (annotations.Annotations, error) {
3939
var annots annotations.Annotations
4040
for x := 0; x < dataPoints.Len(); x++ {
4141
if err := c.everyN.checkContext(ctx); err != nil {

otlptranslator/prometheusremotewrite/histograms_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"time"
2424

2525
"github.com/prometheus/common/model"
26+
2627
"github.com/stretchr/testify/assert"
2728
"github.com/stretchr/testify/require"
2829
"go.opentelemetry.io/collector/pdata/pcommon"
@@ -590,7 +591,7 @@ func validateExponentialHistogramCount(t *testing.T, h pmetric.ExponentialHistog
590591
for _, bucket := range h.Negative().BucketCounts().AsRaw() {
591592
actualCount += bucket
592593
}
593-
require.Equal(t, h.Count(), actualCount, "exponential histogram count mismatch")
594+
require.Equalf(t, h.Count(), actualCount, "exponential histogram count mismatch")
594595
}
595596

596597
func validateNativeHistogramCount(t *testing.T, h prompb.Histogram) {
@@ -610,7 +611,7 @@ func validateNativeHistogramCount(t *testing.T, h prompb.Histogram) {
610611
prevBucket += delta
611612
actualCount += uint64(prevBucket)
612613
}
613-
assert.Equal(t, want, actualCount, "native histogram count mismatch")
614+
assert.Equalf(t, want, actualCount, "native histogram count mismatch")
614615
}
615616

616617
func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {

otlptranslator/prometheusremotewrite/metrics_to_prw.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import (
2222
"fmt"
2323
"sort"
2424

25+
prometheustranslator "github.com/prometheus/common/otlptranslator/prometheus"
26+
2527
"go.opentelemetry.io/collector/pdata/pcommon"
2628
"go.opentelemetry.io/collector/pdata/pmetric"
2729
"go.uber.org/multierr"
2830

29-
prometheustranslator "github.com/prometheus/common/otlptranslator/prometheus"
3031
"github.com/prometheus/prometheus/prompb"
3132
"github.com/prometheus/prometheus/util/annotations"
3233
)

otlptranslator/prometheusremotewrite/metrics_to_prw_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ import (
2222
"testing"
2323
"time"
2424

25+
prometheustranslator "github.com/prometheus/common/otlptranslator/prometheus"
26+
2527
"github.com/google/go-cmp/cmp"
2628
"github.com/stretchr/testify/require"
2729
"go.opentelemetry.io/collector/pdata/pcommon"
2830
"go.opentelemetry.io/collector/pdata/pmetric"
2931
"go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp"
3032

31-
prometheustranslator "github.com/prometheus/common/otlptranslator/prometheus"
3233
"github.com/prometheus/prometheus/model/labels"
3334
"github.com/prometheus/prometheus/prompb"
3435
)

otlptranslator/prometheusremotewrite/number_data_points.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import (
2121
"math"
2222

2323
"github.com/prometheus/common/model"
24+
2425
"go.opentelemetry.io/collector/pdata/pcommon"
2526
"go.opentelemetry.io/collector/pdata/pmetric"
2627

2728
"github.com/prometheus/prometheus/model/value"
2829
"github.com/prometheus/prometheus/prompb"
2930
)
3031

31-
func (c *PrometheusConverter) addGaugeNumberDataPoints(ctx context.Context, dataPoints pmetric.NumberDataPointSlice,
32-
resource pcommon.Resource, settings Settings, name string) error {
32+
func (c *PrometheusConverter) addGaugeNumberDataPoints(ctx context.Context, dataPoints pmetric.NumberDataPointSlice, resource pcommon.Resource, settings Settings, name string) error {
3333
for x := 0; x < dataPoints.Len(); x++ {
3434
if err := c.everyN.checkContext(ctx); err != nil {
3535
return err
@@ -64,8 +64,7 @@ func (c *PrometheusConverter) addGaugeNumberDataPoints(ctx context.Context, data
6464
return nil
6565
}
6666

67-
func (c *PrometheusConverter) addSumNumberDataPoints(ctx context.Context, dataPoints pmetric.NumberDataPointSlice,
68-
resource pcommon.Resource, metric pmetric.Metric, settings Settings, name string) error {
67+
func (c *PrometheusConverter) addSumNumberDataPoints(ctx context.Context, dataPoints pmetric.NumberDataPointSlice, resource pcommon.Resource, metric pmetric.Metric, settings Settings, name string) error {
6968
for x := 0; x < dataPoints.Len(); x++ {
7069
if err := c.everyN.checkContext(ctx); err != nil {
7170
return err

otlptranslator/prometheusremotewrite/number_data_points_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import (
2222
"time"
2323

2424
"github.com/prometheus/common/model"
25+
2526
"github.com/stretchr/testify/assert"
27+
"github.com/stretchr/testify/require"
2628
"go.opentelemetry.io/collector/pdata/pcommon"
2729
"go.opentelemetry.io/collector/pdata/pmetric"
2830

@@ -56,7 +58,8 @@ func TestPrometheusConverter_addGaugeNumberDataPoints(t *testing.T) {
5658
{
5759
Value: 1,
5860
Timestamp: convertTimeStamp(pcommon.Timestamp(ts)),
59-
}},
61+
},
62+
},
6063
},
6164
}
6265
},
@@ -67,15 +70,15 @@ func TestPrometheusConverter_addGaugeNumberDataPoints(t *testing.T) {
6770
metric := tt.metric()
6871
converter := NewPrometheusConverter()
6972

70-
converter.addGaugeNumberDataPoints(
73+
require.NoError(t, converter.addGaugeNumberDataPoints(
7174
context.Background(),
7275
metric.Gauge().DataPoints(),
7376
pcommon.NewResource(),
7477
Settings{
7578
ExportCreatedMetric: true,
7679
},
7780
metric.Name(),
78-
)
81+
))
7982

8083
assert.Equal(t, tt.want(), converter.unique)
8184
assert.Empty(t, converter.conflicts)
@@ -111,7 +114,8 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
111114
{
112115
Value: 1,
113116
Timestamp: convertTimeStamp(ts),
114-
}},
117+
},
118+
},
115119
},
116120
}
117121
},
@@ -244,7 +248,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
244248
metric := tt.metric()
245249
converter := NewPrometheusConverter()
246250

247-
converter.addSumNumberDataPoints(
251+
require.NoError(t, converter.addSumNumberDataPoints(
248252
context.Background(),
249253
metric.Sum().DataPoints(),
250254
pcommon.NewResource(),
@@ -253,7 +257,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
253257
ExportCreatedMetric: true,
254258
},
255259
metric.Name(),
256-
)
260+
))
257261

258262
assert.Equal(t, tt.want(), converter.unique)
259263
assert.Empty(t, converter.conflicts)

0 commit comments

Comments
 (0)