diff --git a/CHANGELOG.md b/CHANGELOG.md
index 11d68b3e1..b8cfc4786 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,9 @@
# Changelog
+## vNext
+- [Fix: Replaced non-threadsafe HashSet with ConcurrentDictionary in RequestTrackingTelemetryModule.IsHandlerToFilter](https://github.com/microsoft/ApplicationInsights-dotnet-server/pull/1211)
+
## Version 2.11.0-beta1
- [Defer populating RequestTelemetry properties.](https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/1173)
diff --git a/Src/Web/Web.Shared.Net/RequestTrackingTelemetryModule.cs b/Src/Web/Web.Shared.Net/RequestTrackingTelemetryModule.cs
index 90a7e829c..9e3ff3549 100644
--- a/Src/Web/Web.Shared.Net/RequestTrackingTelemetryModule.cs
+++ b/Src/Web/Web.Shared.Net/RequestTrackingTelemetryModule.cs
@@ -24,16 +24,14 @@ public class RequestTrackingTelemetryModule : ITelemetryModule
// if HttpApplicaiton.OnRequestExecute is available, we don't attempt to detect any correlation issues
private static bool correlationIssuesDetectionComplete = typeof(HttpApplication).GetMethod("OnExecuteRequestStep") != null;
+ /// Tracks if given type should be included in telemetry. ConcurrentDictionary is used as a concurrent hashset.
+ private readonly ConcurrentDictionary includedHttpHandlerTypes = new ConcurrentDictionary();
+
private TelemetryClient telemetryClient;
private TelemetryConfiguration telemetryConfiguration;
private bool initializationErrorReported;
private ChildRequestTrackingSuppressionModule childRequestTrackingSuppressionModule = null;
-
- ///
- /// Handler types that are not TransferHandlers will be included in request tracking.
- ///
- private HashSet requestHandlerTypesDoNotFilter = new HashSet();
-
+
///
/// Gets or sets a value indicating whether child request suppression is enabled or disabled.
/// True by default.
@@ -371,7 +369,7 @@ private bool IsHandlerToFilter(IHttpHandler handler)
if (handler != null)
{
var handlerType = handler.GetType();
- if (!this.requestHandlerTypesDoNotFilter.Contains(handlerType))
+ if (!this.includedHttpHandlerTypes.ContainsKey(handlerType))
{
var handlerName = handlerType.FullName;
foreach (var h in this.Handlers)
@@ -383,7 +381,7 @@ private bool IsHandlerToFilter(IHttpHandler handler)
}
}
- this.requestHandlerTypesDoNotFilter.Add(handlerType);
+ this.includedHttpHandlerTypes.TryAdd(handlerType, true);
}
}