@@ -85,7 +85,7 @@ func initConfig(endpoint string) *cfg.Config {
8585 return xrayConfig
8686}
8787
88- func initDaemon (config * cfg.Config ) * Daemon {
88+ func initDaemon (config * cfg.Config , enableTelemetry bool ) * Daemon {
8989 if logFile != "" {
9090 var fileWriter io.Writer
9191 if * config .Logging .LogRotation {
@@ -133,8 +133,9 @@ func initDaemon(config *cfg.Config) *Daemon {
133133 awsConfig , session := conn .GetAWSConfigSession (& conn.Conn {}, config , config .RoleARN , config .Region , noMetadata )
134134 log .Infof ("Using region: %v" , aws .StringValue (awsConfig .Region ))
135135
136- log .Debugf ("ARN of the AWS resource running the daemon: %v" , config .ResourceARN )
137- telemetry .Init (awsConfig , session , config .ResourceARN , noMetadata )
136+ if enableTelemetry {
137+ telemetry .Init (awsConfig , session , config .ResourceARN , noMetadata )
138+ }
138139
139140 // If calculated number of buffer is lower than our default, use calculated one. Otherwise, use default value.
140141 parameterConfig .Processor .BatchSize = util .GetMinIntValue (parameterConfig .Processor .BatchSize , buffers )
@@ -179,10 +180,14 @@ func (d *Daemon) close() {
179180 // Signal routines to finish
180181 // This will push telemetry and customer segments in parallel
181182 d .std .Close ()
182- telemetry .T .Quit <- true
183+ if telemetry .T != nil {
184+ telemetry .T .Quit <- true
185+ }
183186
184187 <- d .processor .Done
185- <- telemetry .T .Done
188+ if telemetry .T != nil {
189+ <- telemetry .T .Done
190+ }
186191
187192 log .Debugf ("Trace segment: received: %d, truncated: %d, processed: %d" , atomic .LoadUint64 (& d .count ), d .std .TruncatedCount (), d .processor .ProcessedCount ())
188193 log .Debugf ("Shutdown finished. Current epoch in nanoseconds: %v" , time .Now ().UnixNano ())
@@ -226,7 +231,7 @@ func (d *Daemon) poll() {
226231 fallbackPointerUsed = true
227232 }
228233 rlen := d .read (bufPointer )
229- if rlen > 0 {
234+ if rlen > 0 && telemetry . T != nil {
230235 telemetry .T .SegmentReceived (1 )
231236 }
232237 if rlen == 0 {
@@ -237,7 +242,9 @@ func (d *Daemon) poll() {
237242 }
238243 if fallbackPointerUsed {
239244 log .Warn ("Segment dropped. Consider increasing memory limit" )
240- telemetry .T .SegmentSpillover (1 )
245+ if telemetry .T != nil {
246+ telemetry .T .SegmentSpillover (1 )
247+ }
241248 continue
242249 } else if rlen == - 1 {
243250 return
@@ -250,7 +257,9 @@ func (d *Daemon) poll() {
250257 if len (slices [1 ]) == 0 {
251258 log .Warnf ("Missing header or segment: %s" , string (slices [0 ]))
252259 d .pool .Return (bufPointer )
253- telemetry .T .SegmentRejected (1 )
260+ if telemetry .T != nil {
261+ telemetry .T .SegmentRejected (1 )
262+ }
254263 continue
255264 }
256265
@@ -264,7 +273,9 @@ func (d *Daemon) poll() {
264273 default :
265274 log .Warnf ("Invalid header: %s" , string (header ))
266275 d .pool .Return (bufPointer )
267- telemetry .T .SegmentRejected (1 )
276+ if telemetry .T != nil {
277+ telemetry .T .SegmentRejected (1 )
278+ }
268279 continue
269280 }
270281
0 commit comments