From a1e102f263da668f0faa1ef663a9e02a6f6af4ae Mon Sep 17 00:00:00 2001 From: Mrod1598 Date: Thu, 4 Nov 2021 11:16:50 -0400 Subject: [PATCH 1/7] Add Unix Support --- receiver/mysqlreceiver/README.md | 2 + receiver/mysqlreceiver/client.go | 38 ++++++++++--------- .../{client_mock_test.go => client_test.go} | 20 +++++++++- receiver/mysqlreceiver/config.go | 3 +- receiver/mysqlreceiver/factory.go | 6 ++- receiver/mysqlreceiver/factory_test.go | 5 ++- receiver/mysqlreceiver/go.mod | 1 + receiver/mysqlreceiver/go.sum | 1 + receiver/mysqlreceiver/scraper.go | 11 ++---- receiver/mysqlreceiver/scraper_test.go | 5 ++- 10 files changed, 62 insertions(+), 30 deletions(-) rename receiver/mysqlreceiver/{client_mock_test.go => client_test.go} (78%) diff --git a/receiver/mysqlreceiver/README.md b/receiver/mysqlreceiver/README.md index 631f4d31e9ed..b0bb1b0f311e 100644 --- a/receiver/mysqlreceiver/README.md +++ b/receiver/mysqlreceiver/README.md @@ -24,6 +24,8 @@ The following settings are optional: - `collection_interval` (default = `10s`): This receiver collects metrics on an interval. This value must be a string readable by Golang's [time.ParseDuration](https://pkg.go.dev/time#ParseDuration). Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. +- `transport`: (default = `tcp`): Defines the network to use for connecting to the server. + ### Example Configuration ```yaml diff --git a/receiver/mysqlreceiver/client.go b/receiver/mysqlreceiver/client.go index f230c510ae51..cb9d868ef6ca 100644 --- a/receiver/mysqlreceiver/client.go +++ b/receiver/mysqlreceiver/client.go @@ -22,36 +22,35 @@ import ( _ "github.com/go-sql-driver/mysql" ) -type client interface { +type Client interface { + Connect() error getGlobalStats() (map[string]string, error) getInnodbStats() (map[string]string, error) Close() error } type mySQLClient struct { - client *sql.DB + connStr string + client *sql.DB } -var _ client = (*mySQLClient)(nil) +var _ Client = (*mySQLClient)(nil) -type mySQLConfig struct { - username string - password string - database string - endpoint string -} +func newMySQLClient(conf *Config) Client { + connStr := fmt.Sprintf("%s:%s@%s(%s)/%s", conf.Username, conf.Password, conf.Transport, conf.Endpoint, conf.Database) -func newMySQLClient(conf mySQLConfig) (*mySQLClient, error) { - connStr := fmt.Sprintf("%s:%s@tcp(%s)/%s", conf.username, conf.password, conf.endpoint, conf.database) + return &mySQLClient{ + connStr: connStr, + } +} - db, err := sql.Open("mysql", connStr) +func (c *mySQLClient) Connect() error { + clientDB, err := sql.Open("mysql", c.connStr) if err != nil { - return nil, err + return fmt.Errorf("unable to connect to database: %w", err) } - - return &mySQLClient{ - client: db, - }, nil + c.client = clientDB + return nil } // getGlobalStats queries the db for global status metrics. @@ -85,5 +84,8 @@ func Query(c mySQLClient, query string) (map[string]string, error) { } func (c *mySQLClient) Close() error { - return c.client.Close() + if c.client != nil { + return c.client.Close() + } + return nil } diff --git a/receiver/mysqlreceiver/client_mock_test.go b/receiver/mysqlreceiver/client_test.go similarity index 78% rename from receiver/mysqlreceiver/client_mock_test.go rename to receiver/mysqlreceiver/client_test.go index f6d6325a18e5..c8a5d2629da6 100644 --- a/receiver/mysqlreceiver/client_mock_test.go +++ b/receiver/mysqlreceiver/client_test.go @@ -19,11 +19,16 @@ import ( "os" "path" "strings" + "testing" + + "github.com/DATA-DOG/go-sqlmock" + "github.com/stretchr/testify/mock" ) -var _ client = (*fakeClient)(nil) +var _ Client = (*fakeClient)(nil) type fakeClient struct { + mock.Mock } func readFile(fname string) (map[string]string, error) { @@ -42,6 +47,19 @@ func readFile(fname string) (map[string]string, error) { return stats, nil } +func TestClientConnection(t *testing.T) { + db, mock, err := sqlmock.New() + mc := mock.NewMockClient() + client := fakeClient{ + connStr: "", + } +} + +func (fc *fakeClient) Connect() error { + args := fc.Called() + return args.Error(0) +} + func (c *fakeClient) getGlobalStats() (map[string]string, error) { return readFile("global_stats") } diff --git a/receiver/mysqlreceiver/config.go b/receiver/mysqlreceiver/config.go index 2a2deba4a1a2..c241a7b8e84a 100644 --- a/receiver/mysqlreceiver/config.go +++ b/receiver/mysqlreceiver/config.go @@ -17,6 +17,7 @@ package mysqlreceiver import ( "errors" + "go.opentelemetry.io/collector/config/confignet" "go.opentelemetry.io/collector/receiver/scraperhelper" "go.uber.org/multierr" ) @@ -26,7 +27,7 @@ type Config struct { Username string `mapstructure:"username"` Password string `mapstructure:"password"` Database string `mapstructure:"database"` - Endpoint string `mapstructure:"endpoint"` + confignet.NetAddr `mapstructure:",squash"` } // Errors for missing required config parameters. diff --git a/receiver/mysqlreceiver/factory.go b/receiver/mysqlreceiver/factory.go index 0f6cb57826b9..25f8840c9e6c 100644 --- a/receiver/mysqlreceiver/factory.go +++ b/receiver/mysqlreceiver/factory.go @@ -22,6 +22,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config" + "go.opentelemetry.io/collector/config/confignet" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/receiver/receiverhelper" "go.opentelemetry.io/collector/receiver/scraperhelper" @@ -44,7 +45,10 @@ func createDefaultConfig() config.Receiver { ReceiverSettings: config.NewReceiverSettings(config.NewComponentID(typeStr)), CollectionInterval: 10 * time.Second, }, - Endpoint: "localhost:3306", + NetAddr: confignet.NetAddr{ + Endpoint: "localhost:3306", + Transport: "tcp", + }, } } diff --git a/receiver/mysqlreceiver/factory_test.go b/receiver/mysqlreceiver/factory_test.go index d34869b5bf6b..a355e6026e01 100644 --- a/receiver/mysqlreceiver/factory_test.go +++ b/receiver/mysqlreceiver/factory_test.go @@ -22,6 +22,7 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/config" + "go.opentelemetry.io/collector/config/confignet" "go.opentelemetry.io/collector/consumer/consumertest" "go.opentelemetry.io/collector/receiver/scraperhelper" ) @@ -53,7 +54,9 @@ func TestCreateMetricsReceiver(t *testing.T) { }, Username: "otel", Password: "otel", - Endpoint: "localhost:3306", + NetAddr: confignet.NetAddr{ + Endpoint: "localhost:3306", + }, }, consumertest.NewNop(), ) diff --git a/receiver/mysqlreceiver/go.mod b/receiver/mysqlreceiver/go.mod index 6f9eeb708404..15a2082cc1f2 100644 --- a/receiver/mysqlreceiver/go.mod +++ b/receiver/mysqlreceiver/go.mod @@ -25,6 +25,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.6.1 // indirect github.com/spf13/cast v1.4.1 // indirect + github.com/stretchr/objx v0.1.0 // indirect go.opencensus.io v0.23.0 // indirect go.opentelemetry.io/otel v1.1.0 // indirect go.opentelemetry.io/otel/metric v0.24.0 // indirect diff --git a/receiver/mysqlreceiver/go.sum b/receiver/mysqlreceiver/go.sum index 85602c08883b..addbeb82b13d 100644 --- a/receiver/mysqlreceiver/go.sum +++ b/receiver/mysqlreceiver/go.sum @@ -350,6 +350,7 @@ github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0 github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/receiver/mysqlreceiver/scraper.go b/receiver/mysqlreceiver/scraper.go index 3ee1be2e3942..c95fb626a410 100644 --- a/receiver/mysqlreceiver/scraper.go +++ b/receiver/mysqlreceiver/scraper.go @@ -29,7 +29,7 @@ import ( ) type mySQLScraper struct { - client client + client Client stopOnce sync.Once logger *zap.Logger @@ -48,12 +48,9 @@ func newMySQLScraper( // start starts the scraper by initializing the db client connection. func (m *mySQLScraper) start(_ context.Context, host component.Host) error { - client, err := newMySQLClient(mySQLConfig{ - username: m.config.Username, - password: m.config.Password, - database: m.config.Database, - endpoint: m.config.Endpoint, - }) + client := newMySQLClient(m.config) + + err := client.Connect() if err != nil { return err } diff --git a/receiver/mysqlreceiver/scraper_test.go b/receiver/mysqlreceiver/scraper_test.go index ff4483a905a3..0403e3d5a14f 100644 --- a/receiver/mysqlreceiver/scraper_test.go +++ b/receiver/mysqlreceiver/scraper_test.go @@ -20,6 +20,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/config/confignet" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/scrapertest" @@ -30,7 +31,9 @@ func TestScrape(t *testing.T) { sc := newMySQLScraper(zap.NewNop(), &Config{ Username: "otel", Password: "otel", - Endpoint: "localhost:3306", + NetAddr: confignet.NetAddr{ + Endpoint: "localhost:3306", + }, }) sc.client = &mysqlMock From 249423a00e46b92f2ebae70aa25c1af8002c470a Mon Sep 17 00:00:00 2001 From: Mrod1598 Date: Thu, 4 Nov 2021 15:16:18 -0400 Subject: [PATCH 2/7] Remove extra mock function --- .../{client_test.go => client_mock_test.go} | 13 +------------ receiver/mysqlreceiver/go.mod | 1 + receiver/mysqlreceiver/go.sum | 2 ++ 3 files changed, 4 insertions(+), 12 deletions(-) rename receiver/mysqlreceiver/{client_test.go => client_mock_test.go} (86%) diff --git a/receiver/mysqlreceiver/client_test.go b/receiver/mysqlreceiver/client_mock_test.go similarity index 86% rename from receiver/mysqlreceiver/client_test.go rename to receiver/mysqlreceiver/client_mock_test.go index c8a5d2629da6..fb4573a3a872 100644 --- a/receiver/mysqlreceiver/client_test.go +++ b/receiver/mysqlreceiver/client_mock_test.go @@ -19,9 +19,7 @@ import ( "os" "path" "strings" - "testing" - "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/mock" ) @@ -47,17 +45,8 @@ func readFile(fname string) (map[string]string, error) { return stats, nil } -func TestClientConnection(t *testing.T) { - db, mock, err := sqlmock.New() - mc := mock.NewMockClient() - client := fakeClient{ - connStr: "", - } -} - func (fc *fakeClient) Connect() error { - args := fc.Called() - return args.Error(0) + return nil } func (c *fakeClient) getGlobalStats() (map[string]string, error) { diff --git a/receiver/mysqlreceiver/go.mod b/receiver/mysqlreceiver/go.mod index 15a2082cc1f2..90bbcd8634c9 100644 --- a/receiver/mysqlreceiver/go.mod +++ b/receiver/mysqlreceiver/go.mod @@ -13,6 +13,7 @@ require ( ) require ( + github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/gogo/protobuf v1.3.2 // indirect diff --git a/receiver/mysqlreceiver/go.sum b/receiver/mysqlreceiver/go.sum index addbeb82b13d..63d74993dcfd 100644 --- a/receiver/mysqlreceiver/go.sum +++ b/receiver/mysqlreceiver/go.sum @@ -40,6 +40,8 @@ contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= From 1edcd5a9d6195303aedd0832158386b1e0aecd9a Mon Sep 17 00:00:00 2001 From: Mrod1598 Date: Thu, 4 Nov 2021 16:03:16 -0400 Subject: [PATCH 3/7] Fix lint --- receiver/mysqlreceiver/client_mock_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receiver/mysqlreceiver/client_mock_test.go b/receiver/mysqlreceiver/client_mock_test.go index fb4573a3a872..3ac25c142c3a 100644 --- a/receiver/mysqlreceiver/client_mock_test.go +++ b/receiver/mysqlreceiver/client_mock_test.go @@ -45,7 +45,7 @@ func readFile(fname string) (map[string]string, error) { return stats, nil } -func (fc *fakeClient) Connect() error { +func (c *fakeClient) Connect() error { return nil } From a8db67c620fb1e3314b78b925e0b48da3f618440 Mon Sep 17 00:00:00 2001 From: Mrod1598 Date: Tue, 9 Nov 2021 14:55:53 -0500 Subject: [PATCH 4/7] Unexpose client interface --- receiver/mysqlreceiver/client.go | 6 +++--- receiver/mysqlreceiver/client_mock_test.go | 2 +- receiver/mysqlreceiver/scraper.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/receiver/mysqlreceiver/client.go b/receiver/mysqlreceiver/client.go index cb9d868ef6ca..d34bca7205f3 100644 --- a/receiver/mysqlreceiver/client.go +++ b/receiver/mysqlreceiver/client.go @@ -22,7 +22,7 @@ import ( _ "github.com/go-sql-driver/mysql" ) -type Client interface { +type client interface { Connect() error getGlobalStats() (map[string]string, error) getInnodbStats() (map[string]string, error) @@ -34,9 +34,9 @@ type mySQLClient struct { client *sql.DB } -var _ Client = (*mySQLClient)(nil) +var _ client = (*mySQLClient)(nil) -func newMySQLClient(conf *Config) Client { +func newMySQLClient(conf *Config) client { connStr := fmt.Sprintf("%s:%s@%s(%s)/%s", conf.Username, conf.Password, conf.Transport, conf.Endpoint, conf.Database) return &mySQLClient{ diff --git a/receiver/mysqlreceiver/client_mock_test.go b/receiver/mysqlreceiver/client_mock_test.go index 3ac25c142c3a..5a4fe2dedfe3 100644 --- a/receiver/mysqlreceiver/client_mock_test.go +++ b/receiver/mysqlreceiver/client_mock_test.go @@ -23,7 +23,7 @@ import ( "github.com/stretchr/testify/mock" ) -var _ Client = (*fakeClient)(nil) +var _ client = (*fakeClient)(nil) type fakeClient struct { mock.Mock diff --git a/receiver/mysqlreceiver/scraper.go b/receiver/mysqlreceiver/scraper.go index c95fb626a410..882930837a81 100644 --- a/receiver/mysqlreceiver/scraper.go +++ b/receiver/mysqlreceiver/scraper.go @@ -29,7 +29,7 @@ import ( ) type mySQLScraper struct { - client Client + client client stopOnce sync.Once logger *zap.Logger From 5f800656d61c2ec77fb7ee698e65c4ffe209699b Mon Sep 17 00:00:00 2001 From: Mrod1598 Date: Tue, 9 Nov 2021 16:43:05 -0500 Subject: [PATCH 5/7] fix lint --- receiver/mysqlreceiver/scraper.go | 19 +++++++++---------- receiver/mysqlreceiver/scraper_test.go | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/receiver/mysqlreceiver/scraper.go b/receiver/mysqlreceiver/scraper.go index 882930837a81..a5bbeb54d61c 100644 --- a/receiver/mysqlreceiver/scraper.go +++ b/receiver/mysqlreceiver/scraper.go @@ -29,8 +29,8 @@ import ( ) type mySQLScraper struct { - client client - stopOnce sync.Once + sqlclient client + stopOnce sync.Once logger *zap.Logger config *Config @@ -48,13 +48,13 @@ func newMySQLScraper( // start starts the scraper by initializing the db client connection. func (m *mySQLScraper) start(_ context.Context, host component.Host) error { - client := newMySQLClient(m.config) + sqlclient := newMySQLClient(m.config) - err := client.Connect() + err := sqlclient.Connect() if err != nil { return err } - m.client = client + m.sqlclient = sqlclient return nil } @@ -63,7 +63,7 @@ func (m *mySQLScraper) start(_ context.Context, host component.Host) error { func (m *mySQLScraper) shutdown(context.Context) error { var err error m.stopOnce.Do(func() { - err = m.client.Close() + err = m.sqlclient.Close() }) return err } @@ -97,8 +97,7 @@ func addToIntMetric(metric pdata.NumberDataPointSlice, labels pdata.AttributeMap // scrape scrapes the mysql db metric stats, transforms them and labels them into a metric slices. func (m *mySQLScraper) scrape(context.Context) (pdata.Metrics, error) { - - if m.client == nil { + if m.sqlclient == nil { return pdata.Metrics{}, errors.New("failed to connect to http client") } @@ -124,7 +123,7 @@ func (m *mySQLScraper) scrape(context.Context) (pdata.Metrics, error) { threads := initMetric(ilm.Metrics(), metadata.M.MysqlThreads).Sum().DataPoints() // collect innodb metrics. - innodbStats, err := m.client.getInnodbStats() + innodbStats, err := m.sqlclient.getInnodbStats() if err != nil { m.logger.Error("Failed to fetch InnoDB stats", zap.Error(err)) } @@ -141,7 +140,7 @@ func (m *mySQLScraper) scrape(context.Context) (pdata.Metrics, error) { } // collect global status metrics. - globalStats, err := m.client.getGlobalStats() + globalStats, err := m.sqlclient.getGlobalStats() if err != nil { m.logger.Error("Failed to fetch global stats", zap.Error(err)) return pdata.Metrics{}, err diff --git a/receiver/mysqlreceiver/scraper_test.go b/receiver/mysqlreceiver/scraper_test.go index 0403e3d5a14f..bef323505b3e 100644 --- a/receiver/mysqlreceiver/scraper_test.go +++ b/receiver/mysqlreceiver/scraper_test.go @@ -35,7 +35,7 @@ func TestScrape(t *testing.T) { Endpoint: "localhost:3306", }, }) - sc.client = &mysqlMock + sc.sqlclient = &mysqlMock scrapedRMS, err := sc.scrape(context.Background()) require.NoError(t, err) From 3b926debdf81c395b88b54a42b9fd4cc4c6ffb42 Mon Sep 17 00:00:00 2001 From: Mrod1598 Date: Wed, 10 Nov 2021 14:19:12 -0500 Subject: [PATCH 6/7] Tidy Go mod --- receiver/mysqlreceiver/client_mock_test.go | 6 +----- receiver/mysqlreceiver/go.mod | 2 -- receiver/mysqlreceiver/go.sum | 3 --- receiver/mysqlreceiver/scraper_test.go | 2 +- 4 files changed, 2 insertions(+), 11 deletions(-) diff --git a/receiver/mysqlreceiver/client_mock_test.go b/receiver/mysqlreceiver/client_mock_test.go index 5a4fe2dedfe3..6424afb614d4 100644 --- a/receiver/mysqlreceiver/client_mock_test.go +++ b/receiver/mysqlreceiver/client_mock_test.go @@ -19,15 +19,11 @@ import ( "os" "path" "strings" - - "github.com/stretchr/testify/mock" ) var _ client = (*fakeClient)(nil) -type fakeClient struct { - mock.Mock -} +type fakeClient struct{} func readFile(fname string) (map[string]string, error) { var stats = map[string]string{} diff --git a/receiver/mysqlreceiver/go.mod b/receiver/mysqlreceiver/go.mod index 90bbcd8634c9..6f9eeb708404 100644 --- a/receiver/mysqlreceiver/go.mod +++ b/receiver/mysqlreceiver/go.mod @@ -13,7 +13,6 @@ require ( ) require ( - github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -26,7 +25,6 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/rogpeppe/go-internal v1.6.1 // indirect github.com/spf13/cast v1.4.1 // indirect - github.com/stretchr/objx v0.1.0 // indirect go.opencensus.io v0.23.0 // indirect go.opentelemetry.io/otel v1.1.0 // indirect go.opentelemetry.io/otel/metric v0.24.0 // indirect diff --git a/receiver/mysqlreceiver/go.sum b/receiver/mysqlreceiver/go.sum index 63d74993dcfd..85602c08883b 100644 --- a/receiver/mysqlreceiver/go.sum +++ b/receiver/mysqlreceiver/go.sum @@ -40,8 +40,6 @@ contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -352,7 +350,6 @@ github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0 github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/receiver/mysqlreceiver/scraper_test.go b/receiver/mysqlreceiver/scraper_test.go index bef323505b3e..ef95ff3c034e 100644 --- a/receiver/mysqlreceiver/scraper_test.go +++ b/receiver/mysqlreceiver/scraper_test.go @@ -47,5 +47,5 @@ func TestScrape(t *testing.T) { eMetricSlice := expectedMetrics.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() aMetricSlice := scrapedRMS.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics() - require.NoError(t, scrapertest.CompareMetricSlices(eMetricSlice, aMetricSlice)) + require.NoError(t, scrapertest.CompareMetricSlices(eMetricSlice, aMetricSlice, true)) } From 444d3a05e261a6c85c9067a32de2cc977abfc3cf Mon Sep 17 00:00:00 2001 From: Mrod1598 Date: Wed, 10 Nov 2021 14:32:20 -0500 Subject: [PATCH 7/7] Update Scrapertest --- receiver/mysqlreceiver/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/receiver/mysqlreceiver/go.mod b/receiver/mysqlreceiver/go.mod index 5c0f47525507..ac85cd8e716c 100644 --- a/receiver/mysqlreceiver/go.mod +++ b/receiver/mysqlreceiver/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/go-sql-driver/mysql v1.6.0 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/scrapertest v0.0.0-00010101000000-000000000000 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/scrapertest v0.0.0-20211110181051-0d46baeab9e9 github.com/stretchr/testify v1.7.0 go.opentelemetry.io/collector v0.38.1-0.20211103215828-cffbecb2ac9e go.opentelemetry.io/collector/model v0.38.1-0.20211103215828-cffbecb2ac9e