Skip to content

Commit

Permalink
Update HostBuilderExtensions.cs
Browse files Browse the repository at this point in the history
Resolve AgentComponents only once.
  • Loading branch information
gregkalapos committed Nov 24, 2020
1 parent 6cf2dfb commit a123175
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Elastic.Apm.Extensions.Hosting/HostBuilderExtensions.cs
Expand Up @@ -56,8 +56,9 @@ public static IHostBuilder UseElasticApm(this IHostBuilder builder, params IDiag
{
if (Agent.IsConfigured) return Agent.Instance;
var newAgentInstance = new ApmAgent(sp.GetService<AgentComponents>());
Agent.Setup(sp.GetService<AgentComponents>());
var components = sp.GetService<AgentComponents>();
var newAgentInstance = new ApmAgent(components);
Agent.Setup(components);
return newAgentInstance;
});
Expand Down

0 comments on commit a123175

Please sign in to comment.