Skip to content

Commit

Permalink
[mdatagen] Add ability to specify additional warnings in metadata.yaml
Browse files Browse the repository at this point in the history
- if_enabled_not_set: to require `enabled` field to be explicitly set by user in case if metric is going to be turned from optional to default and vice versa.

- if_configured: to make sure that metric is not configured by user. Should be used for deprecated optional metrics that will be removed soon.

This change also adds more test coverage for the metrics config unmarshaling
  • Loading branch information
dmitryax committed Dec 20, 2022
1 parent 1d703ee commit e6ad59b
Show file tree
Hide file tree
Showing 130 changed files with 4,540 additions and 2,166 deletions.
11 changes: 11 additions & 0 deletions .chloggen/mdatagen-more-warnings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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. filelogreceiver)
component: mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add ability to specify additional warnings in metadata.yaml

# One or more tracking issues related to the change
issues: [17180]
12 changes: 11 additions & 1 deletion cmd/mdatagen/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ metrics:
Monotonic cumulative sum int metric enabled by default.
Additional information.
The metric will be become optional soon.
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
Expand All @@ -30,6 +30,16 @@ Additional information.
| state | Integer attribute with overridden name. | Any Int |
| enum_attr | Attribute with a known set of string values. | Str: ``red``, ``green``, ``blue`` |
### default.metric.to_be_removed
[DEPRECATED] Non-monotonic delta sum double metric enabled by default.
The metric will be will be removed soon.
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| s | Sum | Double | Delta | false |
## Optional Metrics
The following metrics are not emitted by default. Each of them can be enabled by applying the following configuration:
Expand Down
111 changes: 87 additions & 24 deletions cmd/mdatagen/internal/metadata/generated_metrics.go

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

62 changes: 49 additions & 13 deletions cmd/mdatagen/internal/metadata/generated_metrics_test.go

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

15 changes: 15 additions & 0 deletions cmd/mdatagen/internal/metadata/testdata/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
default:
all_metrics:
default.metric:
enabled: true
default.metric.to_be_removed:
enabled: true
optional.metric:
enabled: true
no_metrics:
default.metric:
enabled: false
default.metric.to_be_removed:
enabled: false
optional.metric:
enabled: false
4 changes: 4 additions & 0 deletions cmd/mdatagen/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ func (m metric) Data() MetricData {
type warnings struct {
// A warning that will be displayed if the metric is enabled in user config.
IfEnabled string `mapstructure:"if_enabled"`
// A warning that will be displayed if `enabled` field is not set explicitly in user config.
IfEnabledNotSet string `mapstructure:"if_enabled_not_set"`
// A warning that will be displayed if the metrics is configured by user in any way.
IfConfigured string `mapstructure:"if_configured"`
}

type attribute struct {
Expand Down
Loading

0 comments on commit e6ad59b

Please sign in to comment.