diff --git a/src/Elastic.Apm/AgentComponents.cs b/src/Elastic.Apm/AgentComponents.cs index b353cd05d..4ae3c8276 100644 --- a/src/Elastic.Apm/AgentComponents.cs +++ b/src/Elastic.Apm/AgentComponents.cs @@ -53,22 +53,21 @@ IApmServerInfo apmServerInfo HttpTraceConfiguration = new HttpTraceConfiguration(); + TracerInternal = new Tracer(Logger, Service, PayloadSender, ConfigStore, + currentExecutionSegmentsContainer ?? new CurrentExecutionSegmentsContainer(), ApmServerInfo); + if (ConfigurationReader.Enabled) { CentralConfigFetcher = centralConfigFetcher ?? new CentralConfigFetcher(Logger, ConfigStore, Service); MetricsCollector = metricsCollector ?? new MetricsCollector(Logger, PayloadSender, ConfigStore); MetricsCollector.StartCollecting(); } - - TracerInternal = new Tracer(Logger, Service, PayloadSender, ConfigStore, - currentExecutionSegmentsContainer ?? new CurrentExecutionSegmentsContainer(), ApmServerInfo); - - if (!ConfigurationReader.Enabled) - Logger?.Info()?.Log("The Elastic APM .NET Agent is disabled - the agent won't capture traces and metrics."); + else + Logger.Info()?.Log("The Elastic APM .NET Agent is disabled - the agent won't capture traces and metrics."); } catch (Exception e) { - logger?.Error()?.LogException(e, "Failed initializing agent."); + Logger.Error()?.LogException(e, "Failed initializing agent."); } }