@@ -85,7 +85,7 @@ func initConfig(endpoint string) *cfg.Config {
85
85
return xrayConfig
86
86
}
87
87
88
- func initDaemon (config * cfg.Config ) * Daemon {
88
+ func initDaemon (config * cfg.Config , enableTelemetry bool ) * Daemon {
89
89
if logFile != "" {
90
90
var fileWriter io.Writer
91
91
if * config .Logging .LogRotation {
@@ -133,8 +133,9 @@ func initDaemon(config *cfg.Config) *Daemon {
133
133
awsConfig , session := conn .GetAWSConfigSession (& conn.Conn {}, config , config .RoleARN , config .Region , noMetadata )
134
134
log .Infof ("Using region: %v" , aws .StringValue (awsConfig .Region ))
135
135
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
+ }
138
139
139
140
// If calculated number of buffer is lower than our default, use calculated one. Otherwise, use default value.
140
141
parameterConfig .Processor .BatchSize = util .GetMinIntValue (parameterConfig .Processor .BatchSize , buffers )
@@ -179,10 +180,14 @@ func (d *Daemon) close() {
179
180
// Signal routines to finish
180
181
// This will push telemetry and customer segments in parallel
181
182
d .std .Close ()
182
- telemetry .T .Quit <- true
183
+ if telemetry .T != nil {
184
+ telemetry .T .Quit <- true
185
+ }
183
186
184
187
<- d .processor .Done
185
- <- telemetry .T .Done
188
+ if telemetry .T != nil {
189
+ <- telemetry .T .Done
190
+ }
186
191
187
192
log .Debugf ("Trace segment: received: %d, truncated: %d, processed: %d" , atomic .LoadUint64 (& d .count ), d .std .TruncatedCount (), d .processor .ProcessedCount ())
188
193
log .Debugf ("Shutdown finished. Current epoch in nanoseconds: %v" , time .Now ().UnixNano ())
@@ -226,7 +231,7 @@ func (d *Daemon) poll() {
226
231
fallbackPointerUsed = true
227
232
}
228
233
rlen := d .read (bufPointer )
229
- if rlen > 0 {
234
+ if rlen > 0 && telemetry . T != nil {
230
235
telemetry .T .SegmentReceived (1 )
231
236
}
232
237
if rlen == 0 {
@@ -237,7 +242,9 @@ func (d *Daemon) poll() {
237
242
}
238
243
if fallbackPointerUsed {
239
244
log .Warn ("Segment dropped. Consider increasing memory limit" )
240
- telemetry .T .SegmentSpillover (1 )
245
+ if telemetry .T != nil {
246
+ telemetry .T .SegmentSpillover (1 )
247
+ }
241
248
continue
242
249
} else if rlen == - 1 {
243
250
return
@@ -250,7 +257,9 @@ func (d *Daemon) poll() {
250
257
if len (slices [1 ]) == 0 {
251
258
log .Warnf ("Missing header or segment: %s" , string (slices [0 ]))
252
259
d .pool .Return (bufPointer )
253
- telemetry .T .SegmentRejected (1 )
260
+ if telemetry .T != nil {
261
+ telemetry .T .SegmentRejected (1 )
262
+ }
254
263
continue
255
264
}
256
265
@@ -264,7 +273,9 @@ func (d *Daemon) poll() {
264
273
default :
265
274
log .Warnf ("Invalid header: %s" , string (header ))
266
275
d .pool .Return (bufPointer )
267
- telemetry .T .SegmentRejected (1 )
276
+ if telemetry .T != nil {
277
+ telemetry .T .SegmentRejected (1 )
278
+ }
268
279
continue
269
280
}
270
281
0 commit comments