Skip to content
Closed
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/make-display-required.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. receiver/otlp)
component: cmd/mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Make the `display_name` field required in metadata.yaml files used by mdatagen

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

# (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: [user]
22 changes: 6 additions & 16 deletions cmd/mdatagen/internal/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ func TestLoadMetadata(t *testing.T) {
name: "testdata/parent.yaml",
want: Metadata{
Type: "subcomponent",
DisplayName: "Subcomponent",
Parent: "parentComponent",
GeneratedPackageName: "metadata",
ScopeName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
Expand All @@ -601,6 +602,7 @@ func TestLoadMetadata(t *testing.T) {
name: "testdata/generated_package_name.yaml",
want: Metadata{
Type: "custom",
DisplayName: "Custom Receiver",
GeneratedPackageName: "customname",
ScopeName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
PackageName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
Expand All @@ -620,6 +622,7 @@ func TestLoadMetadata(t *testing.T) {
name: "testdata/empty_test_config.yaml",
want: Metadata{
Type: "test",
DisplayName: "Test Receiver",
GeneratedPackageName: "metadata",
ScopeName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
PackageName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
Expand Down Expand Up @@ -726,22 +729,8 @@ func TestLoadMetadata(t *testing.T) {
},
},
{
name: "testdata/no_display_name.yaml",
want: Metadata{
Type: "nodisplayname",
DisplayName: "",
GeneratedPackageName: "metadata",
ScopeName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
PackageName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
ShortFolderName: "testdata",
Tests: Tests{Host: "newMdatagenNopHost()"},
Status: &Status{
Class: "receiver",
Stability: map[component.StabilityLevel][]string{
component.StabilityLevelBeta: {"logs"},
},
},
},
name: "testdata/no_display_name.yaml",
wantErr: "missing display_name",
},
{
name: "testdata/with_description.yaml",
Expand All @@ -766,6 +755,7 @@ func TestLoadMetadata(t *testing.T) {
name: "testdata/with_underscore_in_semconv_ref_anchor_tag.yaml",
want: Metadata{
Type: "metricreceiver",
DisplayName: "Metric Receiver",
GeneratedPackageName: "metadata",
SemConvVersion: "1.40.0",
ScopeName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
Expand Down
11 changes: 11 additions & 0 deletions cmd/mdatagen/internal/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ func (md *Metadata) Validate() error {
errs = errors.Join(errs, err)
}

if err := md.validateDisplayName(); err != nil {
errs = errors.Join(errs, err)
}

if md.Parent != "" {
if md.Status != nil {
// status is not required for subcomponents.
Expand Down Expand Up @@ -158,6 +162,13 @@ func (md *Metadata) validateType() error {
return nil
}

func (md *Metadata) validateDisplayName() error {
if md.DisplayName == "" {
return errors.New("missing display_name")
}
return nil
}

func (md *Metadata) validateResourceAttributes() error {
var errs error
for name, attr := range md.ResourceAttributes {
Expand Down
3 changes: 2 additions & 1 deletion cmd/mdatagen/internal/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ func TestValidateConfig(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
md := &Metadata{
Type: "test",
Type: "test",
DisplayName: "Test Component",
Status: &Status{
Class: "exporter",
Stability: StabilityMap{
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/async_metric.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metricreceiver
display_name: Metric Receiver

status:
class: receiver
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/basic_connector.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: test
display_name: Test Component

status:
class: connector
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/basic_pkg.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: test
display_name: Test Component

status:
class: pkg
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/basic_receiver.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: test
display_name: Test Component

status:
class: receiver
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metricreceiver
display_name: Metric Receiver

generated_package_name: custom

Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/empty_test_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: test
display_name: Test Receiver

status:
class: receiver
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/entity_valid.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/events/basic_event.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: receiver
display_name: Test Receiver

status:
class: receiver
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/feature_gates.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component
status:
class: receiver
stability:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: custom
display_name: Custom Receiver

generated_package_name: customname

Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/metrics_and_type.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metricreceiver
display_name: Metric Receiver

status:
class: receiver
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/parent.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
type: subcomponent
display_name: Subcomponent

parent: parentComponent
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: test
display_name: Test Component

status:
class: receiver
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/status_only.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metricreceiver
display_name: Metric Receiver
status:
class: exporter
stability:
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/unsorted_rattr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: sample
display_name: Sample Component

status:
class: receiver
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: receiver
display_name: Test Receiver

status:
class: receiver
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: receiver
display_name: Test Receiver

status:
class: receiver
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_goleak_ignores.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: foobar
display_name: Foobar Component

status:
disable_codecov_badge: true
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_goleak_setup.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: foobar
display_name: Foobar Component

status:
disable_codecov_badge: true
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_goleak_skip.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: foobar
display_name: Foobar Component

status:
disable_codecov_badge: true
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_goleak_teardown.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: foobar
display_name: Foobar Component

status:
disable_codecov_badge: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: receiver
display_name: Test Receiver

status:
class: receiver
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_telemetry.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metric
display_name: Metric Component

status:
class: receiver
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_tests_connector.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: foobar
display_name: Foobar Component

status:
disable_codecov_badge: true
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_tests_exporter.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metric
display_name: Metric Component

status:
class: exporter
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_tests_extension.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metric
display_name: Metric Component

status:
class: extension
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_tests_processor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metric
display_name: Metric Component

status:
class: processor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: foobar
display_name: Foobar Component

status:
disable_codecov_badge: true
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/testdata/with_tests_receiver.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metric
display_name: Metric Component

status:
class: receiver
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type: metricreceiver
display_name: Metric Receiver

status:
class: receiver
Expand Down
2 changes: 1 addition & 1 deletion cmd/mdatagen/metadata-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type:
# Optional: A deprecated type that is still available as an alias.
deprecated_type: string

# Optional: Human-readable display name for the component. Used as the title in generated README files.
# Required: Human-readable display name for the component. Used as the title in generated README files.
display_name: string

# Optional: Brief description of the component that will be included in the generated README.
Expand Down
Loading