From cbb2dee6c4ac31d5264db7f5e24e45279aabf408 Mon Sep 17 00:00:00 2001 From: Paramadon Date: Wed, 11 Dec 2024 03:35:34 -0500 Subject: [PATCH] adding fixed change --- exporter/awsemfexporter/emf_exporter.go | 6 +++--- exporter/awsemfexporter/factory.go | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/exporter/awsemfexporter/emf_exporter.go b/exporter/awsemfexporter/emf_exporter.go index ccfca8ba2244..fac8ce31c438 100644 --- a/exporter/awsemfexporter/emf_exporter.go +++ b/exporter/awsemfexporter/emf_exporter.go @@ -7,11 +7,11 @@ import ( "context" "errors" "fmt" + "github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil" "strings" "sync" - "github.com/amazon-contributing/opentelemetry-collector-contrib/extension/awsmiddleware" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/google/uuid" "go.opentelemetry.io/collector/component" @@ -167,7 +167,7 @@ func (emf *emfExporter) getPusher(key cwlogs.StreamKey) (cwlogs.Pusher, error) { pusher, exists := emf.pusherMap[key] if !exists { - if emf.set.Logger !=nil{ + if emf.set.Logger != nil { pusher = cwlogs.NewPusher(key, emf.retryCnt, *emf.svcStructuredLog, emf.set.Logger) } else { pusher = cwlogs.NewPusher(key, emf.retryCnt, *emf.svcStructuredLog, emf.config.logger) @@ -188,7 +188,7 @@ func (emf *emfExporter) listPushers() []cwlogs.Pusher { return pushers } -func (emf *emfExporter) start(ctx context.Context, host component.Host) error { +func (emf *emfExporter) start(_ context.Context, host component.Host) error { // Create AWS session here awsConfig, session, err := awsutil.GetAWSConfigSession(emf.config.logger, &awsutil.Conn{}, &emf.config.AWSSessionSettings) if err != nil { diff --git a/exporter/awsemfexporter/factory.go b/exporter/awsemfexporter/factory.go index 5a6a264d2695..3e4ad06ed538 100644 --- a/exporter/awsemfexporter/factory.go +++ b/exporter/awsemfexporter/factory.go @@ -5,8 +5,6 @@ package awsemfexporter // import "github.com/open-telemetry/opentelemetry-collec import ( "context" - "fmt" - "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/exporter" "go.opentelemetry.io/collector/exporter/exporterhelper" @@ -61,16 +59,13 @@ func createMetricsExporter(ctx context.Context, params exporter.Settings, config return nil, err } - // Calling start right after constructor - if err := emfExp.start(ctx, nil); err != nil { - return nil, fmt.Errorf("failed to start EMF exporter: %w", err) - } exporter, err := exporterhelper.NewMetricsExporter( ctx, params, config, emfExp.pushMetricsData, + exporterhelper.WithStart(emfExp.start), exporterhelper.WithShutdown(emfExp.shutdown), ) if err != nil {