Skip to content
This repository was archived by the owner on Jul 5, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
14 changes: 6 additions & 8 deletions Src/Web/Web.Shared.Net/RequestTrackingTelemetryModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/// <summary>Tracks if given type should be included in telemetry. ConcurrentDictionary is used as a concurrent hashset.</summary>
private readonly ConcurrentDictionary<Type, bool> includedHttpHandlerTypes = new ConcurrentDictionary<Type, bool>();

private TelemetryClient telemetryClient;
private TelemetryConfiguration telemetryConfiguration;
private bool initializationErrorReported;
private ChildRequestTrackingSuppressionModule childRequestTrackingSuppressionModule = null;

/// <summary>
/// Handler types that are not TransferHandlers will be included in request tracking.
/// </summary>
private HashSet<Type> requestHandlerTypesDoNotFilter = new HashSet<Type>();


/// <summary>
/// Gets or sets a value indicating whether child request suppression is enabled or disabled.
/// True by default.
Expand Down Expand Up @@ -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)
Expand All @@ -383,7 +381,7 @@ private bool IsHandlerToFilter(IHttpHandler handler)
}
}

this.requestHandlerTypesDoNotFilter.Add(handlerType);
this.includedHttpHandlerTypes.TryAdd(handlerType, true);
}
}

Expand Down