Skip to content

Commit 2a27159

Browse files
authored
[pkg/ottl] ottlarg struct tag cleanup (#26669)
**Description:** Removes all instances of `ottlarg`. Followup to #25705 **Link to tracking Issue:** <Issue number if applicable> #24874
1 parent d313210 commit 2a27159

21 files changed

+94
-67
lines changed

.chloggen/ottl-structtag-cleanup.yaml

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: pkg/ottl
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove support for `ottlarg`. The struct's field order is now the function parameter order.
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: [25705]
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]

internal/filter/filterottl/functions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func dropFn[K any]() (ottl.ExprFunc[K], error) {
7070
}
7171

7272
type hasAttributeOnDatapointArguments struct {
73-
Key string `ottlarg:"0"`
74-
ExpectedVal string `ottlarg:"1"`
73+
Key string
74+
ExpectedVal string
7575
}
7676

7777
func newHasAttributeOnDatapointFactory() ottl.Factory[ottlmetric.TransformContext] {
@@ -95,7 +95,7 @@ func hasAttributeOnDatapoint(key string, expectedVal string) (ottl.ExprFunc[ottl
9595
}
9696

9797
type hasAttributeKeyOnDatapointArguments struct {
98-
Key string `ottlarg:"0"`
98+
Key string
9999
}
100100

101101
func newHasAttributeKeyOnDatapointFactory() ottl.Factory[ottlmetric.TransformContext] {

pkg/ottl/expression_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ func Test_FunctionGetter(t *testing.T) {
703703
Function FunctionGetter[any]
704704
}
705705
type FuncArgs struct {
706-
Input StringGetter[any] `ottlarg:"0"`
706+
Input StringGetter[any]
707707
}
708708
tests := []struct {
709709
name string

pkg/ottl/functions_test.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ func functionWithErr() (ExprFunc[any], error) {
11911191
}
11921192

11931193
type stringSliceArguments struct {
1194-
Strings []string `ottlarg:"0"`
1194+
Strings []string
11951195
}
11961196

11971197
func functionWithStringSlice(strs []string) (ExprFunc[any], error) {
@@ -1201,7 +1201,7 @@ func functionWithStringSlice(strs []string) (ExprFunc[any], error) {
12011201
}
12021202

12031203
type floatSliceArguments struct {
1204-
Floats []float64 `ottlarg:"0"`
1204+
Floats []float64
12051205
}
12061206

12071207
func functionWithFloatSlice(floats []float64) (ExprFunc[interface{}], error) {
@@ -1211,7 +1211,7 @@ func functionWithFloatSlice(floats []float64) (ExprFunc[interface{}], error) {
12111211
}
12121212

12131213
type intSliceArguments struct {
1214-
Ints []int64 `ottlarg:"0"`
1214+
Ints []int64
12151215
}
12161216

12171217
func functionWithIntSlice(ints []int64) (ExprFunc[interface{}], error) {
@@ -1221,7 +1221,7 @@ func functionWithIntSlice(ints []int64) (ExprFunc[interface{}], error) {
12211221
}
12221222

12231223
type byteSliceArguments struct {
1224-
Bytes []byte `ottlarg:"0"`
1224+
Bytes []byte
12251225
}
12261226

12271227
func functionWithByteSlice(bytes []byte) (ExprFunc[interface{}], error) {
@@ -1231,7 +1231,7 @@ func functionWithByteSlice(bytes []byte) (ExprFunc[interface{}], error) {
12311231
}
12321232

12331233
type getterSliceArguments struct {
1234-
Getters []Getter[any] `ottlarg:"0"`
1234+
Getters []Getter[any]
12351235
}
12361236

12371237
func functionWithGetterSlice(getters []Getter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1241,7 +1241,7 @@ func functionWithGetterSlice(getters []Getter[interface{}]) (ExprFunc[interface{
12411241
}
12421242

12431243
type stringGetterSliceArguments struct {
1244-
StringGetters []StringGetter[any] `ottlarg:"0"`
1244+
StringGetters []StringGetter[any]
12451245
}
12461246

12471247
func functionWithStringGetterSlice(getters []StringGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1251,7 +1251,7 @@ func functionWithStringGetterSlice(getters []StringGetter[interface{}]) (ExprFun
12511251
}
12521252

12531253
type durationGetterSliceArguments struct {
1254-
DurationGetters []DurationGetter[any] `ottlarg:"0"`
1254+
DurationGetters []DurationGetter[any]
12551255
}
12561256

12571257
func functionWithDurationGetterSlice(_ []DurationGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1261,7 +1261,7 @@ func functionWithDurationGetterSlice(_ []DurationGetter[interface{}]) (ExprFunc[
12611261
}
12621262

12631263
type timeGetterSliceArguments struct {
1264-
TimeGetters []TimeGetter[any] `ottlarg:"0"`
1264+
TimeGetters []TimeGetter[any]
12651265
}
12661266

12671267
func functionWithTimeGetterSlice(_ []TimeGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1271,7 +1271,7 @@ func functionWithTimeGetterSlice(_ []TimeGetter[interface{}]) (ExprFunc[interfac
12711271
}
12721272

12731273
type floatGetterSliceArguments struct {
1274-
FloatGetters []FloatGetter[any] `ottlarg:"0"`
1274+
FloatGetters []FloatGetter[any]
12751275
}
12761276

12771277
func functionWithFloatGetterSlice(getters []FloatGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1281,7 +1281,7 @@ func functionWithFloatGetterSlice(getters []FloatGetter[interface{}]) (ExprFunc[
12811281
}
12821282

12831283
type intGetterSliceArguments struct {
1284-
IntGetters []IntGetter[any] `ottlarg:"0"`
1284+
IntGetters []IntGetter[any]
12851285
}
12861286

12871287
func functionWithIntGetterSlice(getters []IntGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1291,7 +1291,7 @@ func functionWithIntGetterSlice(getters []IntGetter[interface{}]) (ExprFunc[inte
12911291
}
12921292

12931293
type pMapGetterSliceArguments struct {
1294-
PMapGetters []PMapGetter[any] `ottlarg:"0"`
1294+
PMapGetters []PMapGetter[any]
12951295
}
12961296

12971297
func functionWithPMapGetterSlice(getters []PMapGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1301,7 +1301,7 @@ func functionWithPMapGetterSlice(getters []PMapGetter[interface{}]) (ExprFunc[in
13011301
}
13021302

13031303
type stringLikeGetterSliceArguments struct {
1304-
StringLikeGetters []StringLikeGetter[any] `ottlarg:"0"`
1304+
StringLikeGetters []StringLikeGetter[any]
13051305
}
13061306

13071307
func functionWithStringLikeGetterSlice(getters []StringLikeGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1311,7 +1311,7 @@ func functionWithStringLikeGetterSlice(getters []StringLikeGetter[interface{}])
13111311
}
13121312

13131313
type floatLikeGetterSliceArguments struct {
1314-
FloatLikeGetters []FloatLikeGetter[any] `ottlarg:"0"`
1314+
FloatLikeGetters []FloatLikeGetter[any]
13151315
}
13161316

13171317
func functionWithFloatLikeGetterSlice(getters []FloatLikeGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1321,7 +1321,7 @@ func functionWithFloatLikeGetterSlice(getters []FloatLikeGetter[interface{}]) (E
13211321
}
13221322

13231323
type intLikeGetterSliceArguments struct {
1324-
IntLikeGetters []IntLikeGetter[any] `ottlarg:"0"`
1324+
IntLikeGetters []IntLikeGetter[any]
13251325
}
13261326

13271327
func functionWithIntLikeGetterSlice(getters []IntLikeGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1331,7 +1331,7 @@ func functionWithIntLikeGetterSlice(getters []IntLikeGetter[interface{}]) (ExprF
13311331
}
13321332

13331333
type setterArguments struct {
1334-
SetterArg Setter[any] `ottlarg:"0"`
1334+
SetterArg Setter[any]
13351335
}
13361336

13371337
func functionWithSetter(Setter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1341,7 +1341,7 @@ func functionWithSetter(Setter[interface{}]) (ExprFunc[interface{}], error) {
13411341
}
13421342

13431343
type getSetterArguments struct {
1344-
GetSetterArg GetSetter[any] `ottlarg:"0"`
1344+
GetSetterArg GetSetter[any]
13451345
}
13461346

13471347
func functionWithGetSetter(GetSetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1351,7 +1351,7 @@ func functionWithGetSetter(GetSetter[interface{}]) (ExprFunc[interface{}], error
13511351
}
13521352

13531353
type getterArguments struct {
1354-
GetterArg Getter[any] `ottlarg:"0"`
1354+
GetterArg Getter[any]
13551355
}
13561356

13571357
func functionWithGetter(Getter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1361,7 +1361,7 @@ func functionWithGetter(Getter[interface{}]) (ExprFunc[interface{}], error) {
13611361
}
13621362

13631363
type stringGetterArguments struct {
1364-
StringGetterArg StringGetter[any] `ottlarg:"0"`
1364+
StringGetterArg StringGetter[any]
13651365
}
13661366

13671367
func functionWithStringGetter(StringGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1371,7 +1371,7 @@ func functionWithStringGetter(StringGetter[interface{}]) (ExprFunc[interface{}],
13711371
}
13721372

13731373
type durationGetterArguments struct {
1374-
DurationGetterArg DurationGetter[any] `ottlarg:"0"`
1374+
DurationGetterArg DurationGetter[any]
13751375
}
13761376

13771377
func functionWithDurationGetter(DurationGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1381,7 +1381,7 @@ func functionWithDurationGetter(DurationGetter[interface{}]) (ExprFunc[interface
13811381
}
13821382

13831383
type timeGetterArguments struct {
1384-
TimeGetterArg TimeGetter[any] `ottlarg:"0"`
1384+
TimeGetterArg TimeGetter[any]
13851385
}
13861386

13871387
func functionWithTimeGetter(TimeGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1391,7 +1391,7 @@ func functionWithTimeGetter(TimeGetter[interface{}]) (ExprFunc[interface{}], err
13911391
}
13921392

13931393
type functionGetterArguments struct {
1394-
FunctionGetterArg FunctionGetter[any] `ottlarg:"0"`
1394+
FunctionGetterArg FunctionGetter[any]
13951395
}
13961396

13971397
func functionWithFunctionGetter(FunctionGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1401,7 +1401,7 @@ func functionWithFunctionGetter(FunctionGetter[interface{}]) (ExprFunc[interface
14011401
}
14021402

14031403
type stringLikeGetterArguments struct {
1404-
StringLikeGetterArg StringLikeGetter[any] `ottlarg:"0"`
1404+
StringLikeGetterArg StringLikeGetter[any]
14051405
}
14061406

14071407
func functionWithStringLikeGetter(StringLikeGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1411,7 +1411,7 @@ func functionWithStringLikeGetter(StringLikeGetter[interface{}]) (ExprFunc[inter
14111411
}
14121412

14131413
type floatGetterArguments struct {
1414-
FloatGetterArg FloatGetter[any] `ottlarg:"0"`
1414+
FloatGetterArg FloatGetter[any]
14151415
}
14161416

14171417
func functionWithFloatGetter(FloatGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1421,7 +1421,7 @@ func functionWithFloatGetter(FloatGetter[interface{}]) (ExprFunc[interface{}], e
14211421
}
14221422

14231423
type floatLikeGetterArguments struct {
1424-
FloatLikeGetterArg FloatLikeGetter[any] `ottlarg:"0"`
1424+
FloatLikeGetterArg FloatLikeGetter[any]
14251425
}
14261426

14271427
func functionWithFloatLikeGetter(FloatLikeGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1431,7 +1431,7 @@ func functionWithFloatLikeGetter(FloatLikeGetter[interface{}]) (ExprFunc[interfa
14311431
}
14321432

14331433
type intGetterArguments struct {
1434-
IntGetterArg IntGetter[any] `ottlarg:"0"`
1434+
IntGetterArg IntGetter[any]
14351435
}
14361436

14371437
func functionWithIntGetter(IntGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1441,7 +1441,7 @@ func functionWithIntGetter(IntGetter[interface{}]) (ExprFunc[interface{}], error
14411441
}
14421442

14431443
type intLikeGetterArguments struct {
1444-
IntLikeGetterArg IntLikeGetter[any] `ottlarg:"0"`
1444+
IntLikeGetterArg IntLikeGetter[any]
14451445
}
14461446

14471447
func functionWithIntLikeGetter(IntLikeGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1451,7 +1451,7 @@ func functionWithIntLikeGetter(IntLikeGetter[interface{}]) (ExprFunc[interface{}
14511451
}
14521452

14531453
type pMapGetterArguments struct {
1454-
PMapArg PMapGetter[any] `ottlarg:"0"`
1454+
PMapArg PMapGetter[any]
14551455
}
14561456

14571457
func functionWithPMapGetter(PMapGetter[interface{}]) (ExprFunc[interface{}], error) {
@@ -1461,7 +1461,7 @@ func functionWithPMapGetter(PMapGetter[interface{}]) (ExprFunc[interface{}], err
14611461
}
14621462

14631463
type stringArguments struct {
1464-
StringArg string `ottlarg:"0"`
1464+
StringArg string
14651465
}
14661466

14671467
func functionWithString(string) (ExprFunc[interface{}], error) {
@@ -1471,7 +1471,7 @@ func functionWithString(string) (ExprFunc[interface{}], error) {
14711471
}
14721472

14731473
type floatArguments struct {
1474-
FloatArg float64 `ottlarg:"0"`
1474+
FloatArg float64
14751475
}
14761476

14771477
func functionWithFloat(float64) (ExprFunc[interface{}], error) {
@@ -1481,7 +1481,7 @@ func functionWithFloat(float64) (ExprFunc[interface{}], error) {
14811481
}
14821482

14831483
type intArguments struct {
1484-
IntArg int64 `ottlarg:"0"`
1484+
IntArg int64
14851485
}
14861486

14871487
func functionWithInt(int64) (ExprFunc[interface{}], error) {
@@ -1491,7 +1491,7 @@ func functionWithInt(int64) (ExprFunc[interface{}], error) {
14911491
}
14921492

14931493
type boolArguments struct {
1494-
BoolArg bool `ottlarg:"0"`
1494+
BoolArg bool
14951495
}
14961496

14971497
func functionWithBool(bool) (ExprFunc[interface{}], error) {
@@ -1501,10 +1501,10 @@ func functionWithBool(bool) (ExprFunc[interface{}], error) {
15011501
}
15021502

15031503
type multipleArgsArguments struct {
1504-
GetSetterArg GetSetter[any] `ottlarg:"0"`
1505-
StringArg string `ottlarg:"1"`
1506-
FloatArg float64 `ottlarg:"2"`
1507-
IntArg int64 `ottlarg:"3"`
1504+
GetSetterArg GetSetter[any]
1505+
StringArg string
1506+
FloatArg float64
1507+
IntArg int64
15081508
}
15091509

15101510
func functionWithMultipleArgs(GetSetter[interface{}], string, float64, int64) (ExprFunc[interface{}], error) {
@@ -1523,7 +1523,7 @@ func functionThatHasAnError() (ExprFunc[interface{}], error) {
15231523
}
15241524

15251525
type enumArguments struct {
1526-
EnumArg Enum `ottlarg:"0"`
1526+
EnumArg Enum
15271527
}
15281528

15291529
func functionWithEnum(Enum) (ExprFunc[interface{}], error) {

pkg/ottl/math_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func testDuration[K any](duration string) (ExprFunc[K], error) {
8383
}
8484

8585
type sumArguments struct {
86-
Ints []int64 `ottlarg:"0"`
86+
Ints []int64
8787
}
8888

8989
//nolint:unparam
@@ -514,11 +514,11 @@ func Test_evaluateMathExpression_error(t *testing.T) {
514514
createFactory("threePointOne", &struct{}{}, threePointOne[any]),
515515
createFactory("sum", &sumArguments{}, sum[any]),
516516
createFactory("Time", &struct {
517-
Time string `ottlarg:"0"`
518-
Format string `ottlarg:"1"`
517+
Time string
518+
Format string
519519
}{}, testTime[any]),
520520
createFactory("Duration", &struct {
521-
Duration string `ottlarg:"0"`
521+
Duration string
522522
}{}, testDuration[any]),
523523
)
524524

@@ -564,11 +564,11 @@ func Test_evaluateMathExpression_error(t *testing.T) {
564564
func Test_evaluateMathExpressionTimeDuration(t *testing.T) {
565565
functions := CreateFactoryMap(
566566
createFactory("Time", &struct {
567-
Time string `ottlarg:"0"`
568-
Format string `ottlarg:"1"`
567+
Time string
568+
Format string
569569
}{}, testTime[any]),
570570
createFactory("Duration", &struct {
571-
Duration string `ottlarg:"0"`
571+
Duration string
572572
}{}, testDuration[any]),
573573
)
574574

0 commit comments

Comments
 (0)