@@ -16,7 +16,6 @@ package collector
1616
1717import (
1818 "fmt"
19- "io/ioutil"
2019 "os"
2120 "time"
2221
@@ -38,18 +37,7 @@ import (
3837
3938func createExporters (v * viper.Viper , logger * zap.Logger ) ([]func (), []exporter.TraceExporter , []exporter.MetricsExporter ) {
4039 // TODO: (@pjanotti) this is slightly modified from agent but in the end duplication, need to consolidate style and visibility.
41- cfg := builder .GetConfigFile (v )
42- if cfg == "" {
43- logger .Info ("No config file, exporters can be only configured via the file." )
44- return nil , nil , nil
45- }
46-
47- cfgBlob , err := ioutil .ReadFile (cfg )
48- if err != nil {
49- logger .Fatal ("Cannot read config file for exporters" , zap .Error (err ))
50- }
51-
52- traceExporters , metricsExporters , doneFns , err := config .ExportersFromYAMLConfig (logger , cfgBlob )
40+ traceExporters , metricsExporters , doneFns , err := config .ExportersFromViperConfig (logger , v )
5341 if err != nil {
5442 logger .Fatal ("Failed to create config for exporters" , zap .Error (err ))
5543 }
@@ -101,9 +89,23 @@ func buildQueuedSpanProcessor(
10189 sender .HTTPTimeout (thriftHTTPSenderOpts .Timeout ),
10290 )
10391 }
92+ doneFns , traceExporters , _ := createExporters (opts .RawConfig , logger )
10493
105- if spanSender == nil {
106- logger .Fatal ("Unrecognized sender type or no exporters configured" , zap .String ("SenderType" , string (opts .SenderType )))
94+ if spanSender == nil && len (traceExporters ) == 0 {
95+ if opts .SenderType != "" {
96+ logger .Fatal ("Unrecognized sender type" , zap .String ("SenderType" , string (opts .SenderType )))
97+ }
98+ logger .Fatal ("No senders or exporters configured." )
99+ }
100+
101+ allSendersAndExporters := make ([]processor.SpanProcessor , 0 , 1 + len (traceExporters ))
102+ if spanSender != nil {
103+ allSendersAndExporters = append (allSendersAndExporters , spanSender )
104+ }
105+ for _ , traceExporter := range traceExporters {
106+ allSendersAndExporters = append (
107+ allSendersAndExporters , processor .NewTraceExporterProcessor (traceExporter ),
108+ )
107109 }
108110
109111 var batchingOptions []nodebatcher.Option
@@ -134,19 +136,25 @@ func buildQueuedSpanProcessor(
134136 }
135137 }
136138
137- // build queued span processor with underlying sender
138- queuedSpanProcessor = queued .NewQueuedSpanProcessor (
139- spanSender ,
140- queued .Options .WithLogger (logger ),
141- queued .Options .WithName (opts .Name ),
142- queued .Options .WithNumWorkers (opts .NumWorkers ),
143- queued .Options .WithQueueSize (opts .QueueSize ),
144- queued .Options .WithRetryOnProcessingFailures (opts .RetryOnFailure ),
145- queued .Options .WithBackoffDelay (opts .BackoffDelay ),
146- queued .Options .WithBatching (opts .BatchingConfig .Enable ),
147- queued .Options .WithBatchingOptions (batchingOptions ... ),
148- )
149- return nil , queuedSpanProcessor , nil
139+ queuedProcessors := make ([]processor.SpanProcessor , 0 , len (allSendersAndExporters ))
140+ for _ , senderOrExporter := range allSendersAndExporters {
141+ // build queued span processor with underlying sender
142+ queuedProcessors = append (
143+ queuedProcessors ,
144+ queued .NewQueuedSpanProcessor (
145+ senderOrExporter ,
146+ queued .Options .WithLogger (logger ),
147+ queued .Options .WithName (opts .Name ),
148+ queued .Options .WithNumWorkers (opts .NumWorkers ),
149+ queued .Options .WithQueueSize (opts .QueueSize ),
150+ queued .Options .WithRetryOnProcessingFailures (opts .RetryOnFailure ),
151+ queued .Options .WithBackoffDelay (opts .BackoffDelay ),
152+ queued .Options .WithBatching (opts .BatchingConfig .Enable ),
153+ queued .Options .WithBatchingOptions (batchingOptions ... ),
154+ ),
155+ )
156+ }
157+ return doneFns , processor .NewMultiSpanProcessor (queuedProcessors ), nil
150158}
151159
152160func buildSamplingProcessor (cfg * builder.SamplingCfg , nameToSpanProcessor map [string ]processor.SpanProcessor , v * viper.Viper , logger * zap.Logger ) (processor.SpanProcessor , error ) {
0 commit comments