From b0af77d3c749bf0541c105e055848ca9572c0b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20=C3=81lvarez?= Date: Thu, 7 May 2020 12:12:22 +0200 Subject: [PATCH] code review --- libbeat/cmd/instance/beat.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index f41387ab330..ee5529c9036 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -123,14 +123,7 @@ var debugf = logp.MakeDebug("beat") func init() { initRand() - - // By default, the APM tracer is active. We switch behaviour to not require users to have - // an APM Server running, making it opt-in - if os.Getenv("ELASTIC_APM_ACTIVE") == "" { - os.Setenv("ELASTIC_APM_ACTIVE", "false") - } - // we need to close the default tracer to prevent the beat sending events to localhost:8200 - apm.DefaultTracer.Close() + preventDefaultTracing() } // initRand initializes the runtime random number generator seed using @@ -150,6 +143,16 @@ func initRand() { rand.Seed(seed) } +func preventDefaultTracing() { + // By default, the APM tracer is active. We switch behaviour to not require users to have + // an APM Server running, making it opt-in + if os.Getenv("ELASTIC_APM_ACTIVE") == "" { + os.Setenv("ELASTIC_APM_ACTIVE", "false") + } + // we need to close the default tracer to prevent the beat sending events to localhost:8200 + apm.DefaultTracer.Close() +} + // Run initializes and runs a Beater implementation. name is the name of the // Beat (e.g. packetbeat or metricbeat). version is version number of the Beater // implementation. bt is the `Creator` callback for creating a new beater