Skip to content

Commit 6db5d1a

Browse files
authored
[chore]: enable gofumpt linter for processor (#36347)
#### Description [gofumpt](https://golangci-lint.run/usage/linters/#gofumpt) enforces a stricter format than gofmt Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 7c914b9 commit 6db5d1a

File tree

64 files changed

+2842
-2733
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2842
-2733
lines changed

processor/attributesprocessor/attributes_log_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func TestAttributes_FilterLogs(t *testing.T) {
136136
}
137137
oCfg.Include = &filterconfig.MatchProperties{
138138
Resources: []filterconfig.Attribute{{Key: "name", Value: "^[^i].*"}},
139-
//Libraries: []filterconfig.InstrumentationLibrary{{Name: "^[^i].*"}},
139+
// Libraries: []filterconfig.InstrumentationLibrary{{Name: "^[^i].*"}},
140140
Config: *createConfig(filterset.Regexp),
141141
}
142142
oCfg.Exclude = &filterconfig.MatchProperties{

processor/attributesprocessor/attributes_metric_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ func TestMetricAttributes_Hash(t *testing.T) {
347347
runIndividualMetricTestCase(t, tc, mp)
348348
}
349349
}
350+
350351
func TestMetricAttributes_Convert(t *testing.T) {
351352
testCases := []metricTestCase{
352353
{

processor/cumulativetodeltaprocessor/internal/tracking/identity.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ type MetricIdentity struct {
2525
MetricValueType pmetric.NumberDataPointValueType
2626
}
2727

28-
const A = int32('A')
29-
const SEP = byte(0x1E)
30-
const SEPSTR = string(SEP)
28+
const (
29+
A = int32('A')
30+
SEP = byte(0x1E)
31+
SEPSTR = string(SEP)
32+
)
3133

3234
func (mi *MetricIdentity) Write(b *bytes.Buffer) {
3335
b.WriteRune(A + int32(mi.MetricType))

processor/deltatocumulativeprocessor/internal/data/expo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ø = math.MaxUint64
2020
func TestExpoAdd(t *testing.T) {
2121
type expdp = expotest.Histogram
2222
type bins = expotest.Bins
23-
var obs0 = expotest.Observe0
23+
obs0 := expotest.Observe0
2424

2525
cases := []struct {
2626
name string

processor/deltatocumulativeprocessor/internal/data/histo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
func TestHistoAdd(t *testing.T) {
1515
type histdp = histotest.Histogram
16-
var obs = histotest.Bounds(histo.DefaultBounds).Observe
16+
obs := histotest.Bounds(histo.DefaultBounds).Observe
1717

1818
cases := []struct {
1919
name string

processor/deltatocumulativeprocessor/internal/streams/data_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ import (
1616
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor/internal/testdata/random"
1717
)
1818

19-
var rdp data.Number
20-
var rid streams.Ident
19+
var (
20+
rdp data.Number
21+
rid streams.Ident
22+
)
2123

2224
func BenchmarkSamples(b *testing.B) {
2325
b.Run("iterfn", func(b *testing.B) {

processor/deltatocumulativeprocessor/linear.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func (p *Linear) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) error {
115115
// tracked stream: add incoming delta dp to existing cumulative aggregation
116116
return acc, delta.AccumulateInto(acc, dp)
117117
}()
118-
119118
// aggregation failed, record as metric and drop datapoint
120119
if err != nil {
121120
p.tel.Datapoints().Inc(ctx, telemetry.Cause(err))

processor/deltatorateprocessor/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
// Config defines the configuration for the processor.
1111
type Config struct {
12-
1312
// List of delta sum metrics to convert to rates
1413
Metrics []string `mapstructure:"metrics"`
1514
}

processor/deltatorateprocessor/processor_test.go

Lines changed: 76 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -31,84 +31,82 @@ type deltaToRateTest struct {
3131
outMetrics pmetric.Metrics
3232
}
3333

34-
var (
35-
testCases = []deltaToRateTest{
36-
{
37-
name: "delta_to_rate_expect_same",
38-
metrics: nil,
39-
inMetrics: generateSumMetrics(testMetric{
40-
metricNames: []string{"metric_1", "metric_2"},
41-
metricValues: [][]float64{{100}, {4}},
42-
isDelta: []bool{true, true},
43-
deltaSecond: 120,
44-
}),
45-
outMetrics: generateSumMetrics(testMetric{
46-
metricNames: []string{"metric_1", "metric_2"},
47-
metricValues: [][]float64{{100}, {4}},
48-
isDelta: []bool{true, true},
49-
deltaSecond: 120,
50-
}),
51-
},
52-
{
53-
name: "delta_to_rate_one_positive",
54-
metrics: []string{"metric_1", "metric_2"},
55-
inMetrics: generateSumMetrics(testMetric{
56-
metricNames: []string{"metric_1", "metric_2"},
57-
metricValues: [][]float64{{120, 240, 360}, {360}},
58-
isDelta: []bool{true, true},
59-
deltaSecond: 120,
60-
}),
61-
outMetrics: generateGaugeMetrics(testMetric{
62-
metricNames: []string{"metric_1", "metric_2"},
63-
metricValues: [][]float64{{1, 2, 3}, {3}},
64-
}),
65-
},
66-
{
67-
name: "delta_to_rate_with_cumulative",
68-
metrics: []string{"metric_1", "metric_2"},
69-
inMetrics: generateSumMetrics(testMetric{
70-
metricNames: []string{"metric_1", "metric_2"},
71-
metricValues: [][]float64{{100}, {4}},
72-
isDelta: []bool{false, false},
73-
deltaSecond: 120,
74-
}),
75-
outMetrics: generateSumMetrics(testMetric{
76-
metricNames: []string{"metric_1", "metric_2"},
77-
metricValues: [][]float64{{100}, {4}},
78-
isDelta: []bool{false, false},
79-
deltaSecond: 120,
80-
}),
81-
},
82-
{
83-
name: "delta_to_rate_expect_zero",
84-
metrics: []string{"metric_1", "metric_2"},
85-
inMetrics: generateSumMetrics(testMetric{
86-
metricNames: []string{"metric_1", "metric_2"},
87-
metricValues: [][]float64{{120, 240, 360}, {360}},
88-
isDelta: []bool{true, true},
89-
deltaSecond: 0,
90-
}),
91-
outMetrics: generateGaugeMetrics(testMetric{
92-
metricNames: []string{"metric_1", "metric_2"},
93-
metricValues: [][]float64{{0, 0, 0}, {0}},
94-
}),
95-
},
96-
{
97-
name: "int64-delta_to_rate_one_positive",
98-
metrics: []string{"metric_1", "metric_2"},
99-
inMetrics: generateSumMetrics(testMetric{
100-
metricNames: []string{"metric_1", "metric_2"},
101-
metricIntValues: [][]int64{{120, 240, 360}, {360}},
102-
isDelta: []bool{true, true},
103-
deltaSecond: 120,
104-
}),
105-
outMetrics: generateGaugeMetrics(testMetric{
106-
metricNames: []string{"metric_1", "metric_2"},
107-
metricValues: [][]float64{{1, 2, 3}, {3}},
108-
}),
109-
},
110-
}
111-
)
34+
var testCases = []deltaToRateTest{
35+
{
36+
name: "delta_to_rate_expect_same",
37+
metrics: nil,
38+
inMetrics: generateSumMetrics(testMetric{
39+
metricNames: []string{"metric_1", "metric_2"},
40+
metricValues: [][]float64{{100}, {4}},
41+
isDelta: []bool{true, true},
42+
deltaSecond: 120,
43+
}),
44+
outMetrics: generateSumMetrics(testMetric{
45+
metricNames: []string{"metric_1", "metric_2"},
46+
metricValues: [][]float64{{100}, {4}},
47+
isDelta: []bool{true, true},
48+
deltaSecond: 120,
49+
}),
50+
},
51+
{
52+
name: "delta_to_rate_one_positive",
53+
metrics: []string{"metric_1", "metric_2"},
54+
inMetrics: generateSumMetrics(testMetric{
55+
metricNames: []string{"metric_1", "metric_2"},
56+
metricValues: [][]float64{{120, 240, 360}, {360}},
57+
isDelta: []bool{true, true},
58+
deltaSecond: 120,
59+
}),
60+
outMetrics: generateGaugeMetrics(testMetric{
61+
metricNames: []string{"metric_1", "metric_2"},
62+
metricValues: [][]float64{{1, 2, 3}, {3}},
63+
}),
64+
},
65+
{
66+
name: "delta_to_rate_with_cumulative",
67+
metrics: []string{"metric_1", "metric_2"},
68+
inMetrics: generateSumMetrics(testMetric{
69+
metricNames: []string{"metric_1", "metric_2"},
70+
metricValues: [][]float64{{100}, {4}},
71+
isDelta: []bool{false, false},
72+
deltaSecond: 120,
73+
}),
74+
outMetrics: generateSumMetrics(testMetric{
75+
metricNames: []string{"metric_1", "metric_2"},
76+
metricValues: [][]float64{{100}, {4}},
77+
isDelta: []bool{false, false},
78+
deltaSecond: 120,
79+
}),
80+
},
81+
{
82+
name: "delta_to_rate_expect_zero",
83+
metrics: []string{"metric_1", "metric_2"},
84+
inMetrics: generateSumMetrics(testMetric{
85+
metricNames: []string{"metric_1", "metric_2"},
86+
metricValues: [][]float64{{120, 240, 360}, {360}},
87+
isDelta: []bool{true, true},
88+
deltaSecond: 0,
89+
}),
90+
outMetrics: generateGaugeMetrics(testMetric{
91+
metricNames: []string{"metric_1", "metric_2"},
92+
metricValues: [][]float64{{0, 0, 0}, {0}},
93+
}),
94+
},
95+
{
96+
name: "int64-delta_to_rate_one_positive",
97+
metrics: []string{"metric_1", "metric_2"},
98+
inMetrics: generateSumMetrics(testMetric{
99+
metricNames: []string{"metric_1", "metric_2"},
100+
metricIntValues: [][]int64{{120, 240, 360}, {360}},
101+
isDelta: []bool{true, true},
102+
deltaSecond: 120,
103+
}),
104+
outMetrics: generateGaugeMetrics(testMetric{
105+
metricNames: []string{"metric_1", "metric_2"},
106+
metricValues: [][]float64{{1, 2, 3}, {3}},
107+
}),
108+
},
109+
}
112110

113111
func TestCumulativeToDeltaProcessor(t *testing.T) {
114112
for _, test := range testCases {

processor/filterprocessor/expr_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/filter/filterconfig"
2222
)
2323

24-
const filteredMetric = "p0_metric_1"
25-
const filteredAttrKey = "pt-label-key-1"
24+
const (
25+
filteredMetric = "p0_metric_1"
26+
filteredAttrKey = "pt-label-key-1"
27+
)
2628

2729
var filteredAttrVal = pcommon.NewValueStr("pt-label-val-1")
2830

processor/groupbyattrsprocessor/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package groupbyattrsprocessor // import "github.com/open-telemetry/opentelemetry
55

66
// Config is the configuration for the processor.
77
type Config struct {
8-
98
// GroupByKeys describes the attribute names that are going to be used for grouping.
109
// Empty value is allowed, since processor in such case can compact data
1110
GroupByKeys []string `mapstructure:"keys"`

processor/groupbyattrsprocessor/factory.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import (
1515
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor/internal/metadata"
1616
)
1717

18-
var (
19-
consumerCapabilities = consumer.Capabilities{MutatesData: true}
20-
)
18+
var consumerCapabilities = consumer.Capabilities{MutatesData: true}
2119

2220
// NewFactory returns a new factory for the Filter processor.
2321
func NewFactory() processor.Factory {
@@ -64,7 +62,8 @@ func createTracesProcessor(
6462
ctx context.Context,
6563
set processor.Settings,
6664
cfg component.Config,
67-
nextConsumer consumer.Traces) (processor.Traces, error) {
65+
nextConsumer consumer.Traces,
66+
) (processor.Traces, error) {
6867
oCfg := cfg.(*Config)
6968
gap, err := createGroupByAttrsProcessor(set, oCfg.GroupByKeys)
7069
if err != nil {
@@ -85,7 +84,8 @@ func createLogsProcessor(
8584
ctx context.Context,
8685
set processor.Settings,
8786
cfg component.Config,
88-
nextConsumer consumer.Logs) (processor.Logs, error) {
87+
nextConsumer consumer.Logs,
88+
) (processor.Logs, error) {
8989
oCfg := cfg.(*Config)
9090
gap, err := createGroupByAttrsProcessor(set, oCfg.GroupByKeys)
9191
if err != nil {
@@ -106,7 +106,8 @@ func createMetricsProcessor(
106106
ctx context.Context,
107107
set processor.Settings,
108108
cfg component.Config,
109-
nextConsumer consumer.Metrics) (processor.Metrics, error) {
109+
nextConsumer consumer.Metrics,
110+
) (processor.Metrics, error) {
110111
oCfg := cfg.(*Config)
111112
gap, err := createGroupByAttrsProcessor(set, oCfg.GroupByKeys)
112113
if err != nil {

processor/groupbyattrsprocessor/processor_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ import (
2222
"go.opentelemetry.io/otel/sdk/metric/metricdata"
2323
)
2424

25-
var (
26-
attrMap = prepareAttributeMap()
27-
)
25+
var attrMap = prepareAttributeMap()
2826

2927
func prepareAttributeMap() pcommon.Map {
3028
am := pcommon.NewMap()

processor/groupbytraceprocessor/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
// Config is the configuration for the processor.
1111
type Config struct {
12-
1312
// NumTraces is the max number of traces to keep in memory waiting for the duration.
1413
// Default: 1_000_000.
1514
NumTraces int `mapstructure:"num_traces"`

processor/groupbytraceprocessor/event.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ var (
4848
}
4949
)
5050

51-
type eventType int
52-
type event struct {
53-
typ eventType
54-
payload any
55-
}
51+
type (
52+
eventType int
53+
event struct {
54+
typ eventType
55+
payload any
56+
}
57+
)
5658

5759
type tracesWithID struct {
5860
id pcommon.TraceID

processor/groupbytraceprocessor/factory.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ func createTracesProcessor(
5454
_ context.Context,
5555
params processor.Settings,
5656
cfg component.Config,
57-
nextConsumer consumer.Traces) (processor.Traces, error) {
57+
nextConsumer consumer.Traces,
58+
) (processor.Traces, error) {
5859
oCfg := cfg.(*Config)
5960

6061
var st storage

0 commit comments

Comments
 (0)