Skip to content

Commit

Permalink
[chore]: enable gofumpt linter for connector (open-telemetry#36372)
Browse files Browse the repository at this point in the history
#### Description

[gofumpt](https://golangci-lint.run/usage/linters/#gofumpt) enforces a
stricter format than gofmt

Part of
open-telemetry#36363

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Nov 14, 2024
1 parent 8ea5956 commit ff9c635
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 18 deletions.
3 changes: 2 additions & 1 deletion connector/countconnector/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ func TestLoadConfig(t *testing.T) {
},
Metrics: map[string]MetricInfo{
"my.metric.count": {
Description: "My metric count."},
Description: "My metric count.",
},
"limited.metric.count": {
Description: "Limited metric count.",
Conditions: []string{`IsMatch(resource.attributes["host.name"], "pod-m")`},
Expand Down
8 changes: 5 additions & 3 deletions connector/otlpjsonconnector/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/otlpjsonconnector/internal/metadata"
)

var logRegex = regexp.MustCompile(`^\{\s*"resourceLogs"\s*:\s*\[`)
var metricRegex = regexp.MustCompile(`^\{\s*"resourceMetrics"\s*:\s*\[`)
var traceRegex = regexp.MustCompile(`^\{\s*"resourceSpans"\s*:\s*\[`)
var (
logRegex = regexp.MustCompile(`^\{\s*"resourceLogs"\s*:\s*\[`)
metricRegex = regexp.MustCompile(`^\{\s*"resourceMetrics"\s*:\s*\[`)
traceRegex = regexp.MustCompile(`^\{\s*"resourceSpans"\s*:\s*\[`)
)

// NewFactory returns a ConnectorFactory.
func NewFactory() connector.Factory {
Expand Down
1 change: 0 additions & 1 deletion connector/routingconnector/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func newLogsConnector(
cfg.DefaultPipelines,
lr.Consumer,
set.TelemetrySettings)

if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion connector/routingconnector/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func newMetricsConnector(
cfg.DefaultPipelines,
mr.Consumer,
set.TelemetrySettings)

if err != nil {
return nil, err
}
Expand Down
8 changes: 5 additions & 3 deletions connector/routingconnector/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import (
// future if needed. For now, it expects the condition to be in exactly the format:
// 'request["<name>"] <comparator> <value>' where <comparator> is either '==' or '!='.

var requestFieldRegex = regexp.MustCompile(`request\[".*"\]`)
var valueFieldRegex = regexp.MustCompile(`".*"`)
var comparatorRegex = regexp.MustCompile(`==|!=`)
var (
requestFieldRegex = regexp.MustCompile(`request\[".*"\]`)
valueFieldRegex = regexp.MustCompile(`".*"`)
comparatorRegex = regexp.MustCompile(`==|!=`)
)

type requestCondition struct {
attributeName string
Expand Down
1 change: 0 additions & 1 deletion connector/routingconnector/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func newTracesConnector(
cfg.DefaultPipelines,
tr.Consumer,
set.TelemetrySettings)

if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion connector/servicegraphconnector/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

// Config defines the configuration options for servicegraphprocessor.
type Config struct {

// MetricsExporter is the name of the metrics exporter to use to ship metrics.
//
// Deprecated: The exporter is defined as part of the pipeline and this option is currently noop.
Expand Down
1 change: 0 additions & 1 deletion connector/servicegraphconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ func TestUpdateDurationMetrics(t *testing.T) {
caseStr string
duration float64
}{

{
caseStr: "index 0 latency",
duration: 0,
Expand Down
4 changes: 1 addition & 3 deletions connector/servicegraphconnector/internal/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
"go.opentelemetry.io/collector/pdata/pcommon"
)

var (
ErrTooManyItems = errors.New("too many items")
)
var ErrTooManyItems = errors.New("too many items")

type Callback func(e *Edge)

Expand Down
3 changes: 2 additions & 1 deletion connector/spanmetricsconnector/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func TestLoadConfig(t *testing.T) {
},
},
},
}},
},
},
{
id: component.NewIDWithName(metadata.Type, "exponential_histogram"),
expected: &Config{
Expand Down
1 change: 1 addition & 0 deletions connector/spanmetricsconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,7 @@ func TestSpanMetrics_Events(t *testing.T) {
})
}
}

func TestExemplarsAreDiscardedAfterFlushing(t *testing.T) {
tests := []struct {
name string
Expand Down
6 changes: 4 additions & 2 deletions connector/spanmetricsconnector/internal/metrics/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ const (

type Unit int8

var _ encoding.TextMarshaler = (*Unit)(nil)
var _ encoding.TextUnmarshaler = (*Unit)(nil)
var (
_ encoding.TextMarshaler = (*Unit)(nil)
_ encoding.TextUnmarshaler = (*Unit)(nil)
)

func (u Unit) String() string {
switch u {
Expand Down

0 comments on commit ff9c635

Please sign in to comment.