From b8437a0f5cc76eba1dd6f12ba9a02e7787663b05 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Wed, 13 Nov 2024 15:25:20 +0100 Subject: [PATCH] [chore]: enable whitespace linter for connector (#36341) #### Description [whitespace](https://golangci-lint.run/usage/linters/#whitespace) is a linter that checks for unnecessary newlines at the start and end of functions. Signed-off-by: Matthieu MOREL --- connector/datadogconnector/connector.go | 1 - connector/exceptionsconnector/connector_metrics_test.go | 2 -- connector/failoverconnector/failover_test.go | 2 -- .../failoverconnector/internal/state/pipeline_selector.go | 1 - connector/otlpjsonconnector/logs.go | 1 - connector/otlpjsonconnector/metrics.go | 1 - .../routingconnector/internal/plogutiltest/logs_test.go | 1 - .../internal/pmetricutiltest/metrics_test.go | 1 - .../internal/ptraceutiltest/traces_test.go | 1 - connector/routingconnector/metrics.go | 1 - connector/routingconnector/traces.go | 1 - connector/servicegraphconnector/config_test.go | 1 - connector/servicegraphconnector/connector.go | 2 -- connector/spanmetricsconnector/connector.go | 2 -- connector/spanmetricsconnector/connector_test.go | 7 ------- connector/spanmetricsconnector/internal/metrics/metrics.go | 1 - 16 files changed, 26 deletions(-) diff --git a/connector/datadogconnector/connector.go b/connector/datadogconnector/connector.go index 50e01a3b41c2..f81c244f801a 100644 --- a/connector/datadogconnector/connector.go +++ b/connector/datadogconnector/connector.go @@ -197,7 +197,6 @@ func (c *traceToMetricConnector) enrichStatsPayload(stats *pb.StatsPayload) { for _, stat := range stats.Stats { if stat.ContainerID != "" { if tags, ok := c.containerTagCache.Get(stat.ContainerID); ok { - tagList := tags.(*sync.Map) for _, tag := range stat.Tags { tagList.Store(tag, struct{}{}) diff --git a/connector/exceptionsconnector/connector_metrics_test.go b/connector/exceptionsconnector/connector_metrics_test.go index 797619d575e6..98b12aec7149 100644 --- a/connector/exceptionsconnector/connector_metrics_test.go +++ b/connector/exceptionsconnector/connector_metrics_test.go @@ -108,7 +108,6 @@ func TestConnectorConsumeTraces(t *testing.T) { assert.NotEmpty(t, metrics) verifyBadMetricsOkay(t, metrics[len(metrics)-1]) }) - } func BenchmarkConnectorConsumeTraces(b *testing.B) { @@ -205,7 +204,6 @@ func verifyConsumeMetricsInput(t testing.TB, input pmetric.Metrics, numCumulativ assert.NotZero(t, exemplar.Timestamp()) assert.NotZero(t, exemplar.TraceID()) assert.NotZero(t, exemplar.SpanID()) - } return true } diff --git a/connector/failoverconnector/failover_test.go b/connector/failoverconnector/failover_test.go index f55e015d737c..603bcde86781 100644 --- a/connector/failoverconnector/failover_test.go +++ b/connector/failoverconnector/failover_test.go @@ -214,12 +214,10 @@ func TestFailoverRecovery_MaxRetries(t *testing.T) { require.Eventually(t, func() bool { return consumeTracesAndCheckStable(failoverConnector, 1, tr) }, 3*time.Second, 5*time.Millisecond) - } func resetConsumers(conn *tracesFailover, consumers ...consumer.Traces) { for i, sink := range consumers { - conn.failover.ModifyConsumerAtIndex(i, sink) } conn.failover.pS.TestSetStableIndex(0) diff --git a/connector/failoverconnector/internal/state/pipeline_selector.go b/connector/failoverconnector/internal/state/pipeline_selector.go index 316af30fad30..a0f395513b67 100644 --- a/connector/failoverconnector/internal/state/pipeline_selector.go +++ b/connector/failoverconnector/internal/state/pipeline_selector.go @@ -87,7 +87,6 @@ func (p *PipelineSelector) setToNextPriorityPipeline(idx int) { // RetryHighPriorityPipelines responsible for single iteration through all higher priority pipelines func (p *PipelineSelector) retryHighPriorityPipelines(ctx context.Context, retryGap time.Duration) { - ticker := time.NewTicker(retryGap) defer ticker.Stop() diff --git a/connector/otlpjsonconnector/logs.go b/connector/otlpjsonconnector/logs.go index 0cb524956855..4be368b89688 100644 --- a/connector/otlpjsonconnector/logs.go +++ b/connector/otlpjsonconnector/logs.go @@ -72,7 +72,6 @@ func (c *connectorLogs) ConsumeLogs(ctx context.Context, pl plog.Logs) error { // If no regex matches, log the invalid payload c.logger.Error("Invalid otlp payload") } - } } } diff --git a/connector/otlpjsonconnector/metrics.go b/connector/otlpjsonconnector/metrics.go index fd8fa9ff6c23..603a5c9b5454 100644 --- a/connector/otlpjsonconnector/metrics.go +++ b/connector/otlpjsonconnector/metrics.go @@ -72,7 +72,6 @@ func (c *connectorMetrics) ConsumeLogs(ctx context.Context, pl plog.Logs) error // If no regex matches, log the invalid payload c.logger.Error("Invalid otlp payload") } - } } } diff --git a/connector/routingconnector/internal/plogutiltest/logs_test.go b/connector/routingconnector/internal/plogutiltest/logs_test.go index 282aeddba5bd..b056e51eef5e 100644 --- a/connector/routingconnector/internal/plogutiltest/logs_test.go +++ b/connector/routingconnector/internal/plogutiltest/logs_test.go @@ -14,7 +14,6 @@ import ( ) func TestNewLogs(t *testing.T) { - t.Run("empty", func(t *testing.T) { expected := plog.NewLogs() assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogs("", "", ""))) diff --git a/connector/routingconnector/internal/pmetricutiltest/metrics_test.go b/connector/routingconnector/internal/pmetricutiltest/metrics_test.go index 3be7405a1e14..abfcde29d72c 100644 --- a/connector/routingconnector/internal/pmetricutiltest/metrics_test.go +++ b/connector/routingconnector/internal/pmetricutiltest/metrics_test.go @@ -14,7 +14,6 @@ import ( ) func TestNewMetrics(t *testing.T) { - t.Run("empty", func(t *testing.T) { expected := pmetric.NewMetrics() assert.NoError(t, pmetrictest.CompareMetrics(expected, pmetricutiltest.NewMetrics("", "", "", ""))) diff --git a/connector/routingconnector/internal/ptraceutiltest/traces_test.go b/connector/routingconnector/internal/ptraceutiltest/traces_test.go index 41d553444d38..b0bb12690f6d 100644 --- a/connector/routingconnector/internal/ptraceutiltest/traces_test.go +++ b/connector/routingconnector/internal/ptraceutiltest/traces_test.go @@ -14,7 +14,6 @@ import ( ) func TestNewTraces(t *testing.T) { - t.Run("empty", func(t *testing.T) { expected := ptrace.NewTraces() assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTraces("", "", "", ""))) diff --git a/connector/routingconnector/metrics.go b/connector/routingconnector/metrics.go index 874d8c2d9887..e83f639453d7 100644 --- a/connector/routingconnector/metrics.go +++ b/connector/routingconnector/metrics.go @@ -140,7 +140,6 @@ func (c *metricsConnector) matchAllMetrics(ctx context.Context, md pmetric.Metri noRoutesMatch = false groupMetrics(groups, route.consumer, rmetrics) } - } if noRoutesMatch { // no route conditions are matched, add resource metrics to default exporters group diff --git a/connector/routingconnector/traces.go b/connector/routingconnector/traces.go index 7df2effd74f0..9e0a5c9e0ce0 100644 --- a/connector/routingconnector/traces.go +++ b/connector/routingconnector/traces.go @@ -139,7 +139,6 @@ func (c *tracesConnector) matchAllTraces(ctx context.Context, td ptrace.Traces) noRoutesMatch = false groupTraces(groups, route.consumer, rspans) } - } if noRoutesMatch { // no route conditions are matched, add resource spans to default pipelines group diff --git a/connector/servicegraphconnector/config_test.go b/connector/servicegraphconnector/config_test.go index aa98d986c193..1b8ee6d12ef0 100644 --- a/connector/servicegraphconnector/config_test.go +++ b/connector/servicegraphconnector/config_test.go @@ -43,5 +43,4 @@ func TestLoadConfig(t *testing.T) { }, cfg.Connectors[component.NewID(metadata.Type)], ) - } diff --git a/connector/servicegraphconnector/connector.go b/connector/servicegraphconnector/connector.go index 4b74fec66d85..3cae81614a70 100644 --- a/connector/servicegraphconnector/connector.go +++ b/connector/servicegraphconnector/connector.go @@ -581,7 +581,6 @@ func (p *serviceGraphConnector) collectServerLatencyMetrics(ilm pmetric.ScopeMet timestamp := pcommon.NewTimestampFromTime(time.Now()) for key := range p.reqServerDurationSecondsCount { - dpDuration := mDuration.Histogram().DataPoints().AppendEmpty() dpDuration.SetStartTimestamp(pcommon.NewTimestampFromTime(p.startTime)) dpDuration.SetTimestamp(timestamp) @@ -652,7 +651,6 @@ func (p *serviceGraphConnector) cacheLoop(d time.Duration) { return } } - } // cleanCache removes series that have not been updated in 15 minutes diff --git a/connector/spanmetricsconnector/connector.go b/connector/spanmetricsconnector/connector.go index 1e5d54b793d7..3a0678dd2839 100644 --- a/connector/spanmetricsconnector/connector.go +++ b/connector/spanmetricsconnector/connector.go @@ -358,7 +358,6 @@ func (p *connectorImp) resetState() { } } }) - } } @@ -410,7 +409,6 @@ func (p *connectorImp) aggregateMetrics(traces ptrace.Traces) { h := histograms.GetOrCreate(key, attributes) p.addExemplar(span, duration, h) h.Observe(duration) - } // aggregate sums metrics s := sums.GetOrCreate(key, attributes) diff --git a/connector/spanmetricsconnector/connector_test.go b/connector/spanmetricsconnector/connector_test.go index 72f65db0cd64..35737a189dbb 100644 --- a/connector/spanmetricsconnector/connector_test.go +++ b/connector/spanmetricsconnector/connector_test.go @@ -102,7 +102,6 @@ func verifyExemplarsExist(t testing.TB, input pmetric.Metrics) bool { // Checking all metrics, naming notice: ismC/mC - C here is for Counter. for ismC := 0; ismC < ism.Len(); ismC++ { - m := ism.At(ismC).Metrics() for mC := 0; mC < m.Len(); mC++ { @@ -1055,7 +1054,6 @@ func BenchmarkConnectorConsumeTraces(b *testing.B) { } func TestExcludeDimensionsConsumeTraces(t *testing.T) { - testcases := []struct { dsc string featureGateEnabled bool @@ -1109,7 +1107,6 @@ func TestExcludeDimensionsConsumeTraces(t *testing.T) { for attributeKey := range dp.At(dpi).Attributes().AsRaw() { assert.NotContains(t, excludeDimensions, attributeKey) } - } } case pmetric.MetricTypeEmpty, pmetric.MetricTypeGauge, pmetric.MetricTypeSum, pmetric.MetricTypeSummary: @@ -1121,16 +1118,12 @@ func TestExcludeDimensionsConsumeTraces(t *testing.T) { } } } - } - } } } - }) } - } func TestConnectorConsumeTracesEvictedCacheKey(t *testing.T) { diff --git a/connector/spanmetricsconnector/internal/metrics/metrics.go b/connector/spanmetricsconnector/internal/metrics/metrics.go index 7b6cc937f637..50591aec6980 100644 --- a/connector/spanmetricsconnector/internal/metrics/metrics.go +++ b/connector/spanmetricsconnector/internal/metrics/metrics.go @@ -139,7 +139,6 @@ func (m *exponentialHistogramMetrics) GetOrCreate(key Key, attributes pcommon.Ma maxExemplarCount: m.maxExemplarCount, } m.metrics[key] = h - } return h