elastic / apm-agent-dotnet

https://www.elastic.co/guide/en/apm/agent/dotnet/current/index.html
Apache License 2.0
586 stars 208 forks source link

Adding filters should not force initialization of Agent. #2418

Closed Mpdreamz closed 3 months ago

Mpdreamz commented 3 months ago

Instead if the agent is not yet setup we simply buffer the filters until the agent gets constructed.

This allows you to add filters before initializing the static agent.

This manifested itself in the hosted service integrations (.NET Core) where the agent get's constructed slightly delayed.

And calling

Agent.AddFilter((ISpan span) =>
{
    return span;
});

Would win the race for Agent.Instance over the ASP.NET core integrations.