Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/add-confmap-to-mdatagen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# 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. otlpreceiver)
component: mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add `converter` and `provider` module classes

# One or more tracking issues or pull requests related to the change
issues: [12467]

# (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:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
10 changes: 9 additions & 1 deletion cmd/mdatagen/internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"path/filepath"
"regexp"
"runtime/debug"
"slices"
"strings"
"text/template"

Expand All @@ -26,6 +27,13 @@ const (
statusEnd = "<!-- end autogenerated section -->"
)

var nonComponents = []string{
"cmd",
"converter",
"pkg",
"provider",
}

func getVersion() (string, error) {
// the second returned value is a boolean, which is true if the binaries are built with module support.
info, ok := debug.ReadBuildInfo()
Expand Down Expand Up @@ -78,7 +86,7 @@ func run(ymlPath string) error {
codeDir := filepath.Join(ymlDir, "internal", md.GeneratedPackageName)
toGenerate := map[string]string{}
if md.Status != nil {
if md.Status.Class != "cmd" && md.Status.Class != "pkg" {
if !slices.Contains(nonComponents, md.Status.Class) {
toGenerate[filepath.Join(tmplDir, "status.go.tmpl")] = filepath.Join(codeDir, "generated_status.go")
if err = generateFile(filepath.Join(tmplDir, "component_test.go.tmpl"),
filepath.Join(ymlDir, "generated_component_test.go"), md, packageName); err != nil {
Expand Down
26 changes: 26 additions & 0 deletions cmd/mdatagen/internal/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,32 @@ Some info about a component
componentClass: "extension",
distros: []string{"contrib"},
},
{
name: "readme with status for converter",
markdown: `# Some component

<!-- status autogenerated section -->
<!-- end autogenerated section -->

Some info about a component
`,
outputFile: "readme_with_status_converter.md",
componentClass: "converter",
distros: []string{"contrib"},
},
{
name: "readme with status for provider",
markdown: `# Some component

<!-- status autogenerated section -->
<!-- end autogenerated section -->

Some info about a component
`,
outputFile: "readme_with_status_provider.md",
componentClass: "provider",
distros: []string{"contrib"},
},
{
name: "readme with status with codeowners and seeking new",
markdown: `# Some component
Expand Down
67 changes: 42 additions & 25 deletions cmd/mdatagen/internal/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package internal // import "go.opentelemetry.io/collector/cmd/mdatagen/internal"
import (
"errors"
"fmt"
"slices"
"sort"

"go.opentelemetry.io/collector/component"
Expand Down Expand Up @@ -48,6 +49,45 @@ type Status struct {
UnsupportedPlatforms []string `mapstructure:"unsupported_platforms"`
}

var validClasses = []string{
"cmd",
"connector",
"converter",
"exporter",
"extension",
"pkg",
"processor",
"provider",
"receiver",
"scraper",
}

var validStabilityKeys = []string{
"converter",
"extension",
"logs",
"logs_to_traces",
"logs_to_metrics",
"logs_to_logs",
"logs_to_profiles",
"metrics",
"metrics_to_traces",
"metrics_to_metrics",
"metrics_to_logs",
"metrics_to_profiles",
"profiles",
"profiles_to_profiles",
"profiles_to_traces",
"profiles_to_metrics",
"profiles_to_logs",
"provider",
"traces_to_traces",
"traces_to_metrics",
"traces_to_logs",
"traces_to_profiles",
"traces",
}

func (s *Status) SortedDistributions() []string {
sorted := s.Distributions
sort.Slice(sorted, func(i, j int) bool {
Expand Down Expand Up @@ -87,10 +127,7 @@ func (s *Status) validateClass() error {
if s.Class == "" {
return errors.New("missing class")
}
if s.Class != "receiver" && s.Class != "processor" &&
s.Class != "exporter" && s.Class != "connector" &&
s.Class != "extension" && s.Class != "scraper" &&
s.Class != "cmd" && s.Class != "pkg" {
if !slices.Contains(validClasses, s.Class) {
return fmt.Errorf("invalid class: %v", s.Class)
}
return nil
Expand All @@ -108,27 +145,7 @@ func (ms StabilityMap) Validate() error {
errs = errors.Join(errs, fmt.Errorf("missing component for stability: %v", stability))
}
for _, c := range cmps {
if c != "metrics" &&
c != "traces" &&
c != "logs" &&
c != "profiles" &&
c != "traces_to_traces" &&
c != "traces_to_metrics" &&
c != "traces_to_logs" &&
c != "traces_to_profiles" &&
c != "metrics_to_traces" &&
c != "metrics_to_metrics" &&
c != "metrics_to_logs" &&
c != "metrics_to_profiles" &&
c != "logs_to_traces" &&
c != "logs_to_metrics" &&
c != "logs_to_logs" &&
c != "logs_to_profiles" &&
c != "profiles_to_profiles" &&
c != "profiles_to_traces" &&
c != "profiles_to_metrics" &&
c != "profiles_to_logs" &&
c != "extension" {
if !slices.Contains(validStabilityKeys, c) {
errs = errors.Join(errs, fmt.Errorf("invalid component: %v", c))
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mdatagen/internal/templates/readme.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{- if ne $class "connector" }}
{{- $idx := 0 }}
{{- range $stability, $value := .Status.Stability }}
| {{ if not $idx }}Stability{{ else }} {{ end }} | [{{ toLowerCase $stability.String }}]{{ if ne $class "extension" }}: {{ stringsJoin $value ", " }} {{ end }} |
| {{ if not $idx }}Stability{{ else }} {{ end }} | [{{ toLowerCase $stability.String }}]{{ if and (ne $class "extension") (ne $class "converter") (ne $class "provider") }}: {{ stringsJoin $value ", " }} {{ end }} |
{{- $idx = inc $idx }}
{{- end }}
{{- end}}
Expand Down
14 changes: 14 additions & 0 deletions cmd/mdatagen/internal/testdata/readme_with_status_converter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Some component

<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [beta] |
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aconverter%2Ffoo%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aconverter%2Ffoo) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aconverter%2Ffoo%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aconverter%2Ffoo) |

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

Some info about a component
14 changes: 14 additions & 0 deletions cmd/mdatagen/internal/testdata/readme_with_status_provider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Some component

<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [beta] |
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aprovider%2Ffoo%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aprovider%2Ffoo) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aprovider%2Ffoo%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aprovider%2Ffoo) |

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

Some info about a component
14 changes: 7 additions & 7 deletions cmd/mdatagen/metadata-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ generated_package_name: string
# Required for components (Optional for subcomponents): A high-level view of the development status and use of this component
status:
# Required: The class of the component (For example receiver)
class: <receiver|processor|exporter|connector|extension|cmd|pkg>
class: <receiver|processor|exporter|connector|extension|cmd|pkg|scraper|converter|provider>
# Required: The stability of the component - See https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#stability-levels
stability:
development: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension>]
alpha: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension>]
beta: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension>]
stable: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension>]
deprecated: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension>]
unmaintained: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension>]
development: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension,converter,provider>]
alpha: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension,converter,provider>]
beta: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension,converter,provider>]
stable: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension,converter,provider>]
deprecated: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension,converter,provider>]
unmaintained: [<metrics|traces|logs|traces_to_metrics|metrics_to_metrics|logs_to_metrics|extension,converter,provider>]
# Optional: The distributions that this component is bundled with (For example core or contrib). See statusdata.go for a list of common distros.
distributions: [string]
# Optional: A list of warnings that should be brought to the attention of users looking to use this component
Expand Down