Skip to content

Commit

Permalink
[chore][receiver/carbon] create metadata (open-telemetry#21842)
Browse files Browse the repository at this point in the history
  • Loading branch information
BominRahmani committed May 11, 2023
1 parent f319aa8 commit 4540dde
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 20 deletions.
16 changes: 9 additions & 7 deletions receiver/carbonreceiver/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Carbon Receiver

| Status | |
| ------------------------ |------------|
| Stability | [beta] |
| Supported pipeline types | metrics |
| Distributions | [contrib] |
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [beta]: metrics |
| Distributions | [contrib] |

[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

The [Carbon](https://github.com/graphite-project/carbon) receiver supports
Carbon's [plaintext
Expand Down Expand Up @@ -61,5 +65,3 @@ receivers:
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
7 changes: 4 additions & 3 deletions receiver/carbonreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/confmap/confmaptest"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver/protocol"
)

Expand All @@ -39,11 +40,11 @@ func TestLoadConfig(t *testing.T) {
expected component.Config
}{
{
id: component.NewIDWithName(typeStr, ""),
id: component.NewIDWithName(metadata.Type, ""),
expected: createDefaultConfig(),
},
{
id: component.NewIDWithName(typeStr, "receiver_settings"),
id: component.NewIDWithName(metadata.Type, "receiver_settings"),
expected: &Config{
NetAddr: confignet.NetAddr{
Endpoint: "localhost:8080",
Expand All @@ -57,7 +58,7 @@ func TestLoadConfig(t *testing.T) {
},
},
{
id: component.NewIDWithName(typeStr, "regex"),
id: component.NewIDWithName(metadata.Type, "regex"),
expected: &Config{
NetAddr: confignet.NetAddr{
Endpoint: "localhost:2003",
Expand Down
2 changes: 2 additions & 0 deletions receiver/carbonreceiver/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:generate mdatagen metadata.yaml

// Package carbonreceiver implements a receiver that can be used by the
// OpenTelemetry collector to receive data in the Carbon supported formats.
// Carbon is the backend used by Graphite, see
Expand Down
12 changes: 3 additions & 9 deletions receiver/carbonreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,19 @@ import (
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver/protocol"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver/transport"
)

// This file implements factory for Carbon receiver.

const (
// The value of "type" key in configuration.
typeStr = "carbon"
// The stability level of the receiver.
stability = component.StabilityLevelBeta
)

// NewFactory creates a factory for Carbon receiver.
func NewFactory() receiver.Factory {
return receiver.NewFactory(
typeStr,
metadata.Type,
createDefaultConfig,
receiver.WithMetrics(createMetricsReceiver, stability))
receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability))
}

func createDefaultConfig() component.Config {
Expand Down
12 changes: 12 additions & 0 deletions receiver/carbonreceiver/internal/metadata/generated_status.go

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

8 changes: 8 additions & 0 deletions receiver/carbonreceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: carbon

status:
class: receiver
stability:
beta: [metrics]
distributions: [contrib]

4 changes: 3 additions & 1 deletion receiver/carbonreceiver/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/obsreport/obsreporttest"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver/internal/metadata"
)

func TestReporterObservability(t *testing.T) {
receiverID := component.NewIDWithName(typeStr, "fake_receiver")
receiverID := component.NewIDWithName(metadata.Type, "fake_receiver")
tt, err := obsreporttest.SetupTelemetry(receiverID)
require.NoError(t, err)
defer func() {
Expand Down

0 comments on commit 4540dde

Please sign in to comment.