Skip to content

Commit

Permalink
Add more explicit logging to ApmAgent.Subscribe. (#2153)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Aug 8, 2023
1 parent a03fe02 commit d943ed8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Elastic.Apm/ApmAgentExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

using System;
using System.Collections.Generic;
using System.Linq;
using Elastic.Apm.Api;
using Elastic.Apm.DiagnosticSource;
using Elastic.Apm.Logging;

namespace Elastic.Apm
{
Expand All @@ -29,7 +31,14 @@ public static class ApmAgentExtensions
public static IDisposable Subscribe(this IApmAgent agent, params IDiagnosticsSubscriber[] subscribers)
{
var disposable = new CompositeDisposable();
if (!agent.Configuration.Enabled || subscribers is null || subscribers.Length == 0)

subscribers ??= Array.Empty<IDiagnosticsSubscriber>();
var subscribersList = string.Join(", ", subscribers.Select(s => s.GetType().Name));

agent.Logger.Trace()?.Log("Agent.Subscribe(), Agent Enabled: {AgentEnabled} Subscriber count: {NumberOfSubscribers}, ({Subscribers})",
agent.Configuration.Enabled, subscribers.Length, subscribersList);

if (!agent.Configuration.Enabled || subscribers.Length == 0)
return disposable;

foreach (var subscriber in subscribers)
Expand Down

0 comments on commit d943ed8

Please sign in to comment.