Skip to content

Commit 8aa55d6

Browse files
committed
[mdatagen] Add optional description field to metadata.yaml
Add description field to capture component purpose in generated README. The description is rendered after the title within the autogenerated section. Addresses review feedback from PR open-telemetry#14115 Related to open-telemetry#14114
1 parent ce112ad commit 8aa55d6

File tree

11 files changed

+50
-6
lines changed

11 files changed

+50
-6
lines changed

cmd/mdatagen/internal/loader_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func TestLoadMetadata(t *testing.T) {
4848
GeneratedPackageName: "metadata",
4949
Type: "sample",
5050
DisplayName: "Sample Receiver",
51+
Description: "This receiver is used for testing purposes to check the output of mdatagen.",
5152
SemConvVersion: "1.37.0",
5253
PackageName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/samplereceiver",
5354
Status: &Status{
@@ -593,6 +594,26 @@ func TestLoadMetadata(t *testing.T) {
593594
},
594595
},
595596
},
597+
{
598+
name: "testdata/with_description.yaml",
599+
want: Metadata{
600+
Type: "test",
601+
DisplayName: "Test Component",
602+
Description: "This is a test component used to validate the description field functionality in mdatagen.",
603+
GeneratedPackageName: "metadata",
604+
ScopeName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
605+
PackageName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
606+
ShortFolderName: "testdata",
607+
Tests: Tests{Host: "newMdatagenNopHost()"},
608+
Status: &Status{
609+
Class: "receiver",
610+
Stability: map[component.StabilityLevel][]string{
611+
component.StabilityLevelBeta: {"metrics"},
612+
},
613+
Distributions: []string{},
614+
},
615+
},
616+
},
596617
}
597618
for _, tt := range tests {
598619
t.Run(tt.name, func(t *testing.T) {

cmd/mdatagen/internal/metadata.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type Metadata struct {
2020
Type string `mapstructure:"type"`
2121
// DisplayName is a human-readable name for the component.
2222
DisplayName string `mapstructure:"display_name"`
23+
// Description is a brief description of the component.
24+
Description string `mapstructure:"description"`
2325
// Type of the parent component (applicable to subcomponents).
2426
Parent string `mapstructure:"parent"`
2527
// Status information for the component.

cmd/mdatagen/internal/sampleprocessor/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
This processor is used for testing purposes to check the output of mdatagen.
2-
31
<!-- status autogenerated section -->
42
# Sample Processor
3+
This processor is used for testing purposes to check the output of mdatagen.
4+
5+
56
| Status | |
67
| ------------- |-----------|
78
| Stability | [development]: logs |

cmd/mdatagen/internal/sampleprocessor/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
type: sample
44
display_name: Sample Processor
5+
description: This processor is used for testing purposes to check the output of mdatagen.
56
scope_name: go.opentelemetry.io/collector/internal/receiver/samplereceiver
67
github_project: open-telemetry/opentelemetry-collector
78

cmd/mdatagen/internal/samplereceiver/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
This receiver is used for testing purposes to check the output of mdatagen.
2-
31
<!-- status autogenerated section -->
42
# Sample Receiver
3+
This receiver is used for testing purposes to check the output of mdatagen.
4+
5+
56
| Status | |
67
| ------------- |-----------|
78
| Stability | [deprecated]: profiles |

cmd/mdatagen/internal/samplereceiver/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
type: sample
44
display_name: Sample Receiver
5+
description: This receiver is used for testing purposes to check the output of mdatagen.
56
scope_name: go.opentelemetry.io/collector/internal/receiver/samplereceiver
67
github_project: open-telemetry/opentelemetry-collector
78

cmd/mdatagen/internal/samplescraper/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
This scraper is used for testing purposes to check the output of mdatagen.
2-
31
<!-- status autogenerated section -->
42
# Sample Scraper
3+
This scraper is used for testing purposes to check the output of mdatagen.
4+
5+
56
| Status | |
67
| ------------- |-----------|
78
| Stability | [development]: logs |

cmd/mdatagen/internal/samplescraper/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
type: sample
44
display_name: Sample Scraper
5+
description: This scraper is used for testing purposes to check the output of mdatagen.
56
github_project: open-telemetry/opentelemetry-collector
67

78
sem_conv_version: 1.37.0

cmd/mdatagen/internal/templates/readme.md.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# {{ .DisplayName }}
44

55
{{- end }}
6+
{{- if .Description }}
7+
{{ .Description }}
8+
9+
{{ end -}}
610
{{- if len .Status.Stability }}
711
| Status | |
812
| ------------- |-----------|
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
type: test
2+
display_name: Test Component
3+
description: This is a test component used to validate the description field functionality in mdatagen.
4+
status:
5+
class: receiver
6+
stability:
7+
beta: [metrics]
8+
distributions: []

0 commit comments

Comments
 (0)