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
28 changes: 28 additions & 0 deletions .chloggen/add-display-name-14114.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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: cmd/mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add optional `display_name` and `description` fields to metadata.yaml for human-readable component names

# 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: |
The `display_name` field allows components to specify a human-readable name in metadata.yaml.
When provided, this name is used as the title in generated README files.
The `description` field allows components to include a brief description in generated README files.

# 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]
2 changes: 2 additions & 0 deletions .github/workflows/utils/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
"myreceiver",
"myrepo",
"mysite",
"nodisplayname",
"nonclobbering",
"nopexporter",
"nopreceiver",
Expand Down Expand Up @@ -457,6 +458,7 @@
"testcomponents",
"testconverter",
"testdata",
"testdesc",
"testfunc",
"testonly",
"testprocessor",
Expand Down
57 changes: 57 additions & 0 deletions cmd/mdatagen/internal/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func TestLoadMetadata(t *testing.T) {
GithubProject: "open-telemetry/opentelemetry-collector",
GeneratedPackageName: "metadata",
Type: "sample",
DisplayName: "Sample Receiver",
Description: "This receiver is used for testing purposes to check the output of mdatagen.",
SemConvVersion: "1.38.0",
PackageName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/samplereceiver",
Status: &Status{
Expand Down Expand Up @@ -553,6 +555,61 @@ func TestLoadMetadata(t *testing.T) {
name: "testdata/~~this file doesn't exist~~.yaml",
wantErr: "unable to read the file file:testdata/~~this file doesn't exist~~.yaml",
},
{
name: "testdata/display_name.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",
ShortFolderName: "testdata",
Tests: Tests{Host: "newMdatagenNopHost()"},
Status: &Status{
Class: "receiver",
Stability: map[component.StabilityLevel][]string{
component.StabilityLevelBeta: {"logs"},
},
},
},
},
{
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/with_description.yaml",
want: Metadata{
Type: "testdesc",
DisplayName: "Test Component",
Description: "This is a test component with a description.",
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"},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions cmd/mdatagen/internal/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
type Metadata struct {
// Type of the component.
Type string `mapstructure:"type"`
// DisplayName is a human-readable display name for the component.
DisplayName string `mapstructure:"display_name"`
// Description is a brief description of the component.
Description string `mapstructure:"description"`
// Type of the parent component (applicable to subcomponents).
Parent string `mapstructure:"parent"`
// Status information for the component.
Expand Down
2 changes: 2 additions & 0 deletions cmd/mdatagen/internal/sampleconnector/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Sample metadata file with all available configurations for a connector.

type: sample
display_name: Sample Connector
description: This connector is used for testing purposes to check the output of mdatagen.
github_project: open-telemetry/opentelemetry-collector

sem_conv_version: 1.9.0
Expand Down
6 changes: 4 additions & 2 deletions cmd/mdatagen/internal/samplefactoryreceiver/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Sample Receiver
This receiver is used for testing purposes to check the output of mdatagen.
<!-- status autogenerated section -->
# Sample Factory Receiver

This receiver is used for testing purposes to check the output of mdatagen.

| Status | |
| ------------- |-----------|
| Stability | [deprecated]: profiles |
Expand Down
2 changes: 2 additions & 0 deletions cmd/mdatagen/internal/samplefactoryreceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Sample metadata file with all available configurations for a receiver.

type: sample
display_name: Sample Factory Receiver
description: This receiver is used for testing purposes to check the output of mdatagen.
scope_name: go.opentelemetry.io/collector/internal/receiver/samplefactoryreceiver
github_project: open-telemetry/opentelemetry-collector

Expand Down
4 changes: 3 additions & 1 deletion cmd/mdatagen/internal/sampleprocessor/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!-- status autogenerated section -->
# Sample Processor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the title should really be at the top of the document, where it was before. This makes me think we should also have a description field (in this case This processor is used for testing purposes to check the output of mdatagen.) to capture the description of the component. Then the header tag <!-- status autogenerated section --> could be moved to the very top of the document and all the generated contents would be in the right place

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that I think it makes sense to move the description into the metadata object as a new field as well 👍


This processor is used for testing purposes to check the output of mdatagen.
<!-- status autogenerated section -->

| Status | |
| ------------- |-----------|
| Stability | [development]: logs |
Expand Down
4 changes: 3 additions & 1 deletion cmd/mdatagen/internal/sampleprocessor/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Sample metadata file with all available configurations for a receiver.
# Sample metadata file with all available configurations for a processor.

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

Expand Down
4 changes: 3 additions & 1 deletion cmd/mdatagen/internal/samplereceiver/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!-- status autogenerated section -->
# Sample Receiver

This receiver is used for testing purposes to check the output of mdatagen.
<!-- status autogenerated section -->

| Status | |
| ------------- |-----------|
| Stability | [deprecated]: profiles |
Expand Down
2 changes: 2 additions & 0 deletions cmd/mdatagen/internal/samplereceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Sample metadata file with all available configurations for a receiver.

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

Expand Down
4 changes: 3 additions & 1 deletion cmd/mdatagen/internal/samplescraper/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!-- status autogenerated section -->
# Sample Scraper

This scraper is used for testing purposes to check the output of mdatagen.
<!-- status autogenerated section -->

| Status | |
| ------------- |-----------|
| Stability | [development]: logs |
Expand Down
2 changes: 2 additions & 0 deletions cmd/mdatagen/internal/samplescraper/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Sample metadata file with all available configurations for a scraper.

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

sem_conv_version: 1.38.0
Expand Down
7 changes: 7 additions & 0 deletions cmd/mdatagen/internal/templates/readme.md.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<!-- status autogenerated section -->
{{- if .DisplayName }}
# {{ .DisplayName }}
{{- end }}
{{- if .Description }}

{{ .Description }}
{{ end -}}
Comment thread
thc1006 marked this conversation as resolved.
{{- if len .Status.Stability }}
| Status | |
| ------------- |-----------|
Expand Down
7 changes: 7 additions & 0 deletions cmd/mdatagen/internal/testdata/display_name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: test
display_name: Test Receiver

status:
class: receiver
stability:
beta: [logs]
6 changes: 6 additions & 0 deletions cmd/mdatagen/internal/testdata/no_display_name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: nodisplayname

status:
class: receiver
stability:
beta: [logs]
8 changes: 8 additions & 0 deletions cmd/mdatagen/internal/testdata/with_description.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: testdesc
display_name: Test Component
description: This is a test component with a description.

status:
class: receiver
stability:
beta: [logs]
6 changes: 6 additions & 0 deletions cmd/mdatagen/metadata-schema.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Required: The type of the component - Usually the name. The type and class combined uniquely identify the component (eg. receiver/otlp) or subcomponent (eg. receiver/hostmetricsreceiver/cpu)
type:

# Optional: 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.
description: string

# Required for subcomponents: The type of the parent component.
parent: string

Expand Down
Loading