From a9296161932f82a7f84b1c17d17dc459ce4b9703 Mon Sep 17 00:00:00 2001 From: David Poncelow Date: Wed, 22 Sep 2021 13:55:57 -0700 Subject: [PATCH 1/6] client wrapper for MongoDB Atlas support Adds pagination, error handling, will be extended to manage metric transformation. --- go.sum | 14 + .../internal/mongodb_atlas_client.go | 374 ++++++++++++++++++ receiver/mongodbatlasreceiver/receiver.go | 88 ++++- 3 files changed, 474 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index 0ee97d53cf0f..bcf9898fc559 100644 --- a/go.sum +++ b/go.sum @@ -1677,6 +1677,7 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.28.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.31.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.31.1 h1:d18hG4PkHnNAKNMOmFuXFaiY8Us0nird/2m60uS1AMs= github.com/prometheus/common v0.31.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/exporter-toolkit v0.5.1/go.mod h1:OCkM4805mmisBhLmVFw858QYi3v0wKdY6/UxrT0pZVg= @@ -1765,6 +1766,9 @@ github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAx github.com/shirou/gopsutil v2.18.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.20.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/gopsutil v3.21.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/gopsutil v3.21.6+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/shirou/gopsutil v3.21.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.9+incompatible h1:LTLpUnfX81MkHeCtSrwNKZwuW5Id6kCa7/P43NdcNn4= github.com/shirou/gopsutil v3.21.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.21.1/go.mod h1:igHnfak0qnw1biGeI2qKQvu0ZkwvEkUcCLlYhZzdr/4= @@ -2049,6 +2053,11 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.22.6/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/collector v0.28.0/go.mod h1:AP/BTXwo1eedoJO7V+HQ68CSvJU1lcdqOzJCgt1VsNs= +go.opentelemetry.io/collector v0.31.0/go.mod h1:A9vKmEa2MI/vJXNUoRinq9w25ZMmxWJLYXYELHkBEw0= +go.opentelemetry.io/collector v0.36.1-0.20210930151317-3ec4f1be6001/go.mod h1:JsoDzlne/ihaLP5xdpcVNErpns1cZwzGF/hf2Kr+hK8= +go.opentelemetry.io/collector v0.36.1-0.20211004155959-190f8fbb2b9a h1:FOP2IABtkcVUPy10rlKgLGgisKABrkB4RVEhYA2iTxU= +go.opentelemetry.io/collector v0.36.1-0.20211004155959-190f8fbb2b9a/go.mod h1:z3NLthT38PDZvMqsBlxXtE5WQvcnSwwV8IRXBdcgpwk= go.opentelemetry.io/collector v0.35.0/go.mod h1:mMW4VJHhy8CwoTenV75axteKd0aZhWHDZjcZ59V53kc= go.opentelemetry.io/collector v0.37.1-0.20211015233822-bd87fb628058 h1:6v0ba4ruY/W2cJLElDZEHDwShlSWUjK2MiBMvwfAIN0= go.opentelemetry.io/collector v0.37.1-0.20211015233822-bd87fb628058/go.mod h1:zbLWBJVy7bmiZHlHjCrV28vxXA/sAkCLtH5thD8ZahA= @@ -2081,6 +2090,7 @@ go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnf go.opentelemetry.io/otel v1.0.1 h1:4XKyXmfqJLOQ7feyV5DB6gsBFZ0ltB8vLtp6pj4JIcc= go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU= go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= +go.opentelemetry.io/otel/exporters/prometheus v0.23.0/go.mod h1:kjCXbxQnnEm5l3HrUw4IPyuALu7Uqb/bEK7vWQnbd8s= go.opentelemetry.io/otel/exporters/prometheus v0.24.0 h1:lfVirQkD4jPMh7m6i9sHDHweYZyWA0NDU6NszkbtFSE= go.opentelemetry.io/otel/exporters/prometheus v0.24.0/go.mod h1:jfc9W1hVK0w9zrsE+C2ELje/M+K67cGinzeg8qQ8oog= go.opentelemetry.io/otel/internal/metric v0.22.0/go.mod h1:7qVuMihW/ktMonEfOvBXuh6tfMvvEyoIDgeJNRloYbQ= @@ -2098,12 +2108,16 @@ go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1 go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc= go.opentelemetry.io/otel/sdk v1.0.0-RC2/go.mod h1:fgwHyiDn4e5k40TD9VX243rOxXR+jzsWBZYA2P5jpEw= go.opentelemetry.io/otel/sdk v1.0.0-RC3/go.mod h1:78H6hyg2fka0NYT9fqGuFLvly2yCxiBXDJAgLKo/2Us= +go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM= +go.opentelemetry.io/otel/sdk v1.0.0-RC3/go.mod h1:78H6hyg2fka0NYT9fqGuFLvly2yCxiBXDJAgLKo/2Us= go.opentelemetry.io/otel/sdk v1.0.1 h1:wXxFEWGo7XfXupPwVJvTBOaPBC9FEg0wB8hMNrKk+cA= go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI= go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE= +go.opentelemetry.io/otel/sdk/export/metric v0.23.0/go.mod h1:SuMiREmKVRIwFKq73zvGTvwFpxb/ZAYkMfyqMoOtDqs= go.opentelemetry.io/otel/sdk/export/metric v0.24.0 h1:innKi8LQebwPI+WEuEKEWMjhWC5mXQG1/WpSm5mffSY= go.opentelemetry.io/otel/sdk/export/metric v0.24.0/go.mod h1:chmxXGVNcpCih5XyniVkL4VUyaEroUbOdvjVlQ8M29Y= go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= +go.opentelemetry.io/otel/sdk/metric v0.23.0/go.mod h1:wa0sKK13eeIFW+0OFjcC3S1i7FTRRiLAXe1kjBVbhwg= go.opentelemetry.io/otel/sdk/metric v0.24.0 h1:LLHrZikGdEHoHihwIPvfFRJX+T+NdrU2zgEqf7tQ7Oo= go.opentelemetry.io/otel/sdk/metric v0.24.0/go.mod h1:KDgJgYzsIowuIDbPM9sLDZY9JJ6gqIDWCx92iWV8ejk= go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= diff --git a/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go b/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go index 38c850c4f5c9..1d266d0d0310 100644 --- a/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go +++ b/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go @@ -20,6 +20,7 @@ import ( "github.com/mongodb-forks/digest" "go.mongodb.org/atlas/mongodbatlas" + "go.opentelemetry.io/collector/model/pdata" "go.uber.org/zap" ) @@ -30,6 +31,7 @@ type MongoDBAtlasClient struct { client *mongodbatlas.Client } +// NewMongoDBAtlasClient creates a new MongoDB Atlas client wrapper func NewMongoDBAtlasClient( publicKey string, privateKey string, @@ -103,3 +105,375 @@ func (s *MongoDBAtlasClient) getOrganizationsPage( } return orgs.Results, hasNext(orgs.Links), nil } + +// Projects returns a list of projects accessible within the provided organization +func (s *MongoDBAtlasClient) Projects( + ctx context.Context, + orgID string, +) []*mongodbatlas.Project { + allProjects := make([]*mongodbatlas.Project, 0) + page := 1 + + for { + projects, hasNext, err := s.getProjectsPage(ctx, orgID, page) + page++ + if err != nil { + s.log.Debug("Error retrieving list of projects from MongoDB Atlas API", zap.Error(err)) + break + } + allProjects = append(allProjects, projects...) + if !hasNext { + break + } + } + return allProjects +} + +func (s *MongoDBAtlasClient) getProjectsPage( + ctx context.Context, + orgID string, + pageNum int, +) ([]*mongodbatlas.Project, bool, error) { + projects, response, err := s.client.Organizations.Projects( + ctx, + orgID, + &mongodbatlas.ListOptions{PageNum: pageNum}, + ) + err = checkMongoDBClientErr(err, response) + if err != nil { + return nil, false, errors.Wrap(err, "Error retrieving project page") + } + return projects.Results, hasNext(projects.Links), nil +} + +// Processes returns the list of processes running for a given project. +func (s *MongoDBAtlasClient) Processes( + ctx context.Context, + projectID string, +) []*mongodbatlas.Process { + // A paginated API, but the MongoDB client just returns the values from the first page + + // Note: MongoDB Atlas also has the idea of a Cluster- we can retrieve a list of clusters from + // the Project, but a Cluster does not have a link to its Process list and a Process does not + // have a link to its Cluster (save through the hostname, which is not a documented relationship). + processes, response, err := s.client.Processes.List( + ctx, + projectID, + &mongodbatlas.ProcessesListOptions{ + ListOptions: mongodbatlas.ListOptions{ + PageNum: 0, + ItemsPerPage: 0, + IncludeCount: true, + }, + }, + ) + err = checkMongoDBClientErr(err, response) + if err != nil { + s.log.Debug("Error retrieving processes from MongoDB Atlas API", zap.Error(err)) + return make([]*mongodbatlas.Process, 0) + } + return processes +} + +func (s *MongoDBAtlasClient) getProcessDatabasesPage( + ctx context.Context, + projectID string, + host string, + port int, + pageNum int, +) ([]*mongodbatlas.ProcessDatabase, bool, error) { + databases, response, err := s.client.ProcessDatabases.List( + ctx, + projectID, + host, + port, + &mongodbatlas.ListOptions{PageNum: pageNum}, + ) + err = checkMongoDBClientErr(err, response) + if err != nil { + return nil, false, err + } + return databases.Results, hasNext(databases.Links), nil +} + +// ProcessDatabases lists databases that are running in a given MongoDB Atlas process +func (s *MongoDBAtlasClient) ProcessDatabases( + ctx context.Context, + projectID string, + host string, + port int, +) []*mongodbatlas.ProcessDatabase { + allProcessDatabases := make([]*mongodbatlas.ProcessDatabase, 0) + pageNum := 1 + for { + processes, hasMore, err := s.getProcessDatabasesPage(ctx, projectID, host, port, pageNum) + pageNum++ + if err != nil { + s.log.Debug("Error while retrieving databases from MongoDB Atlas API", zap.Error(err)) + break // Return the results we already have + } + allProcessDatabases = append(allProcessDatabases, processes...) + if !hasMore { + break + } + } + return allProcessDatabases +} + +// ProcessMetrics returns a set of metrics associated with the specified running process. +func (s *MongoDBAtlasClient) ProcessMetrics( + ctx context.Context, + resource pdata.Resource, + projectID string, + host string, + port int, + start string, + end string, + resolution string, +) (pdata.Metrics, []error) { + allMeasurements := make([]*mongodbatlas.Measurements, 0) + pageNum := 1 + for { + measurements, hasMore, err := s.getProcessMeasurementsPage( + ctx, + projectID, + host, + port, + pageNum, + start, + end, + resolution, + ) + if err != nil { + s.log.Debug("Error retrieving process metrics from MongoDB Atlas API", zap.Error(err)) + break // Return partial results + } + pageNum++ + allMeasurements = append(allMeasurements, measurements...) + if !hasMore { + break + } + } + return processMeasurements(resource, allMeasurements) +} + +func (s *MongoDBAtlasClient) getProcessMeasurementsPage( + ctx context.Context, + projectID string, + host string, + port int, + pageNum int, + start string, + end string, + resolution string, +) ([]*mongodbatlas.Measurements, bool, error) { + measurements, result, err := s.client.ProcessMeasurements.List( + ctx, + projectID, + host, + port, + &mongodbatlas.ProcessMeasurementListOptions{ + ListOptions: &mongodbatlas.ListOptions{PageNum: pageNum}, + Granularity: resolution, + Start: start, + End: end, + }, + ) + err = checkMongoDBClientErr(err, result) + if err != nil { + return nil, false, err + } + return measurements.Measurements, hasNext(measurements.Links), nil +} + +// ProcessDatabaseMetrics returns metrics about a particular database running within a MongoDB Atlas process +func (s *MongoDBAtlasClient) ProcessDatabaseMetrics( + ctx context.Context, + resource pdata.Resource, + projectID string, + host string, + port int, + dbname string, + start string, + end string, + resolution string, +) (pdata.Metrics, []error) { + allMeasurements := make([]*mongodbatlas.Measurements, 0) + pageNum := 1 + for { + measurements, hasMore, err := s.getProcessDatabaseMeasurementsPage( + ctx, + projectID, + host, + port, + dbname, + pageNum, + start, + end, + resolution, + ) + if err != nil { + s.log.Debug("Error retrieving database metrics from MongoDB Atlas API", zap.Error(err)) + break // Return partial results + } + pageNum++ + allMeasurements = append(allMeasurements, measurements...) + if !hasMore { + break + } + } + return processMeasurements(resource, allMeasurements) +} + +func (s *MongoDBAtlasClient) getProcessDatabaseMeasurementsPage( + ctx context.Context, + projectID string, + host string, + port int, + dbname string, + pageNum int, + start string, + end string, + resolution string, +) ([]*mongodbatlas.Measurements, bool, error) { + measurements, result, err := s.client.ProcessDatabaseMeasurements.List( + ctx, + projectID, + host, + port, + dbname, + &mongodbatlas.ProcessMeasurementListOptions{ + ListOptions: &mongodbatlas.ListOptions{PageNum: pageNum}, + Granularity: resolution, + Start: start, + End: end, + }, + ) + err = checkMongoDBClientErr(err, result) + if err != nil { + return nil, false, err + } + return measurements.Measurements, hasNext(measurements.Links), nil +} + +// ProcessDisks enumerates the disks accessible to a specified MongoDB Atlas process +func (s *MongoDBAtlasClient) ProcessDisks( + ctx context.Context, + projectID string, + host string, + port int, +) []*mongodbatlas.ProcessDisk { + allDisks := make([]*mongodbatlas.ProcessDisk, 0) + pageNum := 1 + for { + disks, hasMore, err := s.getProcessDisksPage(ctx, projectID, host, port, pageNum) + if err != nil { + s.log.Debug("Error retrieving disk metrics from MongoDB Atlas API", zap.Error(err)) + break // Return partial results + } + pageNum++ + allDisks = append(allDisks, disks...) + if !hasMore { + break + } + } + return allDisks +} + +func (s *MongoDBAtlasClient) getProcessDisksPage( + ctx context.Context, + projectID string, + host string, + port int, + pageNum int, +) ([]*mongodbatlas.ProcessDisk, bool, error) { + disks, result, err := s.client.ProcessDisks.List( + ctx, + projectID, + host, + port, + &mongodbatlas.ListOptions{PageNum: pageNum}, + ) + err = checkMongoDBClientErr(err, result) + if err != nil { + return nil, false, err + } + return disks.Results, hasNext(disks.Links), nil +} + +// ProcessDiskMetrics returns metrics supplied for a particular disk partition used by a MongoDB Atlas process +func (s *MongoDBAtlasClient) ProcessDiskMetrics( + ctx context.Context, + resource pdata.Resource, + projectID string, + host string, + port int, + partitionName string, + start string, + end string, + resolution string, +) (pdata.Metrics, []error) { + allMeasurements := make([]*mongodbatlas.Measurements, 0) + pageNum := 1 + for { + measurements, hasMore, err := s.processDiskMeasurementsPage( + ctx, + projectID, + host, + port, + partitionName, + pageNum, + start, + end, + resolution, + ) + if err != nil { + s.log.Debug("Error retrieving process disk metrics from MongoDB Atlas API", zap.Error(err)) + break // Return partial results + } + pageNum++ + allMeasurements = append(allMeasurements, measurements...) + if !hasMore { + break + } + } + return processMeasurements(resource, allMeasurements) +} + +func (s *MongoDBAtlasClient) processDiskMeasurementsPage( + ctx context.Context, + projectID string, + host string, + port int, + partitionName string, + pageNum int, + start string, + end string, + resolution string, +) ([]*mongodbatlas.Measurements, bool, error) { + measurements, result, err := s.client.ProcessDiskMeasurements.List( + ctx, + projectID, + host, + port, + partitionName, + &mongodbatlas.ProcessMeasurementListOptions{ + ListOptions: &mongodbatlas.ListOptions{PageNum: pageNum}, + Granularity: resolution, + Start: start, + End: end, + }, + ) + err = checkMongoDBClientErr(err, result) + if err != nil { + return nil, false, err + } + return measurements.Measurements, hasNext(measurements.Links), nil +} + +func processMeasurements(_ pdata.Resource, measurements []*mongodbatlas.Measurements) (pdata.Metrics, []error) { + // Stub- will be replaced with code for normalizing and processing metrics + fmt.Printf("Fake processing %d metrics\n", len(measurements)) + errs := make([]error, 0) + return pdata.NewMetrics(), errs +} diff --git a/receiver/mongodbatlasreceiver/receiver.go b/receiver/mongodbatlasreceiver/receiver.go index 977db8beb92f..970fec172592 100644 --- a/receiver/mongodbatlasreceiver/receiver.go +++ b/receiver/mongodbatlasreceiver/receiver.go @@ -56,7 +56,91 @@ func (s *receiver) scrape(ctx context.Context) (pdata.Metrics, error) { func (s *receiver) poll(ctx context.Context, start string, end string, resolution string) { //nolint for _, org := range s.client.Organizations(ctx) { - // Metrics collection starts here - s.log.Debug("fetch resources for MongoDB Organization", zap.String("org", org.Name)) + resourceAttributes.InsertString("org_name", org.Name) + for _, project := range s.client.Projects(ctx, org.ID) { + resourceAttributes.InsertString("project_name", project.Name) + for _, process := range s.client.Processes(ctx, project.ID) { + resource := pdata.NewResource() + resourceAttributes.CopyTo(resource.Attributes()) + resource.Attributes().InsertString("hostname", process.Hostname) + resource.Attributes().InsertString("port", strconv.Itoa(process.Port)) + if s.metricSink != nil { + metrics, errs := + s.client.ProcessMetrics( + ctx, + resource, + project.ID, + process.Hostname, + process.Port, + start, + end, + resolution, + ) + for _, err := range errs { + s.log.Debug( + "Encountered error when polling from MongoDB Atlas", + zap.Error(err), + ) + } + s.metricSink.ConsumeMetrics(ctx, metrics) + + for _, db := range s.client.ProcessDatabases(ctx, project.ID, process.Hostname, process.Port) { + dbResource := pdata.NewResource() + resource.CopyTo(dbResource) + resource.Attributes().InsertString("database_name", db.DatabaseName) + metrics, errs := s.client.ProcessDatabaseMetrics( + ctx, + resource, + project.ID, + process.Hostname, + process.Port, + db.DatabaseName, + start, + end, + resolution, + ) + for _, err := range errs { + s.log.Debug( + "Encountered error when polling from MongoDB Atlas", + zap.Error(err), + ) + } + s.metricSink.ConsumeMetrics( + ctx, + metrics, + ) + } + for _, disk := range s.client.ProcessDisks(ctx, project.ID, process.Hostname, process.Port) { + diskResource := pdata.NewResource() + resource.CopyTo(diskResource) + diskResource.Attributes().InsertString("partition_name", disk.PartitionName) + metrics, errs := s.client.ProcessDiskMetrics( + ctx, + diskResource, + project.ID, + process.Hostname, + process.Port, + disk.PartitionName, + start, + end, + resolution, + ) + for _, err := range errs { + s.log.Debug( + "Encountered error when polling from MongoDB Atlas", + zap.Error(err), + ) + } + s.metricSink.ConsumeMetrics( + ctx, + metrics, + ) + } + } else { + s.log.Debug("Metrics not enabled") + } + } + } + // } } } From 475d6d9a7c88e75bce9ff54034b419aac8421f9a Mon Sep 17 00:00:00 2001 From: David Poncelow Date: Fri, 1 Oct 2021 15:50:43 -0700 Subject: [PATCH 2/6] address review comments MongoDB Atlas wrapper returns errors rather than logging change resource attributes to use conventions modify error handling --- .../internal/mongodb_atlas_client.go | 41 ++++++++--------- receiver/mongodbatlasreceiver/receiver.go | 44 +++++++++++++------ 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go b/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go index 1d266d0d0310..a0c52772ab78 100644 --- a/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go +++ b/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go @@ -19,6 +19,7 @@ import ( "fmt" "github.com/mongodb-forks/digest" + "github.com/pkg/errors" "go.mongodb.org/atlas/mongodbatlas" "go.opentelemetry.io/collector/model/pdata" "go.uber.org/zap" @@ -70,7 +71,7 @@ func hasNext(links []*mongodbatlas.Link) bool { } // Organizations returns a list of all organizations available with the supplied credentials -func (s *MongoDBAtlasClient) Organizations(ctx context.Context) []*mongodbatlas.Organization { +func (s *MongoDBAtlasClient) Organizations(ctx context.Context) ([]*mongodbatlas.Organization, error) { allOrgs := make([]*mongodbatlas.Organization, 0) page := 1 @@ -79,15 +80,15 @@ func (s *MongoDBAtlasClient) Organizations(ctx context.Context) []*mongodbatlas. page++ if err != nil { // TODO: Add error to a metric - s.log.Debug("Error retrieving organizations from MongoDB Atlas API", zap.Error(err)) - break // Stop, returning what we have (probably empty slice) + // Stop, returning what we have (probably empty slice) + return allOrgs, errors.Wrap(err, "Error retrieving organizations from MongoDB Atlas API") } allOrgs = append(allOrgs, orgs...) if !hasNext { break } } - return allOrgs + return allOrgs, nil } func (s *MongoDBAtlasClient) getOrganizationsPage( @@ -110,7 +111,7 @@ func (s *MongoDBAtlasClient) getOrganizationsPage( func (s *MongoDBAtlasClient) Projects( ctx context.Context, orgID string, -) []*mongodbatlas.Project { +) ([]*mongodbatlas.Project, error) { allProjects := make([]*mongodbatlas.Project, 0) page := 1 @@ -118,15 +119,14 @@ func (s *MongoDBAtlasClient) Projects( projects, hasNext, err := s.getProjectsPage(ctx, orgID, page) page++ if err != nil { - s.log.Debug("Error retrieving list of projects from MongoDB Atlas API", zap.Error(err)) - break + return allProjects, errors.Wrap(err, "Error retrieving list of projects from MongoDB Atlas API") } allProjects = append(allProjects, projects...) if !hasNext { break } } - return allProjects + return allProjects, nil } func (s *MongoDBAtlasClient) getProjectsPage( @@ -150,7 +150,7 @@ func (s *MongoDBAtlasClient) getProjectsPage( func (s *MongoDBAtlasClient) Processes( ctx context.Context, projectID string, -) []*mongodbatlas.Process { +) ([]*mongodbatlas.Process, error) { // A paginated API, but the MongoDB client just returns the values from the first page // Note: MongoDB Atlas also has the idea of a Cluster- we can retrieve a list of clusters from @@ -169,10 +169,9 @@ func (s *MongoDBAtlasClient) Processes( ) err = checkMongoDBClientErr(err, response) if err != nil { - s.log.Debug("Error retrieving processes from MongoDB Atlas API", zap.Error(err)) - return make([]*mongodbatlas.Process, 0) + return make([]*mongodbatlas.Process, 0), errors.Wrap(err, "Error retrieving processes from MongoDB Atlas API") } - return processes + return processes, nil } func (s *MongoDBAtlasClient) getProcessDatabasesPage( @@ -202,22 +201,21 @@ func (s *MongoDBAtlasClient) ProcessDatabases( projectID string, host string, port int, -) []*mongodbatlas.ProcessDatabase { +) ([]*mongodbatlas.ProcessDatabase, error) { allProcessDatabases := make([]*mongodbatlas.ProcessDatabase, 0) pageNum := 1 for { processes, hasMore, err := s.getProcessDatabasesPage(ctx, projectID, host, port, pageNum) pageNum++ if err != nil { - s.log.Debug("Error while retrieving databases from MongoDB Atlas API", zap.Error(err)) - break // Return the results we already have + return allProcessDatabases, err } allProcessDatabases = append(allProcessDatabases, processes...) if !hasMore { break } } - return allProcessDatabases + return allProcessDatabases, nil } // ProcessMetrics returns a set of metrics associated with the specified running process. @@ -230,7 +228,7 @@ func (s *MongoDBAtlasClient) ProcessMetrics( start string, end string, resolution string, -) (pdata.Metrics, []error) { +) (pdata.Metrics, error) { allMeasurements := make([]*mongodbatlas.Measurements, 0) pageNum := 1 for { @@ -297,7 +295,7 @@ func (s *MongoDBAtlasClient) ProcessDatabaseMetrics( start string, end string, resolution string, -) (pdata.Metrics, []error) { +) (pdata.Metrics, error) { allMeasurements := make([]*mongodbatlas.Measurements, 0) pageNum := 1 for { @@ -412,7 +410,7 @@ func (s *MongoDBAtlasClient) ProcessDiskMetrics( start string, end string, resolution string, -) (pdata.Metrics, []error) { +) (pdata.Metrics, error) { allMeasurements := make([]*mongodbatlas.Measurements, 0) pageNum := 1 for { @@ -471,9 +469,8 @@ func (s *MongoDBAtlasClient) processDiskMeasurementsPage( return measurements.Measurements, hasNext(measurements.Links), nil } -func processMeasurements(_ pdata.Resource, measurements []*mongodbatlas.Measurements) (pdata.Metrics, []error) { +func processMeasurements(_ pdata.Resource, measurements []*mongodbatlas.Measurements) (pdata.Metrics, error) { // Stub- will be replaced with code for normalizing and processing metrics fmt.Printf("Fake processing %d metrics\n", len(measurements)) - errs := make([]error, 0) - return pdata.NewMetrics(), errs + return pdata.NewMetrics(), nil } diff --git a/receiver/mongodbatlasreceiver/receiver.go b/receiver/mongodbatlasreceiver/receiver.go index 970fec172592..10332b3089c2 100644 --- a/receiver/mongodbatlasreceiver/receiver.go +++ b/receiver/mongodbatlasreceiver/receiver.go @@ -62,10 +62,13 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio for _, process := range s.client.Processes(ctx, project.ID) { resource := pdata.NewResource() resourceAttributes.CopyTo(resource.Attributes()) - resource.Attributes().InsertString("hostname", process.Hostname) - resource.Attributes().InsertString("port", strconv.Itoa(process.Port)) + resource.Attributes().InsertString("host.name", process.Hostname) + resource.Attributes().InsertString("process.port", strconv.Itoa(process.Port)) + // This receiver will support both logs and metrics- if one pipeline + // or the other is not configured, it will be nil. + pdata.NewMetrics() if s.metricSink != nil { - metrics, errs := + metrics, err := s.client.ProcessMetrics( ctx, resource, @@ -76,19 +79,31 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio end, resolution, ) - for _, err := range errs { + if err != nil { s.log.Debug( "Encountered error when polling from MongoDB Atlas", zap.Error(err), ) + return } s.metricSink.ConsumeMetrics(ctx, metrics) - for _, db := range s.client.ProcessDatabases(ctx, project.ID, process.Hostname, process.Port) { + processDatabases, err := s.client.ProcessDatabases( + ctx, + project.ID, + process.Hostname, + process.Port, + ) + if err != nil { + s.log.Debug("Error retrieving process databases", zap.Error(err)) + } + + for _, db := range processDatabases { dbResource := pdata.NewResource() resource.CopyTo(dbResource) - resource.Attributes().InsertString("database_name", db.DatabaseName) - metrics, errs := s.client.ProcessDatabaseMetrics( + resource.Attributes(). + InsertString("mongodb.atlas.database_name", db.DatabaseName) + metrics, err := s.client.ProcessDatabaseMetrics( ctx, resource, project.ID, @@ -99,11 +114,12 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio end, resolution, ) - for _, err := range errs { + if err != nil { s.log.Debug( "Encountered error when polling from MongoDB Atlas", zap.Error(err), ) + return } s.metricSink.ConsumeMetrics( ctx, @@ -113,8 +129,9 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio for _, disk := range s.client.ProcessDisks(ctx, project.ID, process.Hostname, process.Port) { diskResource := pdata.NewResource() resource.CopyTo(diskResource) - diskResource.Attributes().InsertString("partition_name", disk.PartitionName) - metrics, errs := s.client.ProcessDiskMetrics( + diskResource.Attributes(). + InsertString("mongodb.atlas.partition", disk.PartitionName) + metrics, err := s.client.ProcessDiskMetrics( ctx, diskResource, project.ID, @@ -125,11 +142,11 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio end, resolution, ) - for _, err := range errs { + if err != nil { s.log.Debug( "Encountered error when polling from MongoDB Atlas", - zap.Error(err), - ) + zap.Error(err)) + return } s.metricSink.ConsumeMetrics( ctx, @@ -141,6 +158,5 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio } } } - // } } } From c7a51c6d340eaf62072be35451136bd0aa71ecce Mon Sep 17 00:00:00 2001 From: David Poncelow Date: Mon, 4 Oct 2021 16:03:58 -0700 Subject: [PATCH 3/6] fix capitalization on error messages --- .../mongodbatlasreceiver/internal/mongodb_atlas_client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go b/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go index a0c52772ab78..ecea71c3ba3f 100644 --- a/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go +++ b/receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go @@ -81,7 +81,7 @@ func (s *MongoDBAtlasClient) Organizations(ctx context.Context) ([]*mongodbatlas if err != nil { // TODO: Add error to a metric // Stop, returning what we have (probably empty slice) - return allOrgs, errors.Wrap(err, "Error retrieving organizations from MongoDB Atlas API") + return allOrgs, errors.Wrap(err, "error retrieving organizations from MongoDB Atlas API") } allOrgs = append(allOrgs, orgs...) if !hasNext { @@ -119,7 +119,7 @@ func (s *MongoDBAtlasClient) Projects( projects, hasNext, err := s.getProjectsPage(ctx, orgID, page) page++ if err != nil { - return allProjects, errors.Wrap(err, "Error retrieving list of projects from MongoDB Atlas API") + return allProjects, errors.Wrap(err, "error retrieving list of projects from MongoDB Atlas API") } allProjects = append(allProjects, projects...) if !hasNext { @@ -141,7 +141,7 @@ func (s *MongoDBAtlasClient) getProjectsPage( ) err = checkMongoDBClientErr(err, response) if err != nil { - return nil, false, errors.Wrap(err, "Error retrieving project page") + return nil, false, errors.Wrap(err, "error retrieving project page") } return projects.Results, hasNext(projects.Links), nil } @@ -169,7 +169,7 @@ func (s *MongoDBAtlasClient) Processes( ) err = checkMongoDBClientErr(err, response) if err != nil { - return make([]*mongodbatlas.Process, 0), errors.Wrap(err, "Error retrieving processes from MongoDB Atlas API") + return make([]*mongodbatlas.Process, 0), errors.Wrap(err, "error retrieving processes from MongoDB Atlas API") } return processes, nil } From d30807335b648400facf0b9f8a3fdb0507918064 Mon Sep 17 00:00:00 2001 From: David Poncelow Date: Mon, 4 Oct 2021 19:22:30 -0700 Subject: [PATCH 4/6] go mod tidy --- receiver/mongodbatlasreceiver/go.mod | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/receiver/mongodbatlasreceiver/go.mod b/receiver/mongodbatlasreceiver/go.mod index 3068dfd406c9..4c79712e1cd6 100644 --- a/receiver/mongodbatlasreceiver/go.mod +++ b/receiver/mongodbatlasreceiver/go.mod @@ -4,6 +4,11 @@ go 1.17 require ( github.com/mongodb-forks/digest v1.0.3 + github.com/open-telemetry/opentelemetry-collector-contrib/internal/interval v0.36.0 + github.com/pkg/errors v0.9.1 + go.mongodb.org/atlas v0.12.0 + go.opentelemetry.io/collector v0.36.1-0.20211004155959-190f8fbb2b9a + go.opentelemetry.io/collector/model v0.36.1-0.20211004155959-190f8fbb2b9a go.mongodb.org/atlas v0.13.0 go.opentelemetry.io/collector v0.37.1-0.20211015233822-bd87fb628058 go.opentelemetry.io/collector/model v0.37.1-0.20211015233822-bd87fb628058 @@ -21,7 +26,6 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/openlyinc/pointy v1.1.2 // indirect github.com/pelletier/go-toml v1.9.3 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/rogpeppe/go-internal v1.6.1 // indirect github.com/spf13/cast v1.4.1 // indirect go.opencensus.io v0.23.0 // indirect From 8bdb6c4d93c62c066b817483765daaa988b9d872 Mon Sep 17 00:00:00 2001 From: David Poncelow Date: Thu, 7 Oct 2021 11:25:59 -0700 Subject: [PATCH 5/6] poll should return an error, not log --- receiver/mongodbatlasreceiver/receiver.go | 49 +++++++++++++---------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/receiver/mongodbatlasreceiver/receiver.go b/receiver/mongodbatlasreceiver/receiver.go index 10332b3089c2..e44c7f8347a2 100644 --- a/receiver/mongodbatlasreceiver/receiver.go +++ b/receiver/mongodbatlasreceiver/receiver.go @@ -18,6 +18,9 @@ import ( "context" "time" + "github.com/pkg/errors" + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/receiver/scraperhelper" "go.uber.org/zap" @@ -54,12 +57,26 @@ func (s *receiver) scrape(ctx context.Context) (pdata.Metrics, error) { return pdata.Metrics{}, nil } -func (s *receiver) poll(ctx context.Context, start string, end string, resolution string) { //nolint - for _, org := range s.client.Organizations(ctx) { - resourceAttributes.InsertString("org_name", org.Name) - for _, project := range s.client.Projects(ctx, org.ID) { - resourceAttributes.InsertString("project_name", project.Name) - for _, process := range s.client.Processes(ctx, project.ID) { +func (s *receiver) poll(ctx context.Context, start string, end string, resolution string) error { + ctx := s.ctx + resourceAttributes := pdata.NewAttributeMap() + orgs, err := s.client.Organizations(ctx) + if err != nil { + return errors.Wrap(err, "error retrieving organizations") + } + for _, org := range orgs { + resourceAttributes.InsertString("mongodb.atlas.org_name", org.Name) + projects, err := s.client.Projects(ctx, org.ID) + if err != nil { + return errors.Wrap(err, "error retrieving projects") + } + for _, project := range projects { + resourceAttributes.InsertString("mongodb.atlas.project", project.Name) + processes, err := s.client.Processes(ctx, project.ID) + if err != nil { + return errors.Wrap(err, "error retrieving MongoDB Atlas processes") + } + for _, process := range processes { resource := pdata.NewResource() resourceAttributes.CopyTo(resource.Attributes()) resource.Attributes().InsertString("host.name", process.Hostname) @@ -80,11 +97,7 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio resolution, ) if err != nil { - s.log.Debug( - "Encountered error when polling from MongoDB Atlas", - zap.Error(err), - ) - return + return errors.Wrap(err, "error when polling process metrics from MongoDB Atlas") } s.metricSink.ConsumeMetrics(ctx, metrics) @@ -95,7 +108,7 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio process.Port, ) if err != nil { - s.log.Debug("Error retrieving process databases", zap.Error(err)) + return errors.Wrap(err, "error retrieving process databases") } for _, db := range processDatabases { @@ -115,11 +128,7 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio resolution, ) if err != nil { - s.log.Debug( - "Encountered error when polling from MongoDB Atlas", - zap.Error(err), - ) - return + return errors.Wrap(err, "error when polling database metrics from MongoDB Atlas") } s.metricSink.ConsumeMetrics( ctx, @@ -143,10 +152,7 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio resolution, ) if err != nil { - s.log.Debug( - "Encountered error when polling from MongoDB Atlas", - zap.Error(err)) - return + return errors.Wrap(err, "error when polling from MongoDB Atlas") } s.metricSink.ConsumeMetrics( ctx, @@ -159,4 +165,5 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio } } } + return nil } From d09dc6781a1facf9861bdfb374b7251eb26fc8cc Mon Sep 17 00:00:00 2001 From: David Poncelow Date: Wed, 20 Oct 2021 16:50:57 -0700 Subject: [PATCH 6/6] changes to work with scraperhelper --- go.mod | 8 +- go.sum | 25 ++-- receiver/mongodbatlasreceiver/go.mod | 14 +- receiver/mongodbatlasreceiver/go.sum | 70 +++++++++- receiver/mongodbatlasreceiver/receiver.go | 149 ++++++++++------------ 5 files changed, 157 insertions(+), 109 deletions(-) diff --git a/go.mod b/go.mod index 53de72e7cc3b..5bae652aae4c 100644 --- a/go.mod +++ b/go.mod @@ -103,7 +103,7 @@ require ( github.com/prometheus/prometheus v1.8.2-0.20210621150501-ff58416a0b02 github.com/stretchr/testify v1.7.0 go.opentelemetry.io/collector v0.37.1-0.20211015233822-bd87fb628058 - golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 + golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac ) require github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbatlasreceiver v0.37.1 @@ -355,16 +355,16 @@ require ( go.uber.org/zap v1.19.1 // indirect golang.org/x/crypto v0.0.0-20210920023735-84f357641f63 // indirect golang.org/x/net v0.0.0-20210927181540-4e4d966f7476 // indirect - golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect + golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gonum.org/v1/gonum v0.9.3 // indirect - google.golang.org/api v0.58.0 // indirect + google.golang.org/api v0.59.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20210927142257-433400c27d05 // indirect + google.golang.org/genproto v0.0.0-20211008145708-270636b82663 // indirect google.golang.org/grpc v1.41.0 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/DataDog/dd-trace-go.v1 v1.33.0 // indirect diff --git a/go.sum b/go.sum index bcf9898fc559..c13b5898937f 100644 --- a/go.sum +++ b/go.sum @@ -1677,7 +1677,6 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.28.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.31.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.31.1 h1:d18hG4PkHnNAKNMOmFuXFaiY8Us0nird/2m60uS1AMs= github.com/prometheus/common v0.31.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/exporter-toolkit v0.5.1/go.mod h1:OCkM4805mmisBhLmVFw858QYi3v0wKdY6/UxrT0pZVg= @@ -1766,8 +1765,6 @@ github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAx github.com/shirou/gopsutil v2.18.10+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.20.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v3.21.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil v3.21.6+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.9+incompatible h1:LTLpUnfX81MkHeCtSrwNKZwuW5Id6kCa7/P43NdcNn4= github.com/shirou/gopsutil v3.21.9+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= @@ -2053,11 +2050,6 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.22.6/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/collector v0.28.0/go.mod h1:AP/BTXwo1eedoJO7V+HQ68CSvJU1lcdqOzJCgt1VsNs= -go.opentelemetry.io/collector v0.31.0/go.mod h1:A9vKmEa2MI/vJXNUoRinq9w25ZMmxWJLYXYELHkBEw0= -go.opentelemetry.io/collector v0.36.1-0.20210930151317-3ec4f1be6001/go.mod h1:JsoDzlne/ihaLP5xdpcVNErpns1cZwzGF/hf2Kr+hK8= -go.opentelemetry.io/collector v0.36.1-0.20211004155959-190f8fbb2b9a h1:FOP2IABtkcVUPy10rlKgLGgisKABrkB4RVEhYA2iTxU= -go.opentelemetry.io/collector v0.36.1-0.20211004155959-190f8fbb2b9a/go.mod h1:z3NLthT38PDZvMqsBlxXtE5WQvcnSwwV8IRXBdcgpwk= go.opentelemetry.io/collector v0.35.0/go.mod h1:mMW4VJHhy8CwoTenV75axteKd0aZhWHDZjcZ59V53kc= go.opentelemetry.io/collector v0.37.1-0.20211015233822-bd87fb628058 h1:6v0ba4ruY/W2cJLElDZEHDwShlSWUjK2MiBMvwfAIN0= go.opentelemetry.io/collector v0.37.1-0.20211015233822-bd87fb628058/go.mod h1:zbLWBJVy7bmiZHlHjCrV28vxXA/sAkCLtH5thD8ZahA= @@ -2090,7 +2082,6 @@ go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnf go.opentelemetry.io/otel v1.0.1 h1:4XKyXmfqJLOQ7feyV5DB6gsBFZ0ltB8vLtp6pj4JIcc= go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU= go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= -go.opentelemetry.io/otel/exporters/prometheus v0.23.0/go.mod h1:kjCXbxQnnEm5l3HrUw4IPyuALu7Uqb/bEK7vWQnbd8s= go.opentelemetry.io/otel/exporters/prometheus v0.24.0 h1:lfVirQkD4jPMh7m6i9sHDHweYZyWA0NDU6NszkbtFSE= go.opentelemetry.io/otel/exporters/prometheus v0.24.0/go.mod h1:jfc9W1hVK0w9zrsE+C2ELje/M+K67cGinzeg8qQ8oog= go.opentelemetry.io/otel/internal/metric v0.22.0/go.mod h1:7qVuMihW/ktMonEfOvBXuh6tfMvvEyoIDgeJNRloYbQ= @@ -2108,16 +2099,13 @@ go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1 go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc= go.opentelemetry.io/otel/sdk v1.0.0-RC2/go.mod h1:fgwHyiDn4e5k40TD9VX243rOxXR+jzsWBZYA2P5jpEw= go.opentelemetry.io/otel/sdk v1.0.0-RC3/go.mod h1:78H6hyg2fka0NYT9fqGuFLvly2yCxiBXDJAgLKo/2Us= -go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM= go.opentelemetry.io/otel/sdk v1.0.0-RC3/go.mod h1:78H6hyg2fka0NYT9fqGuFLvly2yCxiBXDJAgLKo/2Us= go.opentelemetry.io/otel/sdk v1.0.1 h1:wXxFEWGo7XfXupPwVJvTBOaPBC9FEg0wB8hMNrKk+cA= go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI= go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE= -go.opentelemetry.io/otel/sdk/export/metric v0.23.0/go.mod h1:SuMiREmKVRIwFKq73zvGTvwFpxb/ZAYkMfyqMoOtDqs= go.opentelemetry.io/otel/sdk/export/metric v0.24.0 h1:innKi8LQebwPI+WEuEKEWMjhWC5mXQG1/WpSm5mffSY= go.opentelemetry.io/otel/sdk/export/metric v0.24.0/go.mod h1:chmxXGVNcpCih5XyniVkL4VUyaEroUbOdvjVlQ8M29Y= go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= -go.opentelemetry.io/otel/sdk/metric v0.23.0/go.mod h1:wa0sKK13eeIFW+0OFjcC3S1i7FTRRiLAXe1kjBVbhwg= go.opentelemetry.io/otel/sdk/metric v0.24.0 h1:LLHrZikGdEHoHihwIPvfFRJX+T+NdrU2zgEqf7tQ7Oo= go.opentelemetry.io/otel/sdk/metric v0.24.0/go.mod h1:KDgJgYzsIowuIDbPM9sLDZY9JJ6gqIDWCx92iWV8ejk= go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= @@ -2345,8 +2333,9 @@ golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210615190721-d04028783cf1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f h1:Qmd2pbz05z7z6lm0DrgQVVPuBm92jqujBKMHMOlOQEw= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 h1:B333XXssMuKQeBwiNODx4TupZy7bf4sxFZnN2ZOcvUE= +golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -2488,11 +2477,11 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= @@ -2693,8 +2682,9 @@ google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6 google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.58.0 h1:MDkAbYIB1JpSgCTOCYYoIec/coMlKK4oVbpnBLLcyT0= google.golang.org/api v0.58.0/go.mod h1:cAbP2FsxoGVNwtgNAmmn3y5G1TWAiVYRmg4yku3lv+E= +google.golang.org/api v0.59.0 h1:fPfFO7gttlXYo2ALuD3HxJzh8vaF++4youI0BkFL6GE= +google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -2779,8 +2769,9 @@ google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20210927142257-433400c27d05 h1:6/1QShroBaS9sY9NbPquolxRETG6PZhfv8ohdbLieBg= google.golang.org/genproto v0.0.0-20210927142257-433400c27d05/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663 h1:33YYJanAOLxgS7pGjzC1IUrFLpwN//bbgtnKYikOmQU= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= diff --git a/receiver/mongodbatlasreceiver/go.mod b/receiver/mongodbatlasreceiver/go.mod index 4c79712e1cd6..e8961293e384 100644 --- a/receiver/mongodbatlasreceiver/go.mod +++ b/receiver/mongodbatlasreceiver/go.mod @@ -4,22 +4,22 @@ go 1.17 require ( github.com/mongodb-forks/digest v1.0.3 - github.com/open-telemetry/opentelemetry-collector-contrib/internal/interval v0.36.0 github.com/pkg/errors v0.9.1 - go.mongodb.org/atlas v0.12.0 - go.opentelemetry.io/collector v0.36.1-0.20211004155959-190f8fbb2b9a - go.opentelemetry.io/collector/model v0.36.1-0.20211004155959-190f8fbb2b9a go.mongodb.org/atlas v0.13.0 go.opentelemetry.io/collector v0.37.1-0.20211015233822-bd87fb628058 go.opentelemetry.io/collector/model v0.37.1-0.20211015233822-bd87fb628058 go.uber.org/zap v1.19.1 + google.golang.org/api v0.59.0 ) require ( + cloud.google.com/go v0.97.0 // indirect github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-querystring v1.1.0 // indirect + github.com/googleapis/gax-go/v2 v2.1.1 // indirect github.com/knadh/koanf v1.2.4 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.4.2 // indirect @@ -35,9 +35,11 @@ require ( go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.7.0 // indirect golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect - golang.org/x/sys v0.0.0-20210902050250-f475640dd07b // indirect + golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 // indirect + golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect golang.org/x/text v0.3.6 // indirect - google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20211008145708-270636b82663 // indirect google.golang.org/grpc v1.41.0 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/receiver/mongodbatlasreceiver/go.sum b/receiver/mongodbatlasreceiver/go.sum index 3dd38dd33993..92d9b96aef22 100644 --- a/receiver/mongodbatlasreceiver/go.sum +++ b/receiver/mongodbatlasreceiver/go.sum @@ -18,6 +18,14 @@ cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmW cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= +cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= +cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= +cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= +cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0 h1:3DXvAyifywvq64LfkKaMOmkWPS1CikIQdMe2lY9vxU8= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -130,6 +138,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -149,6 +158,7 @@ github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -170,6 +180,7 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -181,11 +192,17 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= +github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU= +github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= @@ -496,6 +513,7 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q= @@ -513,6 +531,11 @@ golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 h1:B333XXssMuKQeBwiNODx4TupZy7bf4sxFZnN2ZOcvUE= +golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -578,11 +601,18 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210611083646-a4fc73990273/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210902050250-f475640dd07b h1:S7hKs0Flbq0bbc9xgYt4stIEG1zNDFqyrPwAX2Wj/sE= -golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -647,7 +677,10 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -676,12 +709,23 @@ google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjR google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= +google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= +google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= +google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= +google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= +google.golang.org/api v0.59.0 h1:fPfFO7gttlXYo2ALuD3HxJzh8vaF++4youI0BkFL6GE= +google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -724,9 +768,24 @@ google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08 h1:pc16UedxnxXXtGxHCSUhafAoVHQZ0yXl8ZelMH4EETc= google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= +google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= +google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663 h1:33YYJanAOLxgS7pGjzC1IUrFLpwN//bbgtnKYikOmQU= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -748,10 +807,15 @@ google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA5 google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.41.0 h1:f+PlOh7QV4iIJkPrx5NQ7qaNGFQ3OTse67yaDHfju4E= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= diff --git a/receiver/mongodbatlasreceiver/receiver.go b/receiver/mongodbatlasreceiver/receiver.go index e44c7f8347a2..1b4a32e2d8bb 100644 --- a/receiver/mongodbatlasreceiver/receiver.go +++ b/receiver/mongodbatlasreceiver/receiver.go @@ -16,11 +16,10 @@ package mongodbatlasreceiver import ( "context" + "strconv" "time" "github.com/pkg/errors" - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/model/pdata" "go.opentelemetry.io/collector/receiver/scraperhelper" "go.uber.org/zap" @@ -52,29 +51,32 @@ func (s *receiver) scrape(ctx context.Context) (pdata.Metrics, error) { start = time.Now().Add(s.cfg.CollectionInterval * -1) } now := time.Now() - s.poll(ctx, start.UTC().Format(time.RFC3339), now.UTC().Format(time.RFC3339), s.cfg.Granularity) + metrics, err := s.poll(ctx, start.UTC().Format(time.RFC3339), now.UTC().Format(time.RFC3339), s.cfg.Granularity) + if err != nil { + return pdata.Metrics{}, err + } s.lastRun = now - return pdata.Metrics{}, nil + return metrics, nil } -func (s *receiver) poll(ctx context.Context, start string, end string, resolution string) error { - ctx := s.ctx +func (s *receiver) poll(ctx context.Context, start string, end string, resolution string) (pdata.Metrics, error) { resourceAttributes := pdata.NewAttributeMap() + allMetrics := pdata.NewMetrics() orgs, err := s.client.Organizations(ctx) if err != nil { - return errors.Wrap(err, "error retrieving organizations") + return pdata.Metrics{}, errors.Wrap(err, "error retrieving organizations") } for _, org := range orgs { resourceAttributes.InsertString("mongodb.atlas.org_name", org.Name) projects, err := s.client.Projects(ctx, org.ID) if err != nil { - return errors.Wrap(err, "error retrieving projects") + return pdata.Metrics{}, errors.Wrap(err, "error retrieving projects") } for _, project := range projects { resourceAttributes.InsertString("mongodb.atlas.project", project.Name) processes, err := s.client.Processes(ctx, project.ID) if err != nil { - return errors.Wrap(err, "error retrieving MongoDB Atlas processes") + return pdata.Metrics{}, errors.Wrap(err, "error retrieving MongoDB Atlas processes") } for _, process := range processes { resource := pdata.NewResource() @@ -83,87 +85,76 @@ func (s *receiver) poll(ctx context.Context, start string, end string, resolutio resource.Attributes().InsertString("process.port", strconv.Itoa(process.Port)) // This receiver will support both logs and metrics- if one pipeline // or the other is not configured, it will be nil. - pdata.NewMetrics() - if s.metricSink != nil { - metrics, err := - s.client.ProcessMetrics( - ctx, - resource, - project.ID, - process.Hostname, - process.Port, - start, - end, - resolution, - ) - if err != nil { - return errors.Wrap(err, "error when polling process metrics from MongoDB Atlas") - } - s.metricSink.ConsumeMetrics(ctx, metrics) + metrics, err := + s.client.ProcessMetrics( + ctx, + resource, + project.ID, + process.Hostname, + process.Port, + start, + end, + resolution, + ) + if err != nil { + return pdata.Metrics{}, errors.Wrap(err, "error when polling process metrics from MongoDB Atlas") + } + metrics.ResourceMetrics().MoveAndAppendTo(allMetrics.ResourceMetrics()) - processDatabases, err := s.client.ProcessDatabases( + processDatabases, err := s.client.ProcessDatabases( + ctx, + project.ID, + process.Hostname, + process.Port, + ) + if err != nil { + return pdata.Metrics{}, errors.Wrap(err, "error retrieving process databases") + } + + for _, db := range processDatabases { + dbResource := pdata.NewResource() + resource.CopyTo(dbResource) + resource.Attributes(). + InsertString("mongodb.atlas.database_name", db.DatabaseName) + metrics, err := s.client.ProcessDatabaseMetrics( ctx, + resource, project.ID, process.Hostname, process.Port, + db.DatabaseName, + start, + end, + resolution, ) if err != nil { - return errors.Wrap(err, "error retrieving process databases") - } - - for _, db := range processDatabases { - dbResource := pdata.NewResource() - resource.CopyTo(dbResource) - resource.Attributes(). - InsertString("mongodb.atlas.database_name", db.DatabaseName) - metrics, err := s.client.ProcessDatabaseMetrics( - ctx, - resource, - project.ID, - process.Hostname, - process.Port, - db.DatabaseName, - start, - end, - resolution, - ) - if err != nil { - return errors.Wrap(err, "error when polling database metrics from MongoDB Atlas") - } - s.metricSink.ConsumeMetrics( - ctx, - metrics, - ) + return pdata.Metrics{}, errors.Wrap(err, "error when polling database metrics from MongoDB Atlas") } - for _, disk := range s.client.ProcessDisks(ctx, project.ID, process.Hostname, process.Port) { - diskResource := pdata.NewResource() - resource.CopyTo(diskResource) - diskResource.Attributes(). - InsertString("mongodb.atlas.partition", disk.PartitionName) - metrics, err := s.client.ProcessDiskMetrics( - ctx, - diskResource, - project.ID, - process.Hostname, - process.Port, - disk.PartitionName, - start, - end, - resolution, - ) - if err != nil { - return errors.Wrap(err, "error when polling from MongoDB Atlas") - } - s.metricSink.ConsumeMetrics( - ctx, - metrics, - ) + metrics.ResourceMetrics().MoveAndAppendTo(allMetrics.ResourceMetrics()) + } + for _, disk := range s.client.ProcessDisks(ctx, project.ID, process.Hostname, process.Port) { + diskResource := pdata.NewResource() + resource.CopyTo(diskResource) + diskResource.Attributes(). + InsertString("mongodb.atlas.partition", disk.PartitionName) + metrics, err := s.client.ProcessDiskMetrics( + ctx, + diskResource, + project.ID, + process.Hostname, + process.Port, + disk.PartitionName, + start, + end, + resolution, + ) + if err != nil { + return pdata.Metrics{}, errors.Wrap(err, "error when polling from MongoDB Atlas") } - } else { - s.log.Debug("Metrics not enabled") + metrics.ResourceMetrics().MoveAndAppendTo(allMetrics.ResourceMetrics()) } } } } - return nil + return allMetrics, nil }