| 1 |
// Code generated by mdatagen. DO NOT EDIT. |
| 2 |
|
| 3 |
package {{ .Package }} |
| 4 |
|
| 5 |
import ( |
| 6 |
"go.opentelemetry.io/collector/confmap" |
| 7 |
{{ if and .Metrics .ResourceAttributes -}} |
| 8 |
"go.opentelemetry.io/collector/filter" |
| 9 |
{{- end }} |
| 10 |
) |
| 11 |
{{ if .Metrics -}} |
| 12 |
|
| 13 |
// MetricConfig provides common config for a particular metric. |
| 14 |
type MetricConfig struct { |
| 15 |
Enabled bool `mapstructure:"enabled"` |
| 16 |
|
| 17 |
enabledSetByUser bool |
| 18 |
} |
| 19 |
|
| 20 |
func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error { |
| 21 |
if parser == nil { |
| 22 |
return nil |
| 23 |
} |
| 24 |
err := parser.Unmarshal(ms) |
| 25 |
if err != nil { |
| 26 |
return err |
| 27 |
} |
| 28 |
ms.enabledSetByUser = parser.IsSet("enabled") |
| 29 |
return nil |
| 30 |
} |
| 31 |
|
| 32 |
// MetricsConfig provides config for {{ .Type }} metrics. |
| 33 |
type MetricsConfig struct { |
| 34 |
{{- range $name, $metric := .Metrics }} |
| 35 |
{{ $name.Render }} MetricConfig `mapstructure:"{{ $name }}"` |
| 36 |
{{- end }} |
| 37 |
} |
| 38 |
|
| 39 |
func DefaultMetricsConfig() MetricsConfig { |
| 40 |
return MetricsConfig{ |
| 41 |
{{- range $name, $metric := .Metrics }} |
| 42 |
{{ $name.Render }}: MetricConfig{ |
| 43 |
Enabled: {{ $metric.Enabled }}, |
| 44 |
}, |
| 45 |
{{- end }} |
| 46 |
} |
| 47 |
} |
| 48 |
{{- end }} |
| 49 |
|
| 50 |
{{ if .Events }} |
| 51 |
// EventConfig provides common config for a particular event. |
| 52 |
type EventConfig struct { |
| 53 |
Enabled bool `mapstructure:"enabled"` |
| 54 |
|
| 55 |
enabledSetByUser bool |
| 56 |
} |
| 57 |
|
| 58 |
func (ec *EventConfig) Unmarshal(parser *confmap.Conf) error { |
| 59 |
if parser == nil { |
| 60 |
return nil |
| 61 |
} |
| 62 |
err := parser.Unmarshal(ec) |
| 63 |
if err != nil { |
| 64 |
return err |
| 65 |
} |
| 66 |
ec.enabledSetByUser = parser.IsSet("enabled") |
| 67 |
return nil |
| 68 |
} |
| 69 |
|
| 70 |
// EventsConfig provides config for {{ .Type }} events. |
| 71 |
type EventsConfig struct { |
| 72 |
{{- range $name, $event := .Events }} |
| 73 |
{{ $name.Render }} EventConfig `mapstructure:"{{ $name }}"` |
| 74 |
{{- end }} |
| 75 |
} |
| 76 |
|
| 77 |
func DefaultEventsConfig() EventsConfig { |
| 78 |
return EventsConfig{ |
| 79 |
{{- range $name, $event := .Events }} |
| 80 |
{{ $name.Render }}: EventConfig{ |
| 81 |
Enabled: {{ $event.Enabled }}, |
| 82 |
}, |
| 83 |
{{- end }} |
| 84 |
} |
| 85 |
} |
| 86 |
{{- end }} |
| 87 |
|
| 88 |
{{ if .ResourceAttributes -}} |
| 89 |
// ResourceAttributeConfig provides common config for a particular resource attribute. |
| 90 |
type ResourceAttributeConfig struct { |
| 91 |
Enabled bool `mapstructure:"enabled"` |
| 92 |
{{- if .Metrics }} |
| 93 |
// Experimental: MetricsInclude defines a list of filters for attribute values. |
| 94 |
// If the list is not empty, only metrics with matching resource attribute values will be emitted. |
| 95 |
MetricsInclude []filter.Config `mapstructure:"metrics_include"` |
| 96 |
// Experimental: MetricsExclude defines a list of filters for attribute values. |
| 97 |
// If the list is not empty, metrics with matching resource attribute values will not be emitted. |
| 98 |
// MetricsInclude has higher priority than MetricsExclude. |
| 99 |
MetricsExclude []filter.Config `mapstructure:"metrics_exclude"` |
| 100 |
{{- end }} |
| 101 |
{{- if .Events }} |
| 102 |
// Experimental: EventsInclude defines a list of filters for attribute values. |
| 103 |
// If the list is not empty, only events with matching resource attribute values will be emitted. |
| 104 |
EventsInclude []filter.Config `mapstructure:"events_include"` |
| 105 |
// Experimental: EventsExclude defines a list of filters for attribute values. |
| 106 |
// If the list is not empty, events with matching resource attribute values will not be emitted. |
| 107 |
// EventsInclude has higher priority than EventsExclude. |
| 108 |
EventsExclude []filter.Config `mapstructure:"events_exclude"` |
| 109 |
{{- end }} |
| 110 |
|
| 111 |
enabledSetByUser bool |
| 112 |
} |
| 113 |
|
| 114 |
func (rac *ResourceAttributeConfig) Unmarshal(parser *confmap.Conf) error { |
| 115 |
if parser == nil { |
| 116 |
return nil |
| 117 |
} |
| 118 |
err := parser.Unmarshal(rac) |
| 119 |
if err != nil { |
| 120 |
return err |
| 121 |
} |
| 122 |
rac.enabledSetByUser = parser.IsSet("enabled") |
| 123 |
return nil |
| 124 |
} |
| 125 |
|
| 126 |
// ResourceAttributesConfig provides config for {{ .Type }} resource attributes. |
| 127 |
type ResourceAttributesConfig struct { |
| 128 |
{{- range $name, $attr := .ResourceAttributes }} |
| 129 |
{{ $name.Render }} ResourceAttributeConfig `mapstructure:"{{ $name }}"` |
| 130 |
{{- end }} |
| 131 |
} |
| 132 |
|
| 133 |
func DefaultResourceAttributesConfig() ResourceAttributesConfig { |
| 134 |
return ResourceAttributesConfig{ |
| 135 |
{{- range $name, $attr := .ResourceAttributes }} |
| 136 |
{{ $name.Render }}: ResourceAttributeConfig { |
| 137 |
Enabled: {{ $attr.Enabled }}, |
| 138 |
}, |
| 139 |
{{- end }} |
| 140 |
} |
| 141 |
} |
| 142 |
{{- end }} |
| 143 |
|
| 144 |
{{ if .Metrics -}} |
| 145 |
// MetricsBuilderConfig is a configuration for {{ .Type }} metrics builder. |
| 146 |
type MetricsBuilderConfig struct { |
| 147 |
Metrics MetricsConfig `mapstructure:"metrics"` |
| 148 |
{{- if .ResourceAttributes }} |
| 149 |
ResourceAttributes ResourceAttributesConfig `mapstructure:"resource_attributes"` |
| 150 |
{{- end }} |
| 151 |
} |
| 152 |
|
| 153 |
func DefaultMetricsBuilderConfig() MetricsBuilderConfig { |
| 154 |
return MetricsBuilderConfig { |
| 155 |
Metrics: DefaultMetricsConfig(), |
| 156 |
{{- if .ResourceAttributes }} |
| 157 |
ResourceAttributes: DefaultResourceAttributesConfig(), |
| 158 |
{{- end }} |
| 159 |
} |
| 160 |
} |
| 161 |
{{- end }} |
| 162 |
|
| 163 |
{{ if .Events -}} |
| 164 |
// LogsBuilderConfig is a configuration for {{ .Type }} logs builder. |
| 165 |
type LogsBuilderConfig struct { |
| 166 |
Events EventsConfig `mapstructure:"events"` |
| 167 |
{{- if .ResourceAttributes }} |
| 168 |
ResourceAttributes ResourceAttributesConfig `mapstructure:"resource_attributes"` |
| 169 |
{{- end }} |
| 170 |
} |
| 171 |
|
| 172 |
func DefaultLogsBuilderConfig() LogsBuilderConfig { |
| 173 |
return LogsBuilderConfig { |
| 174 |
Events: DefaultEventsConfig(), |
| 175 |
{{- if .ResourceAttributes }} |
| 176 |
ResourceAttributes: DefaultResourceAttributesConfig(), |
| 177 |
{{- end }} |
| 178 |
} |
| 179 |
} |
| 180 |
{{- end }} |