Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] update awscloudwatchlogs exporter to pass apicheck #26366

Merged
merged 8 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/checkapi/allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
connector/servicegraphconnector
exporter/alibabacloudlogserviceexporter
exporter/awscloudwatchlogsexporter
exporter/awskinesisexporter
exporter/azuremonitorexporter
exporter/coralogixexporter
Expand Down Expand Up @@ -37,4 +36,4 @@ receiver/nsxtreceiver
receiver/podmanreceiver
receiver/pulsarreceiver
receiver/statsdreceiver
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