From 55c69e9c0b32cca9c69a3c3ed44850b9fba1f5f5 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Thu, 18 May 2023 14:27:40 -0700 Subject: [PATCH] [exporter/carbon] use generated status header This PR updates the component to generate the status table using mdatagen. Linked issue: #21213 Signed-off-by: Alex Boten --- exporter/carbonexporter/README.md | 21 ++++++++++--------- exporter/carbonexporter/config_test.go | 6 ++++-- exporter/carbonexporter/doc.go | 2 ++ exporter/carbonexporter/factory.go | 11 +++------- .../internal/metadata/generated_status.go | 12 +++++++++++ exporter/carbonexporter/metadata.yaml | 7 +++++++ 6 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 exporter/carbonexporter/internal/metadata/generated_status.go create mode 100644 exporter/carbonexporter/metadata.yaml diff --git a/exporter/carbonexporter/README.md b/exporter/carbonexporter/README.md index 16f67dd8e53f..a799b8b8b07a 100644 --- a/exporter/carbonexporter/README.md +++ b/exporter/carbonexporter/README.md @@ -1,10 +1,16 @@ # Carbon Exporter -| Status | | -| ------------------------ | ----------------------------- | -| Stability | [beta] | -| Supported pipeline types | metrics | -| Distributions | [contrib], [observiq], [sumo] | + +| Status | | +| ------------- |-----------| +| Stability | [beta]: metrics | +| Distributions | [contrib], [observiq], [sumo] | + +[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 +[sumo]: https://github.com/SumoLogic/sumologic-otel-collector + The [Carbon](https://github.com/graphite-project/carbon) exporter supports Carbon's [plaintext @@ -37,8 +43,3 @@ exporters: The full list of settings exposed for this receiver are documented [here](./config.go) with detailed sample configurations [here](./testdata/config.yaml). - -[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 -[sumo]: https://github.com/SumoLogic/sumologic-otel-collector diff --git a/exporter/carbonexporter/config_test.go b/exporter/carbonexporter/config_test.go index 6137c0118be8..07cfaf48e42b 100644 --- a/exporter/carbonexporter/config_test.go +++ b/exporter/carbonexporter/config_test.go @@ -12,6 +12,8 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/confmap/confmaptest" + + "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter/internal/metadata" ) func TestLoadConfig(t *testing.T) { @@ -27,11 +29,11 @@ func TestLoadConfig(t *testing.T) { }{ { - id: component.NewIDWithName(typeStr, ""), + id: component.NewIDWithName(metadata.Type, ""), expected: createDefaultConfig(), }, { - id: component.NewIDWithName(typeStr, "allsettings"), + id: component.NewIDWithName(metadata.Type, "allsettings"), expected: &Config{ Endpoint: "localhost:8080", Timeout: 10 * time.Second, diff --git a/exporter/carbonexporter/doc.go b/exporter/carbonexporter/doc.go index 80a171e08fa6..db743358016f 100644 --- a/exporter/carbonexporter/doc.go +++ b/exporter/carbonexporter/doc.go @@ -1,5 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +//go:generate mdatagen metadata.yaml + // Package carbonexporter implements an exporter that sends data to Carbon. package carbonexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter" diff --git a/exporter/carbonexporter/factory.go b/exporter/carbonexporter/factory.go index a5e1ca1df035..87d5666332e4 100644 --- a/exporter/carbonexporter/factory.go +++ b/exporter/carbonexporter/factory.go @@ -8,21 +8,16 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/exporter" -) -const ( - // The value of "type" key in configuration. - typeStr = "carbon" - // The stability level of the exporter. - stability = component.StabilityLevelBeta + "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/carbonexporter/internal/metadata" ) // NewFactory creates a factory for Carbon exporter. func NewFactory() exporter.Factory { return exporter.NewFactory( - typeStr, + metadata.Type, createDefaultConfig, - exporter.WithMetrics(createMetricsExporter, stability)) + exporter.WithMetrics(createMetricsExporter, metadata.MetricsStability)) } func createDefaultConfig() component.Config { diff --git a/exporter/carbonexporter/internal/metadata/generated_status.go b/exporter/carbonexporter/internal/metadata/generated_status.go new file mode 100644 index 000000000000..6dbde87f829a --- /dev/null +++ b/exporter/carbonexporter/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 = "carbon" + MetricsStability = component.StabilityLevelBeta +) diff --git a/exporter/carbonexporter/metadata.yaml b/exporter/carbonexporter/metadata.yaml new file mode 100644 index 000000000000..a430e70a01f4 --- /dev/null +++ b/exporter/carbonexporter/metadata.yaml @@ -0,0 +1,7 @@ +type: carbon + +status: + class: exporter + stability: + beta: [metrics] + distributions: [contrib, observiq, sumo]