@@ -145,11 +145,11 @@ func TestConfigYaml(t *testing.T) {
145
145
"insights" : "yeah!" ,
146
146
},
147
147
},
148
- Pipelines : AnyConfig {
149
- Object : map [ string ] interface {} {
150
- "receivers" : []string {"otlp" },
151
- "processors" : []string {"modify_2000" },
152
- "exporters" : []string {"otlp/exporter" , "con" },
148
+ Pipelines : map [ string ] * Pipeline {
149
+ "traces" : {
150
+ Receivers : []string {"otlp" },
151
+ Processors : []string {"modify_2000" },
152
+ Exporters : []string {"otlp/exporter" , "con" },
153
153
},
154
154
},
155
155
},
@@ -173,13 +173,14 @@ service:
173
173
telemetry:
174
174
insights: yeah!
175
175
pipelines:
176
- exporters:
177
- - otlp/exporter
178
- - con
179
- processors:
180
- - modify_2000
181
- receivers:
182
- - otlp
176
+ traces:
177
+ exporters:
178
+ - otlp/exporter
179
+ - con
180
+ processors:
181
+ - modify_2000
182
+ receivers:
183
+ - otlp
183
184
`
184
185
185
186
assert .Equal (t , expected , yamlCollector )
@@ -278,3 +279,109 @@ func TestConfigToMetricsPort(t *testing.T) {
278
279
})
279
280
}
280
281
}
282
+
283
+ func TestConfig_GetEnabledComponents (t * testing.T ) {
284
+ tests := []struct {
285
+ name string
286
+ file string
287
+ want map [ComponentType ]map [string ]interface {}
288
+ }{
289
+
290
+ {
291
+ name : "connectors" ,
292
+ file : "testdata/otelcol-connectors.yaml" ,
293
+ want : map [ComponentType ]map [string ]interface {}{
294
+ ComponentTypeReceiver : {
295
+ "foo" : struct {}{},
296
+ "count" : struct {}{},
297
+ },
298
+ ComponentTypeProcessor : {},
299
+ ComponentTypeExporter : {
300
+ "bar" : struct {}{},
301
+ "count" : struct {}{},
302
+ },
303
+ },
304
+ },
305
+ {
306
+ name : "couchbase" ,
307
+ file : "testdata/otelcol-couchbase.yaml" ,
308
+ want : map [ComponentType ]map [string ]interface {}{
309
+ ComponentTypeReceiver : {
310
+ "prometheus/couchbase" : struct {}{},
311
+ },
312
+ ComponentTypeProcessor : {
313
+ "filter/couchbase" : struct {}{},
314
+ "metricstransform/couchbase" : struct {}{},
315
+ "transform/couchbase" : struct {}{},
316
+ },
317
+ ComponentTypeExporter : {
318
+ "prometheus" : struct {}{},
319
+ },
320
+ },
321
+ },
322
+ {
323
+ name : "demo" ,
324
+ file : "testdata/otelcol-demo.yaml" ,
325
+ want : map [ComponentType ]map [string ]interface {}{
326
+ ComponentTypeReceiver : {
327
+ "otlp" : struct {}{},
328
+ },
329
+ ComponentTypeProcessor : {
330
+ "batch" : struct {}{},
331
+ },
332
+ ComponentTypeExporter : {
333
+ "debug" : struct {}{},
334
+ "zipkin" : struct {}{},
335
+ "otlp" : struct {}{},
336
+ "prometheus" : struct {}{},
337
+ },
338
+ },
339
+ },
340
+ {
341
+ name : "extensions" ,
342
+ file : "testdata/otelcol-extensions.yaml" ,
343
+ want : map [ComponentType ]map [string ]interface {}{
344
+ ComponentTypeReceiver : {
345
+ "otlp" : struct {}{},
346
+ },
347
+ ComponentTypeProcessor : {},
348
+ ComponentTypeExporter : {
349
+ "otlp/auth" : struct {}{},
350
+ },
351
+ },
352
+ },
353
+ {
354
+ name : "filelog" ,
355
+ file : "testdata/otelcol-filelog.yaml" ,
356
+ want : map [ComponentType ]map [string ]interface {}{
357
+ ComponentTypeReceiver : {
358
+ "filelog" : struct {}{},
359
+ },
360
+ ComponentTypeProcessor : {},
361
+ ComponentTypeExporter : {
362
+ "debug" : struct {}{},
363
+ },
364
+ },
365
+ },
366
+ {
367
+ name : "null" ,
368
+ file : "testdata/otelcol-null-values.yaml" ,
369
+ want : map [ComponentType ]map [string ]interface {}{
370
+ ComponentTypeReceiver : {},
371
+ ComponentTypeProcessor : {},
372
+ ComponentTypeExporter : {},
373
+ },
374
+ },
375
+ }
376
+ for _ , tt := range tests {
377
+ t .Run (tt .name , func (t * testing.T ) {
378
+ collectorYaml , err := os .ReadFile (tt .file )
379
+ require .NoError (t , err )
380
+
381
+ c := & Config {}
382
+ err = go_yaml .Unmarshal (collectorYaml , c )
383
+ require .NoError (t , err )
384
+ assert .Equalf (t , tt .want , c .GetEnabledComponents (), "GetEnabledComponents()" )
385
+ })
386
+ }
387
+ }
0 commit comments