Skip to content

Commit

Permalink
[exporter/awscloudwatchlogs] use generated status header (#22113)
Browse files Browse the repository at this point in the history
This PR updates the component to generate the status table using mdatagen.

Linked issue: #21213

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
Alex Boten authored May 20, 2023
1 parent 6a7d8d5 commit 2f31c02
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 32 deletions.
19 changes: 10 additions & 9 deletions exporter/awscloudwatchlogsexporter/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# AWS CloudWatch Logs Exporter

| Status | |
| ------------------------ |-----------------------|
| Stability | [beta] |
| Supported pipeline types | logs |
| Distributions | [contrib], [observiq] |
<!-- status autogenerated section -->
| 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
<!-- end autogenerated section -->

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).
Expand Down Expand Up @@ -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
31 changes: 16 additions & 15 deletions exporter/awscloudwatchlogsexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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",
Expand All @@ -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,
Expand All @@ -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`,
},
}
Expand Down Expand Up @@ -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",
},
Expand Down
13 changes: 5 additions & 8 deletions exporter/awscloudwatchlogsexporter/factory.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions exporter/awscloudwatchlogsexporter/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: awscloudwatchlogs

status:
class: exporter
stability:
beta: [logs]
distributions: [contrib, observiq]

0 comments on commit 2f31c02

Please sign in to comment.