Skip to content
Open
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
27 changes: 27 additions & 0 deletions .chloggen/add-display-name-14114.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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` field 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.
If not provided, the component type will be used with the first letter capitalized.

# 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]
1 change: 1 addition & 0 deletions .github/workflows/utils/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
"nonclobbering",
"nopexporter",
"nopreceiver",
"nodisplayname",
"nosuchprocessor",
"notls",
"obsreceiver",
Expand Down
3 changes: 3 additions & 0 deletions cmd/mdatagen/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Metadata Generator


# Mdatagen

<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
Expand Down
61 changes: 61 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.37.0",
PackageName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/samplereceiver",
Status: &Status{
Expand Down Expand Up @@ -455,6 +457,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 @@ -467,6 +470,7 @@ func TestLoadMetadata(t *testing.T) {
name: "testdata/generated_package_name.yaml",
want: Metadata{
Type: "custom",
DisplayName: "Custom",
GeneratedPackageName: "customname",
ScopeName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
PackageName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
Expand All @@ -486,6 +490,7 @@ func TestLoadMetadata(t *testing.T) {
name: "testdata/empty_test_config.yaml",
want: Metadata{
Type: "test",
DisplayName: "Test",
GeneratedPackageName: "metadata",
ScopeName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
PackageName: "go.opentelemetry.io/collector/cmd/mdatagen/internal/testdata",
Expand Down Expand Up @@ -553,6 +558,62 @@ 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: "test",
DisplayName: "Test Component",
Description: "This is a test component used to validate the description field functionality in mdatagen.",
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: {"metrics"},
},
Distributions: []string{},
},
},
},
}
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 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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cmd/mdatagen/internal/samplefactoryreceiver/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Sample Receiver
This receiver is used for testing purposes to check the output of mdatagen.

<!-- status autogenerated section -->
# Sample Factory Receiver
| Status | |
| ------------- |-----------|
| Stability | [deprecated]: profiles |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Sample metadata file with all available configurations for a receiver.

type: sample
display_name: Sample Factory Receiver
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
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

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


| Status | |
| ------------- |-----------|
| Stability | [development]: logs |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions 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.

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.37.0
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/templates/component_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
{{- end }}

"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
{{- if not (and .Tests.SkipLifecycle .Tests.SkipShutdown) }}
Expand Down
2 changes: 1 addition & 1 deletion cmd/mdatagen/internal/templates/config_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func loadResourceAttributesConfig(t *testing.T, name string) ResourceAttributesC
sub, err = sub.Sub("resource_attributes")
require.NoError(t, err)
cfg := DefaultResourceAttributesConfig()
require.NoError(t, sub.Unmarshal(&cfg))
require.NoError(t, sub.Unmarshal(&cfg, confmap.WithIgnoreUnused()))
return cfg
}
{{- end }}
18 changes: 12 additions & 6 deletions cmd/mdatagen/internal/templates/logs.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@
package {{ .Package }}

import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
{{- if or isReceiver isScraper }}
"go.opentelemetry.io/collector/{{ .Status.Class }}"
{{- if .Events }}
"context"
{{- end }}
{{- if .SemConvVersion }}

conventions "go.opentelemetry.io/otel/semconv/v{{ .SemConvVersion }}"
{{- end }}
{{- if .Events }}
"context"
"go.opentelemetry.io/otel/trace"
{{- end }}

"go.opentelemetry.io/collector/component"
{{- if .Events }}
"go.opentelemetry.io/collector/filter"
{{- end }}
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
{{- if or isReceiver isScraper }}
"go.opentelemetry.io/collector/{{ .Status.Class }}"
{{- end }}
)


Expand Down
14 changes: 9 additions & 5 deletions cmd/mdatagen/internal/templates/logs_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
package {{ .Package }}

import (
"time"
{{- if .Events }}
"context"
{{- end }}
"testing"
"time"

"github.com/stretchr/testify/assert"
{{- if .Events }}
"go.opentelemetry.io/otel/trace"
{{- end }}
"go.uber.org/zap"
"go.uber.org/zap/zaptest/observer"

"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/plog"
{{- if or isReceiver isScraper }}
"go.opentelemetry.io/collector/{{ .Status.Class }}/{{ .Status.Class }}test"
{{- end }}
{{- if .Events }}
"context"
"go.opentelemetry.io/otel/trace"
{{- end }}
)

{{- if .Events }}
Expand Down
13 changes: 7 additions & 6 deletions cmd/mdatagen/internal/templates/metrics.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ import (
"fmt"
{{- end }}
"time"
{{- if .SemConvVersion }}

conventions "go.opentelemetry.io/otel/semconv/v{{ .SemConvVersion }}"
{{- end }}

"go.opentelemetry.io/collector/component"
{{ if .ResourceAttributes -}}
"go.opentelemetry.io/collector/filter"
{{- end }}
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
{{- if or isReceiver isScraper isConnector }}
"go.opentelemetry.io/collector/{{ .Status.Class }}"
{{- end }}
{{- if .SemConvVersion }}
conventions "go.opentelemetry.io/otel/semconv/v{{ .SemConvVersion }}"
{{- end }}
{{ if .ResourceAttributes -}}
"go.opentelemetry.io/collector/filter"
{{- end }}
)

{{ range $name, $info := .Attributes }}
Expand Down
5 changes: 3 additions & 2 deletions cmd/mdatagen/internal/templates/metrics_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"go.uber.org/zap/zaptest/observer"

"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
{{- if or isReceiver isScraper isConnector }}
"go.opentelemetry.io/collector/{{ .Status.Class }}/{{ .Status.Class }}test"
{{- end }}
"go.uber.org/zap"
"go.uber.org/zap/zaptest/observer"
)


Expand Down
Loading
Loading