From fee94894caddc5674cc47a2b58107e2d5a822d07 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Thu, 15 Feb 2024 13:51:45 -0800 Subject: [PATCH] [chore] more lint fixes (#31287) Related https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/31240 Signed-off-by: Alex Boten --- .../opencensusreceiver/opencensus_test.go | 2 +- receiver/oracledbreceiver/factory.go | 2 +- receiver/oracledbreceiver/scraper_test.go | 8 +- receiver/podmanreceiver/podman_connection.go | 4 +- receiver/postgresqlreceiver/config_test.go | 2 +- .../internal/staleness_end_to_end_test.go | 4 +- .../metrics_receiver_test.go | 2 +- receiver/rabbitmqreceiver/client_test.go | 6 +- receiver/rabbitmqreceiver/scraper_test.go | 8 +- receiver/riakreceiver/client_test.go | 4 +- receiver/riakreceiver/scraper_test.go | 8 +- receiver/saphanareceiver/client_test.go | 16 ++-- receiver/saphanareceiver/config_test.go | 2 +- receiver/saphanareceiver/queries.go | 74 +++++++++---------- .../solacereceiver/messaging_service_test.go | 12 +-- receiver/solacereceiver/receiver_test.go | 52 ++++++------- .../unmarshaller_receive_test.go | 4 +- 17 files changed, 105 insertions(+), 105 deletions(-) diff --git a/receiver/opencensusreceiver/opencensus_test.go b/receiver/opencensusreceiver/opencensus_test.go index 86a5969e7e89..1846baae582a 100644 --- a/receiver/opencensusreceiver/opencensus_test.go +++ b/receiver/opencensusreceiver/opencensus_test.go @@ -297,7 +297,7 @@ func TestReceiveOnUnixDomainSocket_endToEnd(t *testing.T) { ` c := http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (conn net.Conn, err error) { + DialContext: func(context.Context, string, string) (conn net.Conn, err error) { return net.Dial("unix", socketName) }, }, diff --git a/receiver/oracledbreceiver/factory.go b/receiver/oracledbreceiver/factory.go index 1284aa45b21f..9e5f0be7071d 100644 --- a/receiver/oracledbreceiver/factory.go +++ b/receiver/oracledbreceiver/factory.go @@ -44,7 +44,7 @@ type sqlOpenerFunc func(dataSourceName string) (*sql.DB, error) func createReceiverFunc(sqlOpenerFunc sqlOpenerFunc, clientProviderFunc clientProviderFunc) receiver.CreateMetricsFunc { return func( - ctx context.Context, + _ context.Context, settings receiver.CreateSettings, cfg component.Config, consumer consumer.Metrics, diff --git a/receiver/oracledbreceiver/scraper_test.go b/receiver/oracledbreceiver/scraper_test.go index 75865a7b6e2b..5a31ab7b0e18 100644 --- a/receiver/oracledbreceiver/scraper_test.go +++ b/receiver/oracledbreceiver/scraper_test.go @@ -49,7 +49,7 @@ func TestScraper_Scrape(t *testing.T) { }{ { name: "valid", - dbclientFn: func(db *sql.DB, s string, logger *zap.Logger) dbClient { + dbclientFn: func(_ *sql.DB, s string, _ *zap.Logger) dbClient { return &fakeDbClient{ Responses: [][]metricRow{ queryResponses[s], @@ -59,7 +59,7 @@ func TestScraper_Scrape(t *testing.T) { }, { name: "bad tablespace usage", - dbclientFn: func(db *sql.DB, s string, logger *zap.Logger) dbClient { + dbclientFn: func(_ *sql.DB, s string, _ *zap.Logger) dbClient { if s == tablespaceUsageSQL { return &fakeDbClient{Responses: [][]metricRow{ { @@ -75,7 +75,7 @@ func TestScraper_Scrape(t *testing.T) { }, { name: "no limit on tablespace", - dbclientFn: func(db *sql.DB, s string, logger *zap.Logger) dbClient { + dbclientFn: func(_ *sql.DB, s string, _ *zap.Logger) dbClient { if s == tablespaceMaxSpaceSQL { return &fakeDbClient{Responses: [][]metricRow{ { @@ -91,7 +91,7 @@ func TestScraper_Scrape(t *testing.T) { }, { name: "bad value on tablespace", - dbclientFn: func(db *sql.DB, s string, logger *zap.Logger) dbClient { + dbclientFn: func(_ *sql.DB, s string, _ *zap.Logger) dbClient { if s == tablespaceMaxSpaceSQL { return &fakeDbClient{Responses: [][]metricRow{ { diff --git a/receiver/podmanreceiver/podman_connection.go b/receiver/podmanreceiver/podman_connection.go index 2ba4c77b0a65..e9252dbc1bcf 100644 --- a/receiver/podmanreceiver/podman_connection.go +++ b/receiver/podmanreceiver/podman_connection.go @@ -62,7 +62,7 @@ func newPodmanConnection(logger *zap.Logger, endpoint string, sshKey string, ssh func tcpConnection(_url *url.URL) *http.Client { return &http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) { + DialContext: func(context.Context, string, string) (net.Conn, error) { return net.Dial("tcp", _url.Host) }, DisableCompression: true, @@ -168,7 +168,7 @@ func sshConnection(logger *zap.Logger, _url *url.URL, secure bool, key, passphra return &http.Client{ Transport: &http.Transport{ - DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) { + DialContext: func(context.Context, string, string) (net.Conn, error) { return bastion.Dial("unix", _url.Path) }, }, diff --git a/receiver/postgresqlreceiver/config_test.go b/receiver/postgresqlreceiver/config_test.go index f879c85850f6..125d02b74e60 100644 --- a/receiver/postgresqlreceiver/config_test.go +++ b/receiver/postgresqlreceiver/config_test.go @@ -27,7 +27,7 @@ func TestValidate(t *testing.T) { }{ { desc: "missing username and password", - defaultConfigModifier: func(cfg *Config) {}, + defaultConfigModifier: func(*Config) {}, expected: multierr.Combine( errors.New(ErrNoUsername), errors.New(ErrNoPassword), diff --git a/receiver/prometheusreceiver/internal/staleness_end_to_end_test.go b/receiver/prometheusreceiver/internal/staleness_end_to_end_test.go index a07292c1f7fb..ad4a728ce687 100644 --- a/receiver/prometheusreceiver/internal/staleness_end_to_end_test.go +++ b/receiver/prometheusreceiver/internal/staleness_end_to_end_test.go @@ -50,7 +50,7 @@ func TestStalenessMarkersEndToEnd(t *testing.T) { // 1. Setup the server that sends series that intermittently appear and disappear. n := &atomic.Uint64{} - scrapeServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + scrapeServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { // Increment the scrape count atomically per scrape. i := n.Add(1) @@ -81,7 +81,7 @@ jvm_memory_pool_bytes_used{pool="CodeHeap 'non-nmethods'"} %.1f`, float64(i)) // 2. Set up the Prometheus RemoteWrite endpoint. prweUploads := make(chan *prompb.WriteRequest) - prweServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + prweServer := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, req *http.Request) { // Snappy decode the uploads. payload, rerr := io.ReadAll(req.Body) require.NoError(t, rerr) diff --git a/receiver/prometheusreceiver/metrics_receiver_test.go b/receiver/prometheusreceiver/metrics_receiver_test.go index 44a051df996d..4cf878c43613 100644 --- a/receiver/prometheusreceiver/metrics_receiver_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_test.go @@ -1606,7 +1606,7 @@ func TestGCInterval(t *testing.T) { func TestUserAgent(t *testing.T) { uaCh := make(chan string, 1) - svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + svr := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { select { case uaCh <- r.UserAgent(): default: diff --git a/receiver/rabbitmqreceiver/client_test.go b/receiver/rabbitmqreceiver/client_test.go index b71f53027b2b..f6427bb3a3fe 100644 --- a/receiver/rabbitmqreceiver/client_test.go +++ b/receiver/rabbitmqreceiver/client_test.go @@ -99,7 +99,7 @@ func TestGetQueuesDetails(t *testing.T) { desc: "Non-200 Response", testFunc: func(t *testing.T) { // Setup test server - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusUnauthorized) })) defer ts.Close() @@ -115,7 +115,7 @@ func TestGetQueuesDetails(t *testing.T) { desc: "Bad payload returned", testFunc: func(t *testing.T) { // Setup test server - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, err := w.Write([]byte("{}")) require.NoError(t, err) })) @@ -134,7 +134,7 @@ func TestGetQueuesDetails(t *testing.T) { data := loadAPIResponseData(t, queuesAPIResponseFile) // Setup test server - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, err := w.Write(data) require.NoError(t, err) })) diff --git a/receiver/rabbitmqreceiver/scraper_test.go b/receiver/rabbitmqreceiver/scraper_test.go index f97c285fbea8..527c9d15f53c 100644 --- a/receiver/rabbitmqreceiver/scraper_test.go +++ b/receiver/rabbitmqreceiver/scraper_test.go @@ -84,22 +84,22 @@ func TestScaperScrape(t *testing.T) { }{ { desc: "Nil client", - setupMockClient: func(t *testing.T) client { + setupMockClient: func(*testing.T) client { return nil }, - expectedMetricGen: func(t *testing.T) pmetric.Metrics { + expectedMetricGen: func(*testing.T) pmetric.Metrics { return pmetric.NewMetrics() }, expectedErr: errClientNotInit, }, { desc: "API Call Failure", - setupMockClient: func(t *testing.T) client { + setupMockClient: func(*testing.T) client { mockClient := mocks.MockClient{} mockClient.On("GetQueues", mock.Anything).Return(nil, errors.New("some api error")) return &mockClient }, - expectedMetricGen: func(t *testing.T) pmetric.Metrics { + expectedMetricGen: func(*testing.T) pmetric.Metrics { return pmetric.NewMetrics() }, diff --git a/receiver/riakreceiver/client_test.go b/receiver/riakreceiver/client_test.go index a8967701584f..e9ebe738e6ac 100644 --- a/receiver/riakreceiver/client_test.go +++ b/receiver/riakreceiver/client_test.go @@ -83,7 +83,7 @@ func TestNewClient(t *testing.T) { func TestGetStatsDetails(t *testing.T) { t.Run("Non-200 Response", func(t *testing.T) { // Setup test server - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusUnauthorized) })) defer ts.Close() @@ -99,7 +99,7 @@ func TestGetStatsDetails(t *testing.T) { data := loadAPIResponseData(t, statsAPIResponseFile) // Setup test server - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { _, err := w.Write(data) require.NoError(t, err) })) diff --git a/receiver/riakreceiver/scraper_test.go b/receiver/riakreceiver/scraper_test.go index a6b65e1632c7..87792b40d345 100644 --- a/receiver/riakreceiver/scraper_test.go +++ b/receiver/riakreceiver/scraper_test.go @@ -87,10 +87,10 @@ func TestScaperScrape(t *testing.T) { }{ { desc: "Nil client", - setupMockClient: func(t *testing.T) client { + setupMockClient: func(*testing.T) client { return nil }, - expectedMetricGen: func(t *testing.T) pmetric.Metrics { + expectedMetricGen: func(*testing.T) pmetric.Metrics { return pmetric.NewMetrics() }, setupCfg: func() *Config { @@ -100,12 +100,12 @@ func TestScaperScrape(t *testing.T) { }, { desc: "API Call Failure", - setupMockClient: func(t *testing.T) client { + setupMockClient: func(*testing.T) client { mockClient := mocks.MockClient{} mockClient.On("GetStats", mock.Anything).Return(nil, errors.New("some api error")) return &mockClient }, - expectedMetricGen: func(t *testing.T) pmetric.Metrics { + expectedMetricGen: func(*testing.T) pmetric.Metrics { return pmetric.NewMetrics() }, setupCfg: func() *Config { diff --git a/receiver/saphanareceiver/client_test.go b/receiver/saphanareceiver/client_test.go index da5a6e3c4bad..802650a93e82 100644 --- a/receiver/saphanareceiver/client_test.go +++ b/receiver/saphanareceiver/client_test.go @@ -136,16 +136,16 @@ func TestSimpleQueryOutput(t *testing.T) { orderedStats: []queryStat{ { key: "value", - addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string, - m map[string]string) error { + addMetricFunction: func(*metadata.MetricsBuilder, pcommon.Timestamp, string, + map[string]string) error { // Function is a no-op as it's not required for this test return nil }, }, { key: "rate", - addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string, - m map[string]string) error { + addMetricFunction: func(*metadata.MetricsBuilder, pcommon.Timestamp, string, + map[string]string) error { // Function is a no-op as it's not required for this test return nil }, @@ -192,16 +192,16 @@ func TestNullOutput(t *testing.T) { orderedStats: []queryStat{ { key: "value", - addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string, - m map[string]string) error { + addMetricFunction: func(*metadata.MetricsBuilder, pcommon.Timestamp, string, + map[string]string) error { // Function is a no-op as it's not required for this test return nil }, }, { key: "rate", - addMetricFunction: func(mb *metadata.MetricsBuilder, t pcommon.Timestamp, val string, - m map[string]string) error { + addMetricFunction: func(*metadata.MetricsBuilder, pcommon.Timestamp, string, + map[string]string) error { // Function is a no-op as it's not required for this test return nil }, diff --git a/receiver/saphanareceiver/config_test.go b/receiver/saphanareceiver/config_test.go index 37ca8221ef2e..898983925f05 100644 --- a/receiver/saphanareceiver/config_test.go +++ b/receiver/saphanareceiver/config_test.go @@ -27,7 +27,7 @@ func TestValidate(t *testing.T) { }{ { desc: "missing username and password", - defaultConfigModifier: func(cfg *Config) {}, + defaultConfigModifier: func(*Config) {}, expected: multierr.Combine( errors.New(ErrNoUsername), errors.New(ErrNoPassword), diff --git a/receiver/saphanareceiver/queries.go b/receiver/saphanareceiver/queries.go index a30d28d69b48..3a6465016354 100644 --- a/receiver/saphanareceiver/queries.go +++ b/receiver/saphanareceiver/queries.go @@ -63,14 +63,14 @@ var queries = []monitoringQuery{ { key: "active_services", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaServiceCountDataPoint(now, val, metadata.AttributeServiceStatusActive) }, }, { key: "inactive_services", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaServiceCountDataPoint(now, val, metadata.AttributeServiceStatusInactive) }, }, @@ -86,14 +86,14 @@ var queries = []monitoringQuery{ { key: "active_threads", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaServiceThreadCountDataPoint(now, val, metadata.AttributeThreadStatusActive) }, }, { key: "inactive_threads", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaServiceThreadCountDataPoint(now, val, metadata.AttributeThreadStatusInactive) }, }, @@ -109,56 +109,56 @@ var queries = []monitoringQuery{ { key: "main_data", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaColumnMemoryUsedDataPoint(now, val, metadata.AttributeColumnMemoryTypeMain, metadata.AttributeColumnMemorySubtypeData) }, }, { key: "main_dict", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaColumnMemoryUsedDataPoint(now, val, metadata.AttributeColumnMemoryTypeMain, metadata.AttributeColumnMemorySubtypeDict) }, }, { key: "main_index", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaColumnMemoryUsedDataPoint(now, val, metadata.AttributeColumnMemoryTypeMain, metadata.AttributeColumnMemorySubtypeIndex) }, }, { key: "main_misc", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaColumnMemoryUsedDataPoint(now, val, metadata.AttributeColumnMemoryTypeMain, metadata.AttributeColumnMemorySubtypeMisc) }, }, { key: "delta_data", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaColumnMemoryUsedDataPoint(now, val, metadata.AttributeColumnMemoryTypeDelta, metadata.AttributeColumnMemorySubtypeData) }, }, { key: "delta_dict", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaColumnMemoryUsedDataPoint(now, val, metadata.AttributeColumnMemoryTypeDelta, metadata.AttributeColumnMemorySubtypeDict) }, }, { key: "delta_index", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaColumnMemoryUsedDataPoint(now, val, metadata.AttributeColumnMemoryTypeDelta, metadata.AttributeColumnMemorySubtypeIndex) }, }, { key: "delta_misc", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaColumnMemoryUsedDataPoint(now, val, metadata.AttributeColumnMemoryTypeDelta, metadata.AttributeColumnMemorySubtypeMisc) }, }, @@ -174,14 +174,14 @@ var queries = []monitoringQuery{ { key: "fixed", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaRowStoreMemoryUsedDataPoint(now, val, metadata.AttributeRowMemoryTypeFixed) }, }, { key: "variable", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaRowStoreMemoryUsedDataPoint(now, val, metadata.AttributeRowMemoryTypeVariable) }, }, @@ -232,7 +232,7 @@ var queries = []monitoringQuery{ { key: "age", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaBackupLatestDataPoint(now, val) }, }, @@ -281,21 +281,21 @@ var queries = []monitoringQuery{ { key: "updates", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaTransactionCountDataPoint(now, val, metadata.AttributeTransactionTypeUpdate) }, }, { key: "commits", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaTransactionCountDataPoint(now, val, metadata.AttributeTransactionTypeCommit) }, }, { key: "rollbacks", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaTransactionCountDataPoint(now, val, metadata.AttributeTransactionTypeRollback) }, }, @@ -311,7 +311,7 @@ var queries = []monitoringQuery{ { key: "blocks", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaTransactionBlockedDataPoint(now, val) }, }, @@ -415,35 +415,35 @@ var queries = []monitoringQuery{ { key: "external", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaNetworkRequestFinishedCountDataPoint(now, val, metadata.AttributeInternalExternalRequestTypeExternal) }, }, { key: "internal", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaNetworkRequestFinishedCountDataPoint(now, val, metadata.AttributeInternalExternalRequestTypeInternal) }, }, { key: "active", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaNetworkRequestCountDataPoint(now, val, metadata.AttributeActivePendingRequestStateActive) }, }, { key: "pending", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaNetworkRequestCountDataPoint(now, val, metadata.AttributeActivePendingRequestStatePending) }, }, { key: "avg_time", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaNetworkRequestAverageTimeDataPoint(now, val) }, }, @@ -722,91 +722,91 @@ var queries = []monitoringQuery{ { key: "free_physical_memory", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaHostMemoryCurrentDataPoint(now, val, metadata.AttributeMemoryStateUsedFreeFree) }, }, { key: "used_physical_memory", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaHostMemoryCurrentDataPoint(now, val, metadata.AttributeMemoryStateUsedFreeUsed) }, }, { key: "free_swap_space", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaHostSwapCurrentDataPoint(now, val, metadata.AttributeHostSwapStateFree) }, }, { key: "used_swap_space", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaHostSwapCurrentDataPoint(now, val, metadata.AttributeHostSwapStateUsed) }, }, { key: "instance_total_used", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaInstanceMemoryCurrentDataPoint(now, val, metadata.AttributeMemoryStateUsedFreeUsed) }, }, { key: "instance_total_used_peak", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaInstanceMemoryUsedPeakDataPoint(now, val) }, }, { key: "instance_total_free", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaInstanceMemoryCurrentDataPoint(now, val, metadata.AttributeMemoryStateUsedFreeFree) }, }, { key: "instance_code_size", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaInstanceCodeSizeDataPoint(now, val) }, }, { key: "instance_shared_memory_allocated", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaInstanceMemorySharedAllocatedDataPoint(now, val) }, }, { key: "cpu_user", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaCPUUsedDataPoint(now, val, metadata.AttributeCPUTypeUser) }, }, { key: "cpu_system", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaCPUUsedDataPoint(now, val, metadata.AttributeCPUTypeSystem) }, }, { key: "cpu_io_wait", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaCPUUsedDataPoint(now, val, metadata.AttributeCPUTypeIoWait) }, }, { key: "cpu_idle", addMetricFunction: func(mb *metadata.MetricsBuilder, now pcommon.Timestamp, val string, - row map[string]string) error { + _ map[string]string) error { return mb.RecordSaphanaCPUUsedDataPoint(now, val, metadata.AttributeCPUTypeIdle) }, }, diff --git a/receiver/solacereceiver/messaging_service_test.go b/receiver/solacereceiver/messaging_service_test.go index be6d5b575d45..678ad4f5666d 100644 --- a/receiver/solacereceiver/messaging_service_test.go +++ b/receiver/solacereceiver/messaging_service_test.go @@ -156,7 +156,7 @@ func TestNewAMQPMessagingServiceFactory(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if tt.want != nil && tt.want.connectConfig.saslConfig != nil { - connSASLPlain = func(username, password string) amqp.SASLType { + connSASLPlain = func(string, string) amqp.SASLType { connSASLPlain = amqp.SASLTypePlain return tt.want.connectConfig.saslConfig } @@ -183,7 +183,7 @@ func TestNewAMQPMessagingServiceFactory(t *testing.T) { func TestAMQPDialFailure(t *testing.T) { const expectedAddr = "some-host:1234" var expectedErr = fmt.Errorf("some error") - dialFunc = func(ctx context.Context, addr string, opts *amqp.ConnOptions) (*amqp.Conn, error) { + dialFunc = func(_ context.Context, addr string, _ *amqp.ConnOptions) (*amqp.Conn, error) { defer func() { dialFunc = amqp.Dial }() // reset dialFunc assert.Equal(t, expectedAddr, addr) return nil, expectedErr @@ -209,7 +209,7 @@ func TestAMQPDialConfigOptionsWithoutTLS(t *testing.T) { const expectedAddr = "some-host:1234" var expectedErr = fmt.Errorf("some error") expectedAuthConnOption := amqp.SASLTypeAnonymous() - dialFunc = func(ctx context.Context, addr string, opts *amqp.ConnOptions) (*amqp.Conn, error) { + dialFunc = func(_ context.Context, addr string, opts *amqp.ConnOptions) (*amqp.Conn, error) { defer func() { dialFunc = amqp.Dial }() // reset dialFunc assert.Equal(t, expectedAddr, addr) testFunctionEquality(t, expectedAuthConnOption, opts.SASLType) @@ -240,7 +240,7 @@ func TestAMQPDialConfigOptionsWithTLS(t *testing.T) { expectedTLSConnOption := &tls.Config{ InsecureSkipVerify: false, } - dialFunc = func(ctx context.Context, addr string, opts *amqp.ConnOptions) (*amqp.Conn, error) { + dialFunc = func(_ context.Context, addr string, opts *amqp.ConnOptions) (*amqp.Conn, error) { defer func() { dialFunc = amqp.Dial }() // reset dialFunc assert.Equal(t, expectedAddr, addr) testFunctionEquality(t, expectedAuthConnOption, opts.SASLType) @@ -384,7 +384,7 @@ func startMockedService(t *testing.T) (*amqpMessagingService, *connMock) { writeData := [][]byte{[]byte(amqpProtocolHeaderResponse), []byte(amqpOpenResponse), []byte(amqpSessionBeginResponse), []byte(amqpAttachResponse)} // we need a custom write handler allowing for waiting until a flow start is called flowStartCalled := make(chan struct{}) - mockWriteData(conn, writeData, func(sentData, receivedData []byte) { + mockWriteData(conn, writeData, func(sentData, _ []byte) { if len(sentData) > 10 && sentData[10] == 19 { // check if the type is 19 (flow) close(flowStartCalled) } @@ -488,7 +488,7 @@ func mockWriteData(conn *connMock, data [][]byte, callbacks ...func(sentData, re } func mockDialFunc(conn *connMock) { - dialFunc = func(ctx context.Context, addr string, opts *amqp.ConnOptions) (*amqp.Conn, error) { + dialFunc = func(ctx context.Context, _ string, opts *amqp.ConnOptions) (*amqp.Conn, error) { defer func() { dialFunc = amqp.Dial }() // reset dialFunc return amqp.NewConn(ctx, conn, opts) } diff --git a/receiver/solacereceiver/receiver_test.go b/receiver/solacereceiver/receiver_test.go index 2dfd97be13bd..e8b657176ef0 100644 --- a/receiver/solacereceiver/receiver_test.go +++ b/receiver/solacereceiver/receiver_test.go @@ -102,7 +102,7 @@ func TestReceiveMessage(t *testing.T) { // populate mock messagingService and unmarshaller functions, expecting them each to be called at most once var receiveMessagesCalled, ackCalled, nackCalled, unmarshalCalled bool - messagingService.receiveMessageFunc = func(ctx context.Context) (*inboundMessage, error) { + messagingService.receiveMessageFunc = func(context.Context) (*inboundMessage, error) { assert.False(t, receiveMessagesCalled) receiveMessagesCalled = true if testCase.receiveMessageErr != nil { @@ -110,7 +110,7 @@ func TestReceiveMessage(t *testing.T) { } return msg, nil } - messagingService.ackFunc = func(ctx context.Context, msg *inboundMessage) error { + messagingService.ackFunc = func(context.Context, *inboundMessage) error { assert.False(t, ackCalled) ackCalled = true if testCase.ackErr != nil { @@ -118,7 +118,7 @@ func TestReceiveMessage(t *testing.T) { } return nil } - messagingService.nackFunc = func(ctx context.Context, msg *inboundMessage) error { + messagingService.nackFunc = func(context.Context, *inboundMessage) error { assert.False(t, nackCalled) nackCalled = true if testCase.nackErr != nil { @@ -126,7 +126,7 @@ func TestReceiveMessage(t *testing.T) { } return nil } - unmarshaller.unmarshalFunc = func(msg *inboundMessage) (ptrace.Traces, error) { + unmarshaller.unmarshalFunc = func(*inboundMessage) (ptrace.Traces, error) { assert.False(t, unmarshalCalled) unmarshalCalled = true if testCase.unmarshalErr != nil { @@ -161,20 +161,20 @@ func TestReceiveMessagesTerminateWithCtxDone(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) msg := &inboundMessage{} trace := newTestTracesWithSpans(1) - messagingService.receiveMessageFunc = func(ctx context.Context) (*inboundMessage, error) { + messagingService.receiveMessageFunc = func(context.Context) (*inboundMessage, error) { assert.False(t, receiveMessagesCalled) receiveMessagesCalled = true return msg, nil } ackCalled := false - messagingService.ackFunc = func(ctx context.Context, msg *inboundMessage) error { + messagingService.ackFunc = func(context.Context, *inboundMessage) error { assert.False(t, ackCalled) ackCalled = true cancel() return nil } unmarshalCalled := false - unmarshaller.unmarshalFunc = func(msg *inboundMessage) (ptrace.Traces, error) { + unmarshaller.unmarshalFunc = func(*inboundMessage) (ptrace.Traces, error) { assert.False(t, unmarshalCalled) unmarshalCalled = true return trace, nil @@ -197,7 +197,7 @@ func TestReceiverLifecycle(t *testing.T) { return nil } closeCalled := make(chan struct{}) - messagingService.closeFunc = func(ctx context.Context) { + messagingService.closeFunc = func(context.Context) { validateMetric(t, receiver.metrics.views.receiverStatus, receiverStateTerminating) close(closeCalled) } @@ -279,7 +279,7 @@ func TestReceiverUnmarshalVersionFailureExpectingDisable(t *testing.T) { dialDone := make(chan struct{}) nackCalled := make(chan struct{}) closeDone := make(chan struct{}) - unmarshaller.unmarshalFunc = func(msg *inboundMessage) (ptrace.Traces, error) { + unmarshaller.unmarshalFunc = func(*inboundMessage) (ptrace.Traces, error) { return ptrace.Traces{}, errUpgradeRequired } msgService.dialFunc = func(context.Context) error { @@ -291,19 +291,19 @@ func TestReceiverUnmarshalVersionFailureExpectingDisable(t *testing.T) { close(dialDone) return nil } - msgService.receiveMessageFunc = func(ctx context.Context) (*inboundMessage, error) { + msgService.receiveMessageFunc = func(context.Context) (*inboundMessage, error) { // we only expect a single receiveMessage call when unmarshal returns unknown version - msgService.receiveMessageFunc = func(ctx context.Context) (*inboundMessage, error) { + msgService.receiveMessageFunc = func(context.Context) (*inboundMessage, error) { t.Error("did not expect receiveMessage to be called again") return nil, nil } return nil, nil } - msgService.nackFunc = func(ctx context.Context, msg *inboundMessage) error { + msgService.nackFunc = func(context.Context, *inboundMessage) error { close(nackCalled) return nil } - msgService.closeFunc = func(ctx context.Context) { + msgService.closeFunc = func(context.Context) { close(closeDone) } // start the receiver @@ -357,7 +357,7 @@ func TestReceiverFlowControlDelayedRetry(t *testing.T) { receiver.config.Flow.DelayedRetry.Delay = delay var err error // we want to return an error at first, then set the next consumer to a noop consumer - receiver.nextConsumer, err = consumer.NewTraces(func(ctx context.Context, ld ptrace.Traces) error { + receiver.nextConsumer, err = consumer.NewTraces(func(context.Context, ptrace.Traces) error { receiver.nextConsumer = tc.nextConsumer return fmt.Errorf("Some temporary error") }) @@ -365,15 +365,15 @@ func TestReceiverFlowControlDelayedRetry(t *testing.T) { // populate mock messagingService and unmarshaller functions, expecting them each to be called at most once var ackCalled bool - messagingService.ackFunc = func(ctx context.Context, msg *inboundMessage) error { + messagingService.ackFunc = func(context.Context, *inboundMessage) error { assert.False(t, ackCalled) ackCalled = true return nil } - messagingService.receiveMessageFunc = func(ctx context.Context) (*inboundMessage, error) { + messagingService.receiveMessageFunc = func(context.Context) (*inboundMessage, error) { return &inboundMessage{}, nil } - unmarshaller.unmarshalFunc = func(msg *inboundMessage) (ptrace.Traces, error) { + unmarshaller.unmarshalFunc = func(*inboundMessage) (ptrace.Traces, error) { return ptrace.NewTraces(), nil } @@ -414,9 +414,9 @@ func TestReceiverFlowControlDelayedRetryInterrupt(t *testing.T) { receiver.config.Flow.DelayedRetry.Delay = 10 * time.Second var err error // we want to return an error at first, then set the next consumer to a noop consumer - receiver.nextConsumer, err = consumer.NewTraces(func(ctx context.Context, ld ptrace.Traces) error { + receiver.nextConsumer, err = consumer.NewTraces(func(context.Context, ptrace.Traces) error { // if we are called again, fatal - receiver.nextConsumer, err = consumer.NewTraces(func(ctx context.Context, ld ptrace.Traces) error { + receiver.nextConsumer, err = consumer.NewTraces(func(context.Context, ptrace.Traces) error { require.Fail(t, "Did not expect next consumer to be called again") return nil }) @@ -426,10 +426,10 @@ func TestReceiverFlowControlDelayedRetryInterrupt(t *testing.T) { require.NoError(t, err) // populate mock messagingService and unmarshaller functions, expecting them each to be called at most once - messagingService.receiveMessageFunc = func(ctx context.Context) (*inboundMessage, error) { + messagingService.receiveMessageFunc = func(context.Context) (*inboundMessage, error) { return &inboundMessage{}, nil } - unmarshaller.unmarshalFunc = func(msg *inboundMessage) (ptrace.Traces, error) { + unmarshaller.unmarshalFunc = func(*inboundMessage) (ptrace.Traces, error) { return ptrace.NewTraces(), nil } @@ -468,13 +468,13 @@ func TestReceiverFlowControlDelayedRetryMultipleRetries(t *testing.T) { var err error var currentRetries int64 // we want to return an error at first, then set the next consumer to a noop consumer - receiver.nextConsumer, err = consumer.NewTraces(func(ctx context.Context, ld ptrace.Traces) error { + receiver.nextConsumer, err = consumer.NewTraces(func(context.Context, ptrace.Traces) error { if currentRetries > 0 { validateMetric(t, receiver.metrics.views.flowControlRecentRetries, currentRetries) } currentRetries++ if currentRetries == retryCount { - receiver.nextConsumer, err = consumer.NewTraces(func(ctx context.Context, ld ptrace.Traces) error { + receiver.nextConsumer, err = consumer.NewTraces(func(context.Context, ptrace.Traces) error { return nil }) } @@ -485,15 +485,15 @@ func TestReceiverFlowControlDelayedRetryMultipleRetries(t *testing.T) { // populate mock messagingService and unmarshaller functions, expecting them each to be called at most once var ackCalled bool - messagingService.ackFunc = func(ctx context.Context, msg *inboundMessage) error { + messagingService.ackFunc = func(context.Context, *inboundMessage) error { assert.False(t, ackCalled) ackCalled = true return nil } - messagingService.receiveMessageFunc = func(ctx context.Context) (*inboundMessage, error) { + messagingService.receiveMessageFunc = func(context.Context) (*inboundMessage, error) { return &inboundMessage{}, nil } - unmarshaller.unmarshalFunc = func(msg *inboundMessage) (ptrace.Traces, error) { + unmarshaller.unmarshalFunc = func(*inboundMessage) (ptrace.Traces, error) { return ptrace.NewTraces(), nil } diff --git a/receiver/solacereceiver/unmarshaller_receive_test.go b/receiver/solacereceiver/unmarshaller_receive_test.go index 70a6a94176ef..c5be6dcd226c 100644 --- a/receiver/solacereceiver/unmarshaller_receive_test.go +++ b/receiver/solacereceiver/unmarshaller_receive_test.go @@ -326,7 +326,7 @@ func TestReceiveUnmarshallerEvents(t *testing.T) { { // don't expect any events when none are present in the span data name: "No Events", spanData: &receive_v1.SpanData{}, - populateExpectedSpan: func(span ptrace.Span) {}, + populateExpectedSpan: func(ptrace.Span) {}, }, { // when an enqueue event is present, expect it to be added to the span events name: "Enqueue Event Queue", @@ -402,7 +402,7 @@ func TestReceiveUnmarshallerEvents(t *testing.T) { }, }, }, - populateExpectedSpan: func(span ptrace.Span) {}, + populateExpectedSpan: func(ptrace.Span) {}, unmarshallingErrors: 1, }, { // Local Transaction