Skip to content

Commit

Permalink
Do not add probe processor when LiveDebugger isn't fully initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
dudikeleti committed Nov 14, 2024
1 parent 25f19d9 commit 09789c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ internal static ProbeExpressionsProcessor Instance

internal void AddProbeProcessor(ProbeDefinition probe)
{
if (LiveDebugger.Instance?.IsInitialized == false)
{
Log.Error("Failed to create probe processor for probe: {Id}", probe.Id);
throw new Exception("AddProbeProcessor can be called only when LiveDebugger is initialized");
}

try
{
_processors.AddOrUpdate(
Expand Down
7 changes: 4 additions & 3 deletions tracer/src/Datadog.Trace/Debugger/LiveDebugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ internal class LiveDebugger
private readonly ConfigurationUpdater _configurationUpdater;
private readonly IDogStatsd _dogStats;
private readonly object _instanceLock = new();
private bool _isInitialized;
private bool _isRcmAvailable;

private LiveDebugger(
Expand Down Expand Up @@ -87,6 +86,8 @@ private LiveDebugger(
}

public static LiveDebugger Instance { get; private set; }

public bool IsInitialized { get; private set; }

public string ServiceName { get; }

Expand Down Expand Up @@ -132,7 +133,7 @@ public async Task InitializeAsync()
return;
}

_isInitialized = true;
IsInitialized = true;
}

try
Expand All @@ -153,7 +154,7 @@ public async Task InitializeAsync()

bool CanInitialize()
{
if (_isInitialized)
if (IsInitialized)
{
return false;
}
Expand Down

0 comments on commit 09789c3

Please sign in to comment.