4
4
package metricstransformprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/metricstransformprocessor"
5
5
6
6
const (
7
- // IncludeFieldName is the mapstructure field name for Include field
8
- IncludeFieldName = "include"
7
+ // includeFieldName is the mapstructure field name for Include field
8
+ includeFieldName = "include"
9
9
10
- // MatchTypeFieldName is the mapstructure field name for MatchType field
11
- MatchTypeFieldName = "match_type"
10
+ // matchTypeFieldName is the mapstructure field name for matchType field
11
+ matchTypeFieldName = "match_type"
12
12
13
- // ActionFieldName is the mapstructure field name for Action field
14
- ActionFieldName = "action"
13
+ // actionFieldName is the mapstructure field name for Action field
14
+ actionFieldName = "action"
15
15
16
- // NewNameFieldName is the mapstructure field name for NewName field
17
- NewNameFieldName = "new_name"
16
+ // newNameFieldName is the mapstructure field name for NewName field
17
+ newNameFieldName = "new_name"
18
18
19
- // GroupResourceLabelsFieldName is the mapstructure field name for GroupResouceLabels field
20
- GroupResourceLabelsFieldName = "group_resource_labels"
19
+ // groupResourceLabelsFieldName is the mapstructure field name for GroupResouceLabels field
20
+ groupResourceLabelsFieldName = "group_resource_labels"
21
21
22
- // AggregationTypeFieldName is the mapstructure field name for AggregationType field
23
- AggregationTypeFieldName = "aggregation_type"
22
+ // aggregationTypeFieldName is the mapstructure field name for aggregationType field
23
+ aggregationTypeFieldName = "aggregation_type"
24
24
25
- // LabelFieldName is the mapstructure field name for Label field
26
- LabelFieldName = "label"
25
+ // labelFieldName is the mapstructure field name for Label field
26
+ labelFieldName = "label"
27
27
28
- // NewLabelFieldName is the mapstructure field name for NewLabel field
29
- NewLabelFieldName = "new_label"
28
+ // newLabelFieldName is the mapstructure field name for NewLabel field
29
+ newLabelFieldName = "new_label"
30
30
31
- // NewValueFieldName is the mapstructure field name for NewValue field
32
- NewValueFieldName = "new_value"
31
+ // newValueFieldName is the mapstructure field name for NewValue field
32
+ newValueFieldName = "new_value"
33
33
34
- // ScaleFieldName is the mapstructure field name for Scale field
35
- ScaleFieldName = "experimental_scale"
34
+ // scaleFieldName is the mapstructure field name for Scale field
35
+ scaleFieldName = "experimental_scale"
36
36
37
- // SubmatchCaseFieldName is the mapstructure field name for SubmatchCase field
38
- SubmatchCaseFieldName = "submatch_case"
37
+ // submatchCaseFieldName is the mapstructure field name for submatchCase field
38
+ submatchCaseFieldName = "submatch_case"
39
39
)
40
40
41
41
// Config defines configuration for Resource processor.
42
42
type Config struct {
43
43
44
- // Transform specifies a list of transforms on metrics with each transform focusing on one metric.
45
- Transforms []Transform `mapstructure:"transforms"`
44
+ // transform specifies a list of transforms on metrics with each transform focusing on one metric.
45
+ Transforms []transform `mapstructure:"transforms"`
46
46
}
47
47
48
- // Transform defines the transformation applied to the specific metric
49
- type Transform struct {
48
+ // transform defines the transformation applied to the specific metric
49
+ type transform struct {
50
50
51
51
// --- SPECIFY WHICH METRIC(S) TO MATCH ---
52
52
@@ -75,10 +75,10 @@ type Transform struct {
75
75
76
76
// AggregationType specifies how to aggregate.
77
77
// REQUIRED only if Action is COMBINE.
78
- AggregationType AggregationType `mapstructure:"aggregation_type"`
78
+ AggregationType aggregationType `mapstructure:"aggregation_type"`
79
79
80
80
// SubmatchCase specifies what case to use for label values created from regexp submatches.
81
- SubmatchCase SubmatchCase `mapstructure:"submatch_case"`
81
+ SubmatchCase submatchCase `mapstructure:"submatch_case"`
82
82
83
83
// Operations contains a list of operations that will be performed on the resulting metric(s).
84
84
Operations []Operation `mapstructure:"operations"`
@@ -89,7 +89,7 @@ type FilterConfig struct {
89
89
Include string `mapstructure:"include"`
90
90
91
91
// MatchType determines how the Include string is matched: <strict|regexp>.
92
- MatchType MatchType `mapstructure:"match_type"`
92
+ MatchType matchType `mapstructure:"match_type"`
93
93
94
94
// MatchLabels specifies the label set against which the metric filter will work.
95
95
// This field is optional.
@@ -100,7 +100,7 @@ type FilterConfig struct {
100
100
type Operation struct {
101
101
// Action specifies the action performed for this operation.
102
102
// REQUIRED
103
- Action OperationAction `mapstructure:"action"`
103
+ Action operationAction `mapstructure:"action"`
104
104
105
105
// Label identifies the exact label to operate on.
106
106
Label string `mapstructure:"label"`
@@ -112,12 +112,12 @@ type Operation struct {
112
112
LabelSet []string `mapstructure:"label_set"`
113
113
114
114
// AggregationType specifies how to aggregate.
115
- AggregationType AggregationType `mapstructure:"aggregation_type"`
115
+ AggregationType aggregationType `mapstructure:"aggregation_type"`
116
116
117
117
// AggregatedValues is a list of label values to aggregate away.
118
118
AggregatedValues []string `mapstructure:"aggregated_values"`
119
119
120
- // NewValue is used to set a new label value either when the operation is `AggregatedValues` or `AddLabel `.
120
+ // NewValue is used to set a new label value either when the operation is `AggregatedValues` or `addLabel `.
121
121
NewValue string `mapstructure:"new_value"`
122
122
123
123
// ValueActions is a list of renaming actions for label values.
@@ -168,45 +168,45 @@ func (ca ConfigAction) isValid() bool {
168
168
return false
169
169
}
170
170
171
- // OperationAction is the enum to capture the thress types of actions to perform for an operation.
172
- type OperationAction string
171
+ // operationAction is the enum to capture the thress types of actions to perform for an operation.
172
+ type operationAction string
173
173
174
174
const (
175
- // AddLabel adds a new label to an existing metric.
175
+ // addLabel adds a new label to an existing metric.
176
176
// Metric has to match the FilterConfig with all its data points if used with Update ConfigAction,
177
177
// otherwise the operation will be ignored.
178
- AddLabel OperationAction = "add_label"
178
+ addLabel operationAction = "add_label"
179
179
180
- // UpdateLabel applies name changes to label and/or label values.
181
- UpdateLabel OperationAction = "update_label"
180
+ // updateLabel applies name changes to label and/or label values.
181
+ updateLabel operationAction = "update_label"
182
182
183
- // DeleteLabelValue deletes a label value by also removing all the points associated with this label value
183
+ // deleteLabelValue deletes a label value by also removing all the points associated with this label value
184
184
// Metric has to match the FilterConfig with all its data points if used with Update ConfigAction,
185
185
// otherwise the operation will be ignored.
186
- DeleteLabelValue OperationAction = "delete_label_value"
186
+ deleteLabelValue operationAction = "delete_label_value"
187
187
188
- // ToggleScalarDataType changes the data type from int64 to double, or vice-versa
189
- ToggleScalarDataType OperationAction = "toggle_scalar_data_type"
188
+ // toggleScalarDataType changes the data type from int64 to double, or vice-versa
189
+ toggleScalarDataType operationAction = "toggle_scalar_data_type"
190
190
191
- // ScaleValue multiplies the value by a constant scalar
192
- ScaleValue OperationAction = "experimental_scale_value"
191
+ // scaleValue multiplies the value by a constant scalar
192
+ scaleValue operationAction = "experimental_scale_value"
193
193
194
- // AggregateLabels aggregates away all labels other than the ones in Operation.LabelSet
194
+ // aggregateLabels aggregates away all labels other than the ones in Operation.LabelSet
195
195
// by the method indicated by Operation.AggregationType.
196
196
// Metric has to match the FilterConfig with all its data points if used with Update ConfigAction,
197
197
// otherwise the operation will be ignored.
198
- AggregateLabels OperationAction = "aggregate_labels"
198
+ aggregateLabels operationAction = "aggregate_labels"
199
199
200
- // AggregateLabelValues aggregates away the values in Operation.AggregatedValues
200
+ // aggregateLabelValues aggregates away the values in Operation.AggregatedValues
201
201
// by the method indicated by Operation.AggregationType.
202
202
// Metric has to match the FilterConfig with all its data points if used with Update ConfigAction,
203
203
// otherwise the operation will be ignored.
204
- AggregateLabelValues OperationAction = "aggregate_label_values"
204
+ aggregateLabelValues operationAction = "aggregate_label_values"
205
205
)
206
206
207
- var operationActions = []OperationAction { AddLabel , UpdateLabel , DeleteLabelValue , ToggleScalarDataType , ScaleValue , AggregateLabels , AggregateLabelValues }
207
+ var operationActions = []operationAction { addLabel , updateLabel , deleteLabelValue , toggleScalarDataType , scaleValue , aggregateLabels , aggregateLabelValues }
208
208
209
- func (oa OperationAction ) isValid () bool {
209
+ func (oa operationAction ) isValid () bool {
210
210
for _ , operationAction := range operationActions {
211
211
if oa == operationAction {
212
212
return true
@@ -216,26 +216,26 @@ func (oa OperationAction) isValid() bool {
216
216
return false
217
217
}
218
218
219
- // AggregationType is the enum to capture the three types of aggregation for the aggregation operation.
220
- type AggregationType string
219
+ // aggregationType is the enum to capture the three types of aggregation for the aggregation operation.
220
+ type aggregationType string
221
221
222
222
const (
223
- // Sum indicates taking the sum of the aggregated data.
224
- Sum AggregationType = "sum"
223
+ // sum indicates taking the sum of the aggregated data.
224
+ sum aggregationType = "sum"
225
225
226
- // Mean indicates taking the mean of the aggregated data.
227
- Mean AggregationType = "mean"
226
+ // mean indicates taking the mean of the aggregated data.
227
+ mean aggregationType = "mean"
228
228
229
- // Min indicates taking the minimum of the aggregated data.
230
- Min AggregationType = "min"
229
+ // min indicates taking the minimum of the aggregated data.
230
+ min aggregationType = "min"
231
231
232
- // Max indicates taking the max of the aggregated data.
233
- Max AggregationType = "max"
232
+ // max indicates taking the max of the aggregated data.
233
+ max aggregationType = "max"
234
234
)
235
235
236
- var aggregationTypes = []AggregationType { Sum , Mean , Min , Max }
236
+ var aggregationTypes = []aggregationType { sum , mean , min , max }
237
237
238
- func (at AggregationType ) isValid () bool {
238
+ func (at aggregationType ) isValid () bool {
239
239
for _ , aggregationType := range aggregationTypes {
240
240
if at == aggregationType {
241
241
return true
@@ -245,20 +245,20 @@ func (at AggregationType) isValid() bool {
245
245
return false
246
246
}
247
247
248
- // MatchType is the enum to capture the two types of matching metric(s) that should have operations applied to them.
249
- type MatchType string
248
+ // matchType is the enum to capture the two types of matching metric(s) that should have operations applied to them.
249
+ type matchType string
250
250
251
251
const (
252
- // StrictMatchType is the FilterType for filtering by exact string matches.
253
- StrictMatchType MatchType = "strict"
252
+ // strictMatchType is the FilterType for filtering by exact string matches.
253
+ strictMatchType matchType = "strict"
254
254
255
- // RegexpMatchType is the FilterType for filtering by regexp string matches.
256
- RegexpMatchType MatchType = "regexp"
255
+ // regexpMatchType is the FilterType for filtering by regexp string matches.
256
+ regexpMatchType matchType = "regexp"
257
257
)
258
258
259
- var matchTypes = []MatchType { StrictMatchType , RegexpMatchType }
259
+ var matchTypes = []matchType { strictMatchType , regexpMatchType }
260
260
261
- func (mt MatchType ) isValid () bool {
261
+ func (mt matchType ) isValid () bool {
262
262
for _ , matchType := range matchTypes {
263
263
if mt == matchType {
264
264
return true
@@ -268,20 +268,20 @@ func (mt MatchType) isValid() bool {
268
268
return false
269
269
}
270
270
271
- // SubmatchCase is the enum to capture the two types of case changes to apply to submatches.
272
- type SubmatchCase string
271
+ // submatchCase is the enum to capture the two types of case changes to apply to submatches.
272
+ type submatchCase string
273
273
274
274
const (
275
- // Lower is the SubmatchCase for lower casing the submatch.
276
- Lower SubmatchCase = "lower"
275
+ // lower is the submatchCase for lower casing the submatch.
276
+ lower submatchCase = "lower"
277
277
278
- // Upper is the SubmatchCase for upper casing the submatch.
279
- Upper SubmatchCase = "upper"
278
+ // upper is the submatchCase for upper casing the submatch.
279
+ upper submatchCase = "upper"
280
280
)
281
281
282
- var submatchCases = []SubmatchCase { Lower , Upper }
282
+ var submatchCases = []submatchCase { lower , upper }
283
283
284
- func (sc SubmatchCase ) isValid () bool {
284
+ func (sc submatchCase ) isValid () bool {
285
285
for _ , submatchCase := range submatchCases {
286
286
if sc == submatchCase {
287
287
return true
0 commit comments