Skip to content

Commit d943ed8

Browse files
authored
Add more explicit logging to ApmAgent.Subscribe. (#2153)
1 parent a03fe02 commit d943ed8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Elastic.Apm/ApmAgentExtensions.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
using System;
66
using System.Collections.Generic;
7+
using System.Linq;
78
using Elastic.Apm.Api;
89
using Elastic.Apm.DiagnosticSource;
10+
using Elastic.Apm.Logging;
911

1012
namespace Elastic.Apm
1113
{
@@ -29,7 +31,14 @@ public static class ApmAgentExtensions
2931
public static IDisposable Subscribe(this IApmAgent agent, params IDiagnosticsSubscriber[] subscribers)
3032
{
3133
var disposable = new CompositeDisposable();
32-
if (!agent.Configuration.Enabled || subscribers is null || subscribers.Length == 0)
34+
35+
subscribers ??= Array.Empty<IDiagnosticsSubscriber>();
36+
var subscribersList = string.Join(", ", subscribers.Select(s => s.GetType().Name));
37+
38+
agent.Logger.Trace()?.Log("Agent.Subscribe(), Agent Enabled: {AgentEnabled} Subscriber count: {NumberOfSubscribers}, ({Subscribers})",
39+
agent.Configuration.Enabled, subscribers.Length, subscribersList);
40+
41+
if (!agent.Configuration.Enabled || subscribers.Length == 0)
3342
return disposable;
3443

3544
foreach (var subscriber in subscribers)

0 commit comments

Comments
 (0)