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
36 changes: 36 additions & 0 deletions cmd/mdatagen/internal/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,43 @@
},
ScopeName: "go.opentelemetry.io/collector/internal/receiver/samplereceiver",
ShortFolderName: "sample",
ExampleConfigs: []ExampleConfig{
{
Name: "Basic Configuration",
Description: "This example demonstrates the most basic configuration for the sample receiver with default settings.",
Config: `sample:
metrics:
default.metric:
enabled: true
`,
},
{
Name: "Advanced Configuration",
Description: "This example shows an advanced configuration with custom metrics enabled and resource attributes configured.",
Config: `sample:
metrics:
default.metric:
enabled: true
optional.metric:
enabled: true
resource_attributes:
string.resource.attr:
enabled: true
optional.resource.attr:
enabled: true
`,
},
{
Name: "Minimal Configuration",
Description: "A minimal configuration suitable for testing environments with only essential metrics.",
Config: `sample:
metrics:
metric.input_type:
enabled: true
`,
},
},
Tests: Tests{Host: "newMdatagenNopHost()"},

Check failure on line 487 in cmd/mdatagen/internal/loader_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gofumpt)
},
},
{
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 @@ -44,6 +44,8 @@ type Metadata struct {
ScopeName string `mapstructure:"scope_name"`
// ShortFolderName is the shortened folder name of the component, removing class if present
ShortFolderName string `mapstructure:"-"`
// ExampleConfigs are example configuration snippets for the component.
ExampleConfigs []ExampleConfig `mapstructure:"example_configs"`
// Tests is the set of tests generated with the component
Tests Tests `mapstructure:"tests"`
// PackageName is the name of the package where the component is defined.
Expand Down Expand Up @@ -521,3 +523,12 @@ type EntityAttributeRef struct {
// Ref is the reference to a resource attribute.
Ref AttributeName `mapstructure:"ref"`
}

type ExampleConfig struct {
// Name is a descriptive name for the example configuration.
Name string `mapstructure:"name"`
// Description provides context about when this configuration should be used.
Description string `mapstructure:"description"`
// Config is the example configuration snippet in YAML format.
Config string `mapstructure:"config"`
}

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

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

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

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

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

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

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

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

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

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

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

45 changes: 45 additions & 0 deletions cmd/mdatagen/internal/samplereceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,51 @@

# sample

## Example Configurations

### Basic Configuration

This example demonstrates the most basic configuration for the sample receiver with default settings.

```yaml
sample:
metrics:
default.metric:
enabled: true

```

### Advanced Configuration

This example shows an advanced configuration with custom metrics enabled and resource attributes configured.

```yaml
sample:
metrics:
default.metric:
enabled: true
optional.metric:
enabled: true
resource_attributes:
string.resource.attr:
enabled: true
optional.resource.attr:
enabled: true

```

### Minimal Configuration

A minimal configuration suitable for testing environments with only essential metrics.

```yaml
sample:
metrics:
metric.input_type:
enabled: true

```

## Default Metrics

The following metrics are emitted by default. Each of them can be disabled by applying the following configuration:
Expand Down

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

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

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

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

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

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

Loading
Loading