Skip to content

Commit 6adebe3

Browse files
authored
chore: Use a thread-safe collection for the custom instrumentation ids that are tracked in AgentHealthReporter (#3517)
chore: Use a thread-safe collection for the custom instrumentation ids that are tracked in AgentHealthReporter. Fixes #3487
1 parent 25c59e7 commit 6adebe3

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Agent/NewRelic/Agent/Core/AgentHealth/AgentHealthReporter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class AgentHealthReporter : ConfigurationBasedService, IAgentHealthReport
4444
private InterlockedCounter _distributedTraceHeadersAcceptedLateCounter = new InterlockedCounter();
4545

4646
private readonly InterlockedCounter _customInstrumentationCounter;
47-
private readonly HashSet<string> _customInstrumentationIds = new();
47+
private readonly ConcurrentDictionary<string, byte> _customInstrumentationIds = new();
4848
private bool _customInstrumentationMaxLogged;
4949

5050
private HealthCheck _healthCheck;
@@ -188,7 +188,7 @@ public void ReportCustomInstrumentation(string assemblyName, string className, s
188188
{
189189
// record only unique custom instrumentation metrics
190190
var uniqueIdentifier = $"{assemblyName}.{className}.{method}";
191-
if (!_customInstrumentationIds.Add(uniqueIdentifier))
191+
if (!_customInstrumentationIds.TryAdd(uniqueIdentifier, 0))
192192
{
193193
return;
194194
}

0 commit comments

Comments
 (0)