Skip to content

Commit

Permalink
[chore] update awscloudwatchlogs exporter to pass apicheck (open-tele…
Browse files Browse the repository at this point in the history
…metry#26366)

**Description:** CWL Logs exporter was using an alias for the exporter
package to avoid a naming conflict. I renamed the internal struct to
resolve the error and remove the need for the alias. I did not create a
breaking changelog entry for this as no api surface was changed.

**Link to tracking Issue:** open-telemetry#26304
  • Loading branch information
bryan-aguilar authored Sep 12, 2023
1 parent fb9f011 commit 607912c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions cmd/checkapi/allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
connector/servicegraphconnector
exporter/awscloudwatchlogsexporter
exporter/awskinesisexporter
exporter/azuremonitorexporter
exporter/coralogixexporter
Expand Down Expand Up @@ -33,4 +32,4 @@ receiver/mysqlreceiver
receiver/nsxtreceiver
receiver/podmanreceiver
receiver/pulsarreceiver
receiver/windowseventlogreceiver
receiver/windowseventlogreceiver
12 changes: 6 additions & 6 deletions exporter/awscloudwatchlogsexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/cwlogs"
)

type exporter struct {
type cwlExporter struct {
Config *Config
logger *zap.Logger
retryCount int
Expand All @@ -47,7 +47,7 @@ type emfMetadata struct {
LogStreamName string `json:"log_stream_name,omitempty"`
}

func newCwLogsPusher(expConfig *Config, params exp.CreateSettings) (*exporter, error) {
func newCwLogsPusher(expConfig *Config, params exp.CreateSettings) (*cwlExporter, error) {
if expConfig == nil {
return nil, errors.New("awscloudwatchlogs exporter config is nil")
}
Expand Down Expand Up @@ -79,7 +79,7 @@ func newCwLogsPusher(expConfig *Config, params exp.CreateSettings) (*exporter, e

pusherMap[pusherKey] = pusher

logsExporter := &exporter{
logsExporter := &cwlExporter{
svcStructuredLog: svcStructuredLog,
Config: expConfig,
logger: params.Logger,
Expand Down Expand Up @@ -108,7 +108,7 @@ func newCwLogsExporter(config component.Config, params exp.CreateSettings) (exp.
)
}

func (e *exporter) consumeLogs(_ context.Context, ld plog.Logs) error {
func (e *cwlExporter) consumeLogs(_ context.Context, ld plog.Logs) error {
logEvents, _ := logsToCWLogs(e.logger, ld, e.Config)
if len(logEvents) == 0 {
return nil
Expand Down Expand Up @@ -146,7 +146,7 @@ func (e *exporter) consumeLogs(_ context.Context, ld plog.Logs) error {
return nil
}

func (e *exporter) getLogPusher(logEvent *cwlogs.Event) cwlogs.Pusher {
func (e *cwlExporter) getLogPusher(logEvent *cwlogs.Event) cwlogs.Pusher {
e.pusherMapLock.Lock()
defer e.pusherMapLock.Unlock()
pusherKey := cwlogs.PusherKey{
Expand All @@ -160,7 +160,7 @@ func (e *exporter) getLogPusher(logEvent *cwlogs.Event) cwlogs.Pusher {
return e.pusherMap[pusherKey]
}

func (e *exporter) shutdown(_ context.Context) error {
func (e *cwlExporter) shutdown(_ context.Context) error {
if e.pusherMap != nil {
for _, pusher := range e.pusherMap {
pusher.ForceFlush()
Expand Down
10 changes: 5 additions & 5 deletions exporter/awscloudwatchlogsexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ import (
"errors"

"go.opentelemetry.io/collector/component"
exp "go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil"
)

func NewFactory() exp.Factory {
return exp.NewFactory(
func NewFactory() exporter.Factory {
return exporter.NewFactory(
metadata.Type,
createDefaultConfig,
exp.WithLogs(createLogsExporter, metadata.LogsStability))
exporter.WithLogs(createLogsExporter, metadata.LogsStability))
}

func createDefaultConfig() component.Config {
Expand All @@ -36,7 +36,7 @@ func createDefaultConfig() component.Config {
}
}

func createLogsExporter(_ context.Context, params exp.CreateSettings, config component.Config) (exp.Logs, error) {
func createLogsExporter(_ context.Context, params exporter.CreateSettings, config component.Config) (exporter.Logs, error) {
expConfig, ok := config.(*Config)
if !ok {
return nil, errors.New("invalid configuration type; can't cast to awscloudwatchlogsexporter.Config")
Expand Down

0 comments on commit 607912c

Please sign in to comment.