@@ -21,6 +21,25 @@ import (
21
21
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor/internal/metadata"
22
22
)
23
23
24
+ func assertConfigContainsDefaultFunctions (t * testing.T , config Config ) {
25
+ t .Helper ()
26
+ for _ , f := range DefaultLogFunctions () {
27
+ assert .Contains (t , config .logFunctions , f .Name (), "missing log function %v" , f .Name ())
28
+ }
29
+ for _ , f := range DefaultDataPointFunctions () {
30
+ assert .Contains (t , config .dataPointFunctions , f .Name (), "missing data point function %v" , f .Name ())
31
+ }
32
+ for _ , f := range DefaultMetricFunctions () {
33
+ assert .Contains (t , config .metricFunctions , f .Name (), "missing metric function %v" , f .Name ())
34
+ }
35
+ for _ , f := range DefaultSpanFunctions () {
36
+ assert .Contains (t , config .spanFunctions , f .Name (), "missing span function %v" , f .Name ())
37
+ }
38
+ for _ , f := range DefaultSpanEventFunctions () {
39
+ assert .Contains (t , config .spanEventFunctions , f .Name (), "missing span event function %v" , f .Name ())
40
+ }
41
+ }
42
+
24
43
// TestLoadingConfigRegexp tests loading testdata/config_strict.yaml
25
44
func TestLoadingConfigStrict (t * testing.T ) {
26
45
// list of filters used repeatedly on testdata/config_strict.yaml
@@ -91,7 +110,8 @@ func TestLoadingConfigStrict(t *testing.T) {
91
110
require .NoError (t , sub .Unmarshal (cfg ))
92
111
93
112
assert .NoError (t , xconfmap .Validate (cfg ))
94
- assert .Equal (t , tt .expected , cfg )
113
+ assert .EqualExportedValues (t , tt .expected , cfg )
114
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
95
115
})
96
116
}
97
117
}
@@ -173,7 +193,8 @@ func TestLoadingConfigStrictLogs(t *testing.T) {
173
193
require .NoError (t , sub .Unmarshal (cfg ))
174
194
175
195
assert .NoError (t , xconfmap .Validate (cfg ))
176
- assert .Equal (t , tt .expected , cfg )
196
+ assert .EqualExportedValues (t , tt .expected , cfg )
197
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
177
198
})
178
199
}
179
200
}
@@ -235,7 +256,8 @@ func TestLoadingConfigSeverityLogsStrict(t *testing.T) {
235
256
require .NoError (t , sub .Unmarshal (cfg ))
236
257
237
258
assert .NoError (t , xconfmap .Validate (cfg ))
238
- assert .Equal (t , tt .expected , cfg )
259
+ assert .EqualExportedValues (t , tt .expected , cfg )
260
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
239
261
})
240
262
}
241
263
}
@@ -297,7 +319,8 @@ func TestLoadingConfigSeverityLogsRegexp(t *testing.T) {
297
319
require .NoError (t , sub .Unmarshal (cfg ))
298
320
299
321
assert .NoError (t , xconfmap .Validate (cfg ))
300
- assert .Equal (t , tt .expected , cfg )
322
+ assert .EqualExportedValues (t , tt .expected , cfg )
323
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
301
324
})
302
325
}
303
326
}
@@ -359,7 +382,8 @@ func TestLoadingConfigBodyLogsStrict(t *testing.T) {
359
382
require .NoError (t , sub .Unmarshal (cfg ))
360
383
361
384
assert .NoError (t , xconfmap .Validate (cfg ))
362
- assert .Equal (t , tt .expected , cfg )
385
+ assert .EqualExportedValues (t , tt .expected , cfg )
386
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
363
387
})
364
388
}
365
389
}
@@ -421,7 +445,8 @@ func TestLoadingConfigBodyLogsRegexp(t *testing.T) {
421
445
require .NoError (t , sub .Unmarshal (cfg ))
422
446
423
447
assert .NoError (t , xconfmap .Validate (cfg ))
424
- assert .Equal (t , tt .expected , cfg )
448
+ assert .EqualExportedValues (t , tt .expected , cfg )
449
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
425
450
})
426
451
}
427
452
}
@@ -486,7 +511,8 @@ func TestLoadingConfigMinSeverityNumberLogs(t *testing.T) {
486
511
require .NoError (t , sub .Unmarshal (cfg ))
487
512
488
513
assert .NoError (t , xconfmap .Validate (cfg ))
489
- assert .Equal (t , tt .expected , cfg )
514
+ assert .EqualExportedValues (t , tt .expected , cfg )
515
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
490
516
})
491
517
}
492
518
}
@@ -575,7 +601,8 @@ func TestLoadingConfigRegexp(t *testing.T) {
575
601
require .NoError (t , sub .Unmarshal (cfg ))
576
602
577
603
assert .NoError (t , xconfmap .Validate (cfg ))
578
- assert .Equal (t , tt .expected , cfg )
604
+ assert .EqualExportedValues (t , tt .expected , cfg )
605
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
579
606
})
580
607
}
581
608
}
@@ -625,7 +652,8 @@ func TestLoadingSpans(t *testing.T) {
625
652
require .NoError (t , sub .Unmarshal (cfg ))
626
653
627
654
assert .NoError (t , xconfmap .Validate (cfg ))
628
- assert .Equal (t , tt .expected , cfg )
655
+ assert .EqualExportedValues (t , tt .expected , cfg )
656
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
629
657
})
630
658
}
631
659
}
@@ -710,7 +738,8 @@ func TestLoadingConfigExpr(t *testing.T) {
710
738
require .NoError (t , sub .Unmarshal (cfg ))
711
739
712
740
assert .NoError (t , xconfmap .Validate (cfg ))
713
- assert .Equal (t , tt .expected , cfg )
741
+ assert .EqualExportedValues (t , tt .expected , cfg )
742
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
714
743
})
715
744
}
716
745
}
@@ -922,7 +951,8 @@ func TestLoadingConfigOTTL(t *testing.T) {
922
951
}
923
952
} else {
924
953
assert .NoError (t , xconfmap .Validate (cfg ))
925
- assert .Equal (t , tt .expected , cfg )
954
+ assert .EqualExportedValues (t , tt .expected , cfg )
955
+ assertConfigContainsDefaultFunctions (t , * cfg .(* Config ))
926
956
}
927
957
})
928
958
}
0 commit comments