Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mdatagen] Rename include/exclude config options #9960

Merged
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

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.

Original file line number Diff line number Diff line change
Expand Up @@ -61,67 +61,67 @@ filter_set_include:
resource_attributes:
map.resource.attr:
enabled: true
include:
metrics_include:
- regexp: ".*"
optional.resource.attr:
enabled: true
include:
metrics_include:
- regexp: ".*"
slice.resource.attr:
enabled: true
include:
metrics_include:
- regexp: ".*"
string.enum.resource.attr:
enabled: true
include:
metrics_include:
- regexp: ".*"
string.resource.attr:
enabled: true
include:
metrics_include:
- regexp: ".*"
string.resource.attr_disable_warning:
enabled: true
include:
metrics_include:
- regexp: ".*"
string.resource.attr_remove_warning:
enabled: true
include:
metrics_include:
- regexp: ".*"
string.resource.attr_to_be_removed:
enabled: true
include:
metrics_include:
- regexp: ".*"
filter_set_exclude:
resource_attributes:
map.resource.attr:
enabled: true
exclude:
metrics_exclude:
- regexp: ".*"
optional.resource.attr:
enabled: true
exclude:
metrics_exclude:
- strict: "optional.resource.attr-val"
slice.resource.attr:
enabled: true
exclude:
metrics_exclude:
- regexp: ".*"
string.enum.resource.attr:
enabled: true
exclude:
metrics_exclude:
- strict: "one"
string.resource.attr:
enabled: true
exclude:
metrics_exclude:
- strict: "string.resource.attr-val"
string.resource.attr_disable_warning:
enabled: true
exclude:
metrics_exclude:
- strict: "string.resource.attr_disable_warning-val"
string.resource.attr_remove_warning:
enabled: true
exclude:
metrics_exclude:
- strict: "string.resource.attr_remove_warning-val"
string.resource.attr_to_be_removed:
enabled: true
exclude:
metrics_exclude:
- strict: "string.resource.attr_to_be_removed-val"
9 changes: 7 additions & 2 deletions cmd/mdatagen/templates/config.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ func DefaultMetricsConfig() MetricsConfig {
type ResourceAttributeConfig struct {
Enabled bool `mapstructure:"enabled"`
{{- if .Metrics }}
Include []filter.Config `mapstructure:"include"`
Exclude []filter.Config `mapstructure:"exclude"`
// Experimental: MetricsInclude defines a list of filters for attribute values.
// If the list is not empty, only metrics with matching resource attribute values will be emitted.
MetricsInclude []filter.Config `mapstructure:"metrics_include"`
// Experimental: MetricsExclude defines a list of filters for attribute values.
// If the list is not empty, metrics with matching resource attribute values will not be emitted.
// MetricsInclude has higher priority than MetricsExclude.
MetricsExclude []filter.Config `mapstructure:"metrics_exclude"`
{{- end }}

enabledSetByUser bool
Expand Down
10 changes: 5 additions & 5 deletions cmd/mdatagen/templates/metrics.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSetting
}
{{- end }}
{{- if $attr.Warnings.IfConfigured }}
if mbc.ResourceAttributes.{{ $name.Render }}.enabledSetByUser || mbc.ResourceAttributes.{{ $name.Render }}.Include != nil || mbc.ResourceAttributes.{{ $name.Render }}.Exclude != nil {
if mbc.ResourceAttributes.{{ $name.Render }}.enabledSetByUser || mbc.ResourceAttributes.{{ $name.Render }}.MetricsInclude != nil || mbc.ResourceAttributes.{{ $name.Render }}.MetricsExclude != nil {
settings.Logger.Warn("[WARNING] `{{ $name }}` should not be configured: {{ $attr.Warnings.IfConfigured }}")
}
{{- end }}
Expand All @@ -203,11 +203,11 @@ func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.CreateSetting
{{- end }}
}
{{- range $name, $attr := .ResourceAttributes }}
if mbc.ResourceAttributes.{{ $name.Render }}.Include != nil {
mb.resourceAttributeIncludeFilter["{{ $name }}"] = filter.CreateFilter(mbc.ResourceAttributes.{{ $name.Render }}.Include)
if mbc.ResourceAttributes.{{ $name.Render }}.MetricsInclude != nil {
mb.resourceAttributeIncludeFilter["{{ $name }}"] = filter.CreateFilter(mbc.ResourceAttributes.{{ $name.Render }}.MetricsInclude)
}
if mbc.ResourceAttributes.{{ $name.Render }}.Exclude != nil {
mb.resourceAttributeExcludeFilter["{{ $name }}"] = filter.CreateFilter(mbc.ResourceAttributes.{{ $name.Render }}.Exclude)
if mbc.ResourceAttributes.{{ $name.Render }}.MetricsExclude != nil {
mb.resourceAttributeExcludeFilter["{{ $name }}"] = filter.CreateFilter(mbc.ResourceAttributes.{{ $name.Render }}.MetricsExclude)
}
{{- end }}

Expand Down
4 changes: 2 additions & 2 deletions cmd/mdatagen/templates/testdata/config.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ filter_set_include:
{{- range $name, $attr := .ResourceAttributes }}
{{ $name }}:
enabled: true
include:
metrics_include:
- regexp: ".*"
{{- end }}
filter_set_exclude:
resource_attributes:
{{- range $name, $attr := .ResourceAttributes }}
{{ $name }}:
enabled: true
exclude:
metrics_exclude:
{{- if eq $attr.Type.String "Str" }}
- strict: {{ $attr.TestValue }}
{{- else }}
Expand Down
Loading