Skip to content

Commit cd57e0f

Browse files
committed
[processor/metricstransformprocessor] unexport elements of the Go API
1 parent 88c3006 commit cd57e0f

9 files changed

+255
-228
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: metricstransformprocessor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Unexport elements of the Go API of the processor
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [24846]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [api]

processor/metricstransformprocessor/config.go

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,49 @@
44
package metricstransformprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/metricstransformprocessor"
55

66
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"
99

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"
1212

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"
1515

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"
1818

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"
2121

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"
2424

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"
2727

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"
3030

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"
3333

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"
3636

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"
3939
)
4040

4141
// Config defines configuration for Resource processor.
4242
type Config struct {
4343

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"`
4646
}
4747

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 {
5050

5151
// --- SPECIFY WHICH METRIC(S) TO MATCH ---
5252

@@ -75,10 +75,10 @@ type Transform struct {
7575

7676
// AggregationType specifies how to aggregate.
7777
// REQUIRED only if Action is COMBINE.
78-
AggregationType AggregationType `mapstructure:"aggregation_type"`
78+
AggregationType aggregationType `mapstructure:"aggregation_type"`
7979

8080
// 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"`
8282

8383
// Operations contains a list of operations that will be performed on the resulting metric(s).
8484
Operations []Operation `mapstructure:"operations"`
@@ -89,7 +89,7 @@ type FilterConfig struct {
8989
Include string `mapstructure:"include"`
9090

9191
// MatchType determines how the Include string is matched: <strict|regexp>.
92-
MatchType MatchType `mapstructure:"match_type"`
92+
MatchType matchType `mapstructure:"match_type"`
9393

9494
// MatchLabels specifies the label set against which the metric filter will work.
9595
// This field is optional.
@@ -100,7 +100,7 @@ type FilterConfig struct {
100100
type Operation struct {
101101
// Action specifies the action performed for this operation.
102102
// REQUIRED
103-
Action OperationAction `mapstructure:"action"`
103+
Action operationAction `mapstructure:"action"`
104104

105105
// Label identifies the exact label to operate on.
106106
Label string `mapstructure:"label"`
@@ -112,12 +112,12 @@ type Operation struct {
112112
LabelSet []string `mapstructure:"label_set"`
113113

114114
// AggregationType specifies how to aggregate.
115-
AggregationType AggregationType `mapstructure:"aggregation_type"`
115+
AggregationType aggregationType `mapstructure:"aggregation_type"`
116116

117117
// AggregatedValues is a list of label values to aggregate away.
118118
AggregatedValues []string `mapstructure:"aggregated_values"`
119119

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`.
121121
NewValue string `mapstructure:"new_value"`
122122

123123
// ValueActions is a list of renaming actions for label values.
@@ -168,45 +168,45 @@ func (ca ConfigAction) isValid() bool {
168168
return false
169169
}
170170

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
173173

174174
const (
175-
// AddLabel adds a new label to an existing metric.
175+
// addLabel adds a new label to an existing metric.
176176
// Metric has to match the FilterConfig with all its data points if used with Update ConfigAction,
177177
// otherwise the operation will be ignored.
178-
AddLabel OperationAction = "add_label"
178+
addLabel operationAction = "add_label"
179179

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"
182182

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
184184
// Metric has to match the FilterConfig with all its data points if used with Update ConfigAction,
185185
// otherwise the operation will be ignored.
186-
DeleteLabelValue OperationAction = "delete_label_value"
186+
deleteLabelValue operationAction = "delete_label_value"
187187

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"
190190

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"
193193

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
195195
// by the method indicated by Operation.AggregationType.
196196
// Metric has to match the FilterConfig with all its data points if used with Update ConfigAction,
197197
// otherwise the operation will be ignored.
198-
AggregateLabels OperationAction = "aggregate_labels"
198+
aggregateLabels operationAction = "aggregate_labels"
199199

200-
// AggregateLabelValues aggregates away the values in Operation.AggregatedValues
200+
// aggregateLabelValues aggregates away the values in Operation.AggregatedValues
201201
// by the method indicated by Operation.AggregationType.
202202
// Metric has to match the FilterConfig with all its data points if used with Update ConfigAction,
203203
// otherwise the operation will be ignored.
204-
AggregateLabelValues OperationAction = "aggregate_label_values"
204+
aggregateLabelValues operationAction = "aggregate_label_values"
205205
)
206206

207-
var operationActions = []OperationAction{AddLabel, UpdateLabel, DeleteLabelValue, ToggleScalarDataType, ScaleValue, AggregateLabels, AggregateLabelValues}
207+
var operationActions = []operationAction{addLabel, updateLabel, deleteLabelValue, toggleScalarDataType, scaleValue, aggregateLabels, aggregateLabelValues}
208208

209-
func (oa OperationAction) isValid() bool {
209+
func (oa operationAction) isValid() bool {
210210
for _, operationAction := range operationActions {
211211
if oa == operationAction {
212212
return true
@@ -216,26 +216,26 @@ func (oa OperationAction) isValid() bool {
216216
return false
217217
}
218218

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
221221

222222
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"
225225

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"
228228

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"
231231

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"
234234
)
235235

236-
var aggregationTypes = []AggregationType{Sum, Mean, Min, Max}
236+
var aggregationTypes = []aggregationType{sum, mean, min, max}
237237

238-
func (at AggregationType) isValid() bool {
238+
func (at aggregationType) isValid() bool {
239239
for _, aggregationType := range aggregationTypes {
240240
if at == aggregationType {
241241
return true
@@ -245,20 +245,20 @@ func (at AggregationType) isValid() bool {
245245
return false
246246
}
247247

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
250250

251251
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"
254254

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"
257257
)
258258

259-
var matchTypes = []MatchType{StrictMatchType, RegexpMatchType}
259+
var matchTypes = []matchType{strictMatchType, regexpMatchType}
260260

261-
func (mt MatchType) isValid() bool {
261+
func (mt matchType) isValid() bool {
262262
for _, matchType := range matchTypes {
263263
if mt == matchType {
264264
return true
@@ -268,20 +268,20 @@ func (mt MatchType) isValid() bool {
268268
return false
269269
}
270270

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
273273

274274
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"
277277

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"
280280
)
281281

282-
var submatchCases = []SubmatchCase{Lower, Upper}
282+
var submatchCases = []submatchCase{lower, upper}
283283

284-
func (sc SubmatchCase) isValid() bool {
284+
func (sc submatchCase) isValid() bool {
285285
for _, submatchCase := range submatchCases {
286286
if sc == submatchCase {
287287
return true

processor/metricstransformprocessor/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TestLoadConfig(t *testing.T) {
2525
configFile: "config_full.yaml",
2626
id: component.NewID(metadata.Type),
2727
expected: &Config{
28-
Transforms: []Transform{
28+
Transforms: []transform{
2929
{
3030
MetricIncludeFilter: FilterConfig{
3131
Include: "name",
@@ -41,7 +41,7 @@ func TestLoadConfig(t *testing.T) {
4141
configFile: "config_full.yaml",
4242
id: component.NewIDWithName(metadata.Type, "multiple"),
4343
expected: &Config{
44-
Transforms: []Transform{
44+
Transforms: []transform{
4545
{
4646
MetricIncludeFilter: FilterConfig{
4747
Include: "name1",

0 commit comments

Comments
 (0)