diff --git a/.chloggen/codeboten_doc-status.yaml b/.chloggen/codeboten_doc-status.yaml new file mode 100755 index 000000000000..8dc4eba7e753 --- /dev/null +++ b/.chloggen/codeboten_doc-status.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: mdatagen + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: use metadata to generate status table + +# One or more tracking issues related to the change +issues: [19175] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/cmd/mdatagen/loader.go b/cmd/mdatagen/loader.go index 4291c6d7a25d..b1a0de175117 100644 --- a/cmd/mdatagen/loader.go +++ b/cmd/mdatagen/loader.go @@ -211,6 +211,8 @@ func (attr *attribute) Unmarshal(parser *confmap.Conf) error { type metadata struct { // Name of the component. Name string `mapstructure:"name"` + // Status information for the component. + Status Status `mapstructure:"status"` // SemConvVersion is a version number of OpenTelemetry semantic conventions applied to the scraped metrics. SemConvVersion string `mapstructure:"sem_conv_version"` // ResourceAttributes that can be emitted by the component. diff --git a/cmd/mdatagen/main.go b/cmd/mdatagen/main.go index bbcfe2edb4a5..ed82660c1834 100644 --- a/cmd/mdatagen/main.go +++ b/cmd/mdatagen/main.go @@ -57,6 +57,12 @@ func run(ymlPath string) error { filepath.Join(codeDir, "generated_metrics.go"), md); err != nil { return err } + if len(md.Status.Stability) > 0 { + if err = generateFile(filepath.Join(tmplDir, "status.go.tmpl"), + filepath.Join(codeDir, "generated_status.go"), md); err != nil { + return err + } + } if err = generateFile(filepath.Join(tmplDir, "testdata", "config.yaml.tmpl"), filepath.Join(codeDir, "testdata", "config.yaml"), md); err != nil { return err @@ -99,6 +105,36 @@ func generateFile(tmplFile string, outputFile string, md metadata) error { }, "stringsJoin": strings.Join, "inc": func(i int) int { return i + 1 }, + "stability": func(in string) string { + switch in { + case "alpha": + return "Alpha" + case "beta": + return "Beta" + case "unmaintained": + return "Unmaintained" + case "deprecated": + return "Deprecated" + case "development": + return "Development" + case "stable": + return "Stable" + } + return "Undefined" + }, + "distroJoin": func(d []Distribution, sep string) string { + if len(d) == 1 { + return d[0].Name + } + output := "" + for idx, distro := range d { + if idx > 0 { + output += sep + } + output += distro.Name + } + return output + }, // ParseFS delegates the parsing of the files to `Glob` // which uses the `\` as a special character. // Meaning on windows based machines, the `\` needs to be replaced diff --git a/cmd/mdatagen/statusdata.go b/cmd/mdatagen/statusdata.go new file mode 100644 index 000000000000..a81ffd0761a3 --- /dev/null +++ b/cmd/mdatagen/statusdata.go @@ -0,0 +1,27 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +type Distribution struct { + Name string `mapstructure:"name"` + URL string `mapstructure:"url"` +} + +type Status struct { + Stability string `mapstructure:"stability"` + Pipelines []string `mapstructure:"pipelines"` + Distributions []Distribution `mapstructure:"distributions"` + Type string `mapstructure:"type"` +} diff --git a/cmd/mdatagen/templates/documentation.md.tmpl b/cmd/mdatagen/templates/documentation.md.tmpl index 7a1d9f6ffb6a..796a821282a5 100644 --- a/cmd/mdatagen/templates/documentation.md.tmpl +++ b/cmd/mdatagen/templates/documentation.md.tmpl @@ -37,7 +37,13 @@ [comment]: <> (Code generated by mdatagen. DO NOT EDIT.) # {{ .Name }} - +{{if ne .Status.Stability "" }} +| Status | | +| ------------------------ |-----------| +| Stability | [{{ .Status.Stability }}] | +| Supported pipeline types | {{range .Status.Pipelines }}{{.}},{{end}} | +| Distributions | [{{ distroJoin .Status.Distributions "], [" }}] | +{{ end }} ## Default Metrics The following metrics are emitted by default. Each of them can be disabled by applying the following configuration: @@ -91,3 +97,9 @@ metrics: {{- end }} {{- end }} +{{if ne .Status.Stability "" }} +[{{ .Status.Stability }}]: https://github.com/open-telemetry/opentelemetry-collector#{{ .Status.Stability }} +{{range .Status.Distributions }} +[{{.Name}}]: {{.URL}} +{{end}} +{{- end -}} \ No newline at end of file diff --git a/cmd/mdatagen/templates/status.go.tmpl b/cmd/mdatagen/templates/status.go.tmpl new file mode 100644 index 000000000000..54d1b7e32441 --- /dev/null +++ b/cmd/mdatagen/templates/status.go.tmpl @@ -0,0 +1,9 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package {{ .Package }} + +import ( + "go.opentelemetry.io/collector/component" +) + +const Stability = component.StabilityLevel{{ stability .Status.Stability }} \ No newline at end of file diff --git a/receiver/haproxyreceiver/README.md b/receiver/haproxyreceiver/README.md index a579267e3391..7f99f9a57a15 100644 --- a/receiver/haproxyreceiver/README.md +++ b/receiver/haproxyreceiver/README.md @@ -1,10 +1,6 @@ # HAProxy Receiver -| Status | | -| ------------------------ |-----------| -| Stability | [alpha] | -| Supported pipeline types | metrics | -| Distributions | [contrib] | +Component [status](./documentation.md#haproxyreceiver). The HAProxy receiver generates metrics by polling periodically the HAProxy process through a dedicated socket or HTTP URL. @@ -50,6 +46,3 @@ receivers: haproxy.requests: enabled: true ``` - -[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha - diff --git a/receiver/haproxyreceiver/documentation.md b/receiver/haproxyreceiver/documentation.md index 640356cf0474..caaa1eb0a264 100644 --- a/receiver/haproxyreceiver/documentation.md +++ b/receiver/haproxyreceiver/documentation.md @@ -2,6 +2,12 @@ # haproxyreceiver +| Status | | +| ------------------------ |-----------| +| Stability | [alpha] | +| Supported pipeline types | metrics, | +| Distributions | [contrib] | + ## Default Metrics The following metrics are emitted by default. Each of them can be disabled by applying the following configuration: @@ -249,3 +255,7 @@ Cumulative number of sessions. Corresponds to HAProxy's `stot` metric. | haproxy.url | The path to the HAProxy socket or HTTP URL. | Any Str | true | | proxy_name | Proxy name | Any Str | false | | service_name | Service name (FRONTEND for frontend, BACKEND for backend, any name for server/listener) | Any Str | false | + +[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha + +[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib diff --git a/receiver/haproxyreceiver/factory.go b/receiver/haproxyreceiver/factory.go index f15d70b30b59..76ec4e653635 100644 --- a/receiver/haproxyreceiver/factory.go +++ b/receiver/haproxyreceiver/factory.go @@ -27,8 +27,7 @@ import ( ) const ( - typeStr = "haproxy" - stability = component.StabilityLevelAlpha + typeStr = "haproxy" ) // NewFactory creates a new HAProxy receiver factory. @@ -36,7 +35,7 @@ func NewFactory() receiver.Factory { return receiver.NewFactory( typeStr, newDefaultConfig, - receiver.WithMetrics(newReceiver, stability)) + receiver.WithMetrics(newReceiver, metadata.Stability)) } func newDefaultConfig() component.Config { diff --git a/receiver/haproxyreceiver/internal/metadata/generated_status.go b/receiver/haproxyreceiver/internal/metadata/generated_status.go new file mode 100644 index 000000000000..d4d0800571f8 --- /dev/null +++ b/receiver/haproxyreceiver/internal/metadata/generated_status.go @@ -0,0 +1,9 @@ +// Code generated by mdatagen. DO NOT EDIT. + +package metadata + +import ( + "go.opentelemetry.io/collector/component" +) + +const Stability = component.StabilityLevelAlpha diff --git a/receiver/haproxyreceiver/metadata.yaml b/receiver/haproxyreceiver/metadata.yaml index 456f89d1db9b..2a1daddec4ef 100644 --- a/receiver/haproxyreceiver/metadata.yaml +++ b/receiver/haproxyreceiver/metadata.yaml @@ -1,5 +1,13 @@ name: haproxyreceiver +status: + type: receiver + stability: alpha + pipelines: [metrics] + distributions: + - name: contrib + url: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib + resource_attributes: haproxy.url: description: The path to the HAProxy socket or HTTP URL.