From c73718cce52dbf82d3b53f946dcaada828bda4dc Mon Sep 17 00:00:00 2001 From: Lewis Robbins Date: Fri, 17 Feb 2023 23:28:50 +0000 Subject: [PATCH] Start on receiver Started receiver struct and stubbed start and shutdown methods --- .../awscloudwatchmetricsreceiver/README.md | 4 +-- .../awscloudwatchmetricsreceiver/factory.go | 5 ++- receiver/awscloudwatchmetricsreceiver/go.mod | 2 +- .../awscloudwatchmetricsreceiver/receiver.go | 36 ++++++++++++++++++- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/receiver/awscloudwatchmetricsreceiver/README.md b/receiver/awscloudwatchmetricsreceiver/README.md index c974806348d0..cb5027f6b3aa 100644 --- a/receiver/awscloudwatchmetricsreceiver/README.md +++ b/receiver/awscloudwatchmetricsreceiver/README.md @@ -50,8 +50,8 @@ awscloudwatchmetrics: poll_interval: 5m metrics: named: - - namespace: /aws/eks/dev-0/cluster: - metric_names: [kube-apiserver-ea9c831555adca1815ae04b87661klasdj] + - namespace: AWS/EC2: + metric_names: [DiskWriteOps,DiskReadBytes] ``` ## Sample Configs diff --git a/receiver/awscloudwatchmetricsreceiver/factory.go b/receiver/awscloudwatchmetricsreceiver/factory.go index a5d486fd2ee9..a0ff50d7f2f6 100644 --- a/receiver/awscloudwatchmetricsreceiver/factory.go +++ b/receiver/awscloudwatchmetricsreceiver/factory.go @@ -41,5 +41,8 @@ func createMetricsRceiver(_ context.Context, params receiver.CreateSettings, bas } func createDefaultConfig() component.Config { - return &Config{} + return &Config{ + PollInterval: defaultPollInterval, + Metrics: &MetricsConfig{}, + } } diff --git a/receiver/awscloudwatchmetricsreceiver/go.mod b/receiver/awscloudwatchmetricsreceiver/go.mod index 41943f59fa1b..537f7d364065 100644 --- a/receiver/awscloudwatchmetricsreceiver/go.mod +++ b/receiver/awscloudwatchmetricsreceiver/go.mod @@ -5,6 +5,7 @@ go 1.19 require ( go.opentelemetry.io/collector v0.71.0 go.opentelemetry.io/collector/component v0.71.0 + go.opentelemetry.io/collector/consumer v0.71.0 go.uber.org/multierr v1.9.0 ) @@ -19,7 +20,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect go.opentelemetry.io/collector/confmap v0.71.0 // indirect - go.opentelemetry.io/collector/consumer v0.71.0 // indirect go.opentelemetry.io/collector/featuregate v0.71.0 // indirect go.opentelemetry.io/collector/pdata v1.0.0-rc5 // indirect go.opentelemetry.io/otel v1.13.0 // indirect diff --git a/receiver/awscloudwatchmetricsreceiver/receiver.go b/receiver/awscloudwatchmetricsreceiver/receiver.go index b57175db648c..cd598ed9a5f8 100644 --- a/receiver/awscloudwatchmetricsreceiver/receiver.go +++ b/receiver/awscloudwatchmetricsreceiver/receiver.go @@ -12,4 +12,38 @@ // See the License for the specific language governing permissions and // limitations under the License. -package awscloudwatchmetricsreceiver +package awscloudwatchmetricsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchmetricsreceiver" + +import ( + "context" + "sync" + "time" + + "go.opentelemetry.io/collector/component" + "go.opentelemetry.io/collector/consumer" + "go.uber.org/zap" +) + +type metricReceiver struct { + region string + profile string + pollInterval time.Duration + nextStartTime time.Time + logger *zap.Logger + consumer consumer.Logs + wg *sync.WaitGroup + doneChan chan bool +} + +func (m *metricReceiver) Start(ctx context.Context, host component.Host) error { + m.logger.Debug("Starting to poll for CloudWatch metrics") + m.wg.Add(1) + return nil +} + +func (m *metricReceiver) Shutdown(ctx context.Context) error { + m.logger.Debug("Shutting down awscloudwatchmetrics receiver") + close(m.doneChan) + m.wg.Wait() + return nil +}