diff --git a/exporter/awscloudwatchlogsexporter/README.md b/exporter/awscloudwatchlogsexporter/README.md index d6c771ee795b..8270c18b7339 100644 --- a/exporter/awscloudwatchlogsexporter/README.md +++ b/exporter/awscloudwatchlogsexporter/README.md @@ -1,10 +1,15 @@ # AWS CloudWatch Logs Exporter -| Status | | -| ------------------------ |-----------------------| -| Stability | [beta] | -| Supported pipeline types | logs | -| Distributions | [contrib], [observiq] | + +| Status | | +| ------------- |-----------| +| Stability | [beta]: logs | +| Distributions | [contrib], [observiq] | + +[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta +[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib +[observiq]: https://github.com/observIQ/observiq-otel-collector + AWS CloudWatch Logs Exporter sends logs data to AWS [CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html). AWS credentials are retrieved from the [default credential chain](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials). @@ -57,7 +62,3 @@ exporters: enabled: true initial_interval: 10ms ``` - -[beta]:https://github.com/open-telemetry/opentelemetry-collector#beta -[contrib]:https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib -[observiq]: https://github.com/observIQ/observiq-otel-collector diff --git a/exporter/awscloudwatchlogsexporter/config_test.go b/exporter/awscloudwatchlogsexporter/config_test.go index 875b3df95e33..9b9ffd1da008 100644 --- a/exporter/awscloudwatchlogsexporter/config_test.go +++ b/exporter/awscloudwatchlogsexporter/config_test.go @@ -17,6 +17,7 @@ import ( "go.opentelemetry.io/collector/exporter/exporterhelper" "go.uber.org/multierr" + "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/awsutil" ) @@ -34,7 +35,7 @@ func TestLoadConfig(t *testing.T) { errorMessage string }{ { - id: component.NewIDWithName(typeStr, "e1-defaults"), + id: component.NewIDWithName(metadata.Type, "e1-defaults"), expected: &Config{ RetrySettings: defaultRetrySettings, LogGroupName: "test-1", @@ -47,7 +48,7 @@ func TestLoadConfig(t *testing.T) { }, }, { - id: component.NewIDWithName(typeStr, "e2-no-retries-short-queue"), + id: component.NewIDWithName(metadata.Type, "e2-no-retries-short-queue"), expected: &Config{ RetrySettings: exporterhelper.RetrySettings{ Enabled: false, @@ -66,19 +67,19 @@ func TestLoadConfig(t *testing.T) { }, }, { - id: component.NewIDWithName(typeStr, "invalid_queue_size"), + id: component.NewIDWithName(metadata.Type, "invalid_queue_size"), errorMessage: "'sending_queue.queue_size' must be 1 or greater", }, { - id: component.NewIDWithName(typeStr, "invalid_required_field_stream"), + id: component.NewIDWithName(metadata.Type, "invalid_required_field_stream"), errorMessage: "'log_stream_name' must be set", }, { - id: component.NewIDWithName(typeStr, "invalid_required_field_group"), + id: component.NewIDWithName(metadata.Type, "invalid_required_field_group"), errorMessage: "'log_group_name' must be set", }, { - id: component.NewIDWithName(typeStr, "invalid_queue_setting"), + id: component.NewIDWithName(metadata.Type, "invalid_queue_setting"), errorMessage: `'sending_queue' has invalid keys: enabled, num_consumers`, }, } @@ -159,46 +160,46 @@ func TestValidateTags(t *testing.T) { errorMessage string }{ { - id: component.NewIDWithName(typeStr, "validate-correct"), + id: component.NewIDWithName(metadata.Type, "validate-correct"), tags: map[string]*string{"basicKey": &basicValue}, }, { - id: component.NewIDWithName(typeStr, "too-little-tags"), + id: component.NewIDWithName(metadata.Type, "too-little-tags"), tags: emptyMap, errorMessage: "invalid amount of items. Please input at least 1 tag or remove the tag field", }, { - id: component.NewIDWithName(typeStr, "too-many-tags"), + id: component.NewIDWithName(metadata.Type, "too-many-tags"), tags: bigMap, errorMessage: "invalid amount of items. Please input at most 50 tags", }, { - id: component.NewIDWithName(typeStr, "wrong-key-regex"), + id: component.NewIDWithName(metadata.Type, "wrong-key-regex"), tags: map[string]*string{"***": &basicValue}, errorMessage: "key - *** does not follow the regex pattern" + `^([\p{L}\p{Z}\p{N}_.:/=+\-@]+)$`, }, { - id: component.NewIDWithName(typeStr, "wrong-value-regex"), + id: component.NewIDWithName(metadata.Type, "wrong-value-regex"), tags: map[string]*string{"basicKey": &wrongRegexValue}, errorMessage: "value - " + wrongRegexValue + " does not follow the regex pattern" + `^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`, }, { - id: component.NewIDWithName(typeStr, "key-too-short"), + id: component.NewIDWithName(metadata.Type, "key-too-short"), tags: map[string]*string{"": &basicValue}, errorMessage: "key - has an invalid length. Please use keys with a length of 1 to 128 characters", }, { - id: component.NewIDWithName(typeStr, "key-too-long"), + id: component.NewIDWithName(metadata.Type, "key-too-long"), tags: map[string]*string{strings.Repeat("a", 129): &basicValue}, errorMessage: "key - " + strings.Repeat("a", 129) + " has an invalid length. Please use keys with a length of 1 to 128 characters", }, { - id: component.NewIDWithName(typeStr, "value-too-short"), + id: component.NewIDWithName(metadata.Type, "value-too-short"), tags: map[string]*string{"basicKey": &emptyValue}, errorMessage: "value - " + emptyValue + " has an invalid length. Please use values with a length of 1 to 256 characters", }, { - id: component.NewIDWithName(typeStr, "value-too-long"), + id: component.NewIDWithName(metadata.Type, "value-too-long"), tags: map[string]*string{"basicKey": &tooLongValue}, errorMessage: "value - " + tooLongValue + " has an invalid length. Please use values with a length of 1 to 256 characters", }, diff --git a/exporter/awscloudwatchlogsexporter/factory.go b/exporter/awscloudwatchlogsexporter/factory.go index d35cfe72c2a6..efdb366d1794 100644 --- a/exporter/awscloudwatchlogsexporter/factory.go +++ b/exporter/awscloudwatchlogsexporter/factory.go @@ -1,6 +1,8 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +//go:generate mdatagen metadata.yaml + // Package awscloudwatchlogsexporter provides a logging exporter for the OpenTelemetry collector. // This package is subject to change and may break configuration settings and behavior. package awscloudwatchlogsexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awscloudwatchlogsexporter" @@ -13,20 +15,15 @@ import ( exp "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" ) -const ( - typeStr = "awscloudwatchlogs" - // The stability level of the exporter. - stability = component.StabilityLevelBeta -) - func NewFactory() exp.Factory { return exp.NewFactory( - typeStr, + metadata.Type, createDefaultConfig, - exp.WithLogs(createLogsExporter, stability)) + exp.WithLogs(createLogsExporter, metadata.LogsStability)) } func createDefaultConfig() component.Config { diff --git a/exporter/awscloudwatchlogsexporter/internal/metadata/generated_status.go b/exporter/awscloudwatchlogsexporter/internal/metadata/generated_status.go new file mode 100644 index 000000000000..85737d8480e2 --- /dev/null +++ b/exporter/awscloudwatchlogsexporter/internal/metadata/generated_status.go @@ -0,0 +1,12 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +const ( + Type = "awscloudwatchlogs" + LogsStability = component.StabilityLevelBeta +) diff --git a/exporter/awscloudwatchlogsexporter/metadata.yaml b/exporter/awscloudwatchlogsexporter/metadata.yaml new file mode 100644 index 000000000000..c5d58fd21633 --- /dev/null +++ b/exporter/awscloudwatchlogsexporter/metadata.yaml @@ -0,0 +1,7 @@ +type: awscloudwatchlogs + +status: + class: exporter + stability: + beta: [logs] + distributions: [contrib, observiq]