From 3813e4f5b937753186848d879837aae1dee81a4c Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Fri, 22 Dec 2023 08:19:54 -0800 Subject: [PATCH] [chore] use mdatagen for otlp receiver Signed-off-by: Alex Boten --- receiver/otlpreceiver/README.md | 20 +++++++++------ receiver/otlpreceiver/doc.go | 2 ++ receiver/otlpreceiver/factory.go | 12 ++++----- .../internal/metadata/generated_status.go | 25 +++++++++++++++++++ receiver/otlpreceiver/metadata.yaml | 8 ++++++ receiver/otlpreceiver/otlp_test.go | 2 +- 6 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 receiver/otlpreceiver/internal/metadata/generated_status.go create mode 100644 receiver/otlpreceiver/metadata.yaml diff --git a/receiver/otlpreceiver/README.md b/receiver/otlpreceiver/README.md index 603e320def3..7d3380ae1dc 100644 --- a/receiver/otlpreceiver/README.md +++ b/receiver/otlpreceiver/README.md @@ -1,12 +1,18 @@ # OTLP Receiver -| Status | | -| ------------------------ | --------------------- | -| Stability | traces [stable] | -| | metrics [stable] | -| | logs [beta] | -| Supported pipeline types | traces, metrics, logs | -| Distributions | [core], [contrib] | + +| Status | | +| ------------- |-----------| +| Stability | [beta]: logs | +| | [stable]: traces, metrics | +| Distributions | [core], [contrib] | +| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Fotlp%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fotlp) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Fotlp%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fotlp) | + +[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta +[stable]: https://github.com/open-telemetry/opentelemetry-collector#stable +[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol +[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib + Receives data via gRPC or HTTP using [OTLP]( https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md) diff --git a/receiver/otlpreceiver/doc.go b/receiver/otlpreceiver/doc.go index 78378a5c082..f0974c12e2a 100644 --- a/receiver/otlpreceiver/doc.go +++ b/receiver/otlpreceiver/doc.go @@ -1,5 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +//go:generate mdatagen metadata.yaml + // Package otlpreceiver receives data in OTLP format. package otlpreceiver // import "go.opentelemetry.io/collector/receiver/otlpreceiver" diff --git a/receiver/otlpreceiver/factory.go b/receiver/otlpreceiver/factory.go index 125c7c9f296..bb8f3bb4f92 100644 --- a/receiver/otlpreceiver/factory.go +++ b/receiver/otlpreceiver/factory.go @@ -13,11 +13,10 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/internal/sharedcomponent" "go.opentelemetry.io/collector/receiver" + "go.opentelemetry.io/collector/receiver/otlpreceiver/internal/metadata" ) const ( - typeStr = "otlp" - defaultGRPCEndpoint = "0.0.0.0:4317" defaultHTTPEndpoint = "0.0.0.0:4318" @@ -29,11 +28,12 @@ const ( // NewFactory creates a new OTLP receiver factory. func NewFactory() receiver.Factory { return receiver.NewFactory( - typeStr, + metadata.Type, createDefaultConfig, - receiver.WithTraces(createTraces, component.StabilityLevelStable), - receiver.WithMetrics(createMetrics, component.StabilityLevelStable), - receiver.WithLogs(createLog, component.StabilityLevelBeta)) + receiver.WithTraces(createTraces, metadata.TracesStability), + receiver.WithMetrics(createMetrics, metadata.MetricsStability), + receiver.WithLogs(createLog, metadata.LogsStability), + ) } // createDefaultConfig creates the default configuration for receiver. diff --git a/receiver/otlpreceiver/internal/metadata/generated_status.go b/receiver/otlpreceiver/internal/metadata/generated_status.go new file mode 100644 index 00000000000..ec7a695b15f --- /dev/null +++ b/receiver/otlpreceiver/internal/metadata/generated_status.go @@ -0,0 +1,25 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/trace" + + "go.opentelemetry.io/collector/component" +) + +const ( + Type = "otlp" + LogsStability = component.StabilityLevelBeta + TracesStability = component.StabilityLevelStable + MetricsStability = component.StabilityLevelStable +) + +func Meter(settings component.TelemetrySettings) metric.Meter { + return settings.MeterProvider.Meter("otelcol/otlpreceiver") +} + +func Tracer(settings component.TelemetrySettings) trace.Tracer { + return settings.TracerProvider.Tracer("otelcol/otlpreceiver") +} diff --git a/receiver/otlpreceiver/metadata.yaml b/receiver/otlpreceiver/metadata.yaml new file mode 100644 index 00000000000..c3036a3341d --- /dev/null +++ b/receiver/otlpreceiver/metadata.yaml @@ -0,0 +1,8 @@ +type: otlp + +status: + class: receiver + stability: + stable: [traces, metrics] + beta: [logs] + distributions: [core, contrib] diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 2de4628455c..c76150cb9a5 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -48,7 +48,7 @@ import ( const otlpReceiverName = "receiver_test" -var otlpReceiverID = component.NewIDWithName(typeStr, otlpReceiverName) +var otlpReceiverID = component.NewIDWithName("otlp", otlpReceiverName) var traceJSON = []byte(` {