@@ -339,3 +339,77 @@ func TestTranslatorMetricsForECS(t *testing.T) {
339339 })
340340 }
341341}
342+
343+ func TestTranslatorLogs (t * testing.T ) {
344+ type want struct {
345+ receivers []string
346+ processors []string
347+ exporters []string
348+ extensions []string
349+ }
350+ tt := NewTranslator (pipeline .SignalLogs )
351+ assert .EqualValues (t , "logs/application_signals" , tt .ID ().String ())
352+ testCases := map [string ]struct {
353+ input map [string ]interface {}
354+ want * want
355+ wantErr error
356+ isEKSCache func () eksdetector.IsEKSCache
357+ }{
358+ "WithoutLogsCollectedKey" : {
359+ input : map [string ]interface {}{},
360+ wantErr : & common.MissingKeyError {ID : tt .ID (), JsonKey : fmt .Sprint (common .AppSignalsLogs )},
361+ },
362+ "WithAppSignalsEnabledLogs" : {
363+ input : map [string ]interface {}{
364+ "logs" : map [string ]interface {}{
365+ "logs_collected" : map [string ]interface {}{
366+ "application_signals" : map [string ]interface {}{},
367+ },
368+ },
369+ },
370+ want : & want {
371+ receivers : []string {"otlp/grpc_0_0_0_0_4315" , "otlp/http_0_0_0_0_4316" },
372+ processors : []string {},
373+ exporters : []string {"otlphttp/application_signals" },
374+ extensions : []string {"sigv4auth" , "agenthealth/logs" , "agenthealth/statuscode" },
375+ },
376+ isEKSCache : eksdetector .TestIsEKSCacheEKS ,
377+ },
378+ "WithAppSignalsLogsAndDebug" : {
379+ input : map [string ]interface {}{
380+ "agent" : map [string ]interface {}{
381+ "debug" : true ,
382+ },
383+ "logs" : map [string ]interface {}{
384+ "logs_collected" : map [string ]interface {}{
385+ "application_signals" : map [string ]interface {}{},
386+ },
387+ },
388+ },
389+ want : & want {
390+ receivers : []string {"otlp/grpc_0_0_0_0_4315" , "otlp/http_0_0_0_0_4316" },
391+ processors : []string {},
392+ exporters : []string {"debug/application_signals" , "otlphttp/application_signals" },
393+ extensions : []string {"sigv4auth" , "agenthealth/logs" , "agenthealth/statuscode" },
394+ },
395+ isEKSCache : eksdetector .TestIsEKSCacheEKS ,
396+ },
397+ }
398+ for name , testCase := range testCases {
399+ t .Run (name , func (t * testing.T ) {
400+ eksdetector .IsEKS = testCase .isEKSCache
401+ conf := confmap .NewFromStringMap (testCase .input )
402+ got , err := tt .Translate (conf )
403+ assert .Equal (t , testCase .wantErr , err )
404+ if testCase .want == nil {
405+ assert .Nil (t , got )
406+ } else {
407+ require .NotNil (t , got )
408+ assert .Equal (t , testCase .want .receivers , collections .MapSlice (got .Receivers .Keys (), component .ID .String ))
409+ assert .Equal (t , testCase .want .processors , collections .MapSlice (got .Processors .Keys (), component .ID .String ))
410+ assert .Equal (t , testCase .want .exporters , collections .MapSlice (got .Exporters .Keys (), component .ID .String ))
411+ assert .Equal (t , testCase .want .extensions , collections .MapSlice (got .Extensions .Keys (), component .ID .String ))
412+ }
413+ })
414+ }
415+ }
0 commit comments