Skip to content

Commit

Permalink
Disable Microsoft-ApplicationInsights-Data EventSource
Browse files Browse the repository at this point in the history
Resolves issue #234
  • Loading branch information
karolz-ms committed Aug 1, 2018
1 parent cee9533 commit 887bc51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Microsoft.Diagnostics.EventFlow.Inputs
{
public class EventSourceInput : EventListener, IObservable<EventData>, IDisposable, IRequireActivation
{
private const string AppInsightsDataEventSource = "Microsoft-ApplicationInsights-Data";

private bool constructed; // Initial value will be false (.NET default)
private IHealthReporter healthReporter;
// This does not really need to be a ConcurrentQueue, but the ConcurrentQueue has a very convenient-to-use TryDequeue method.
Expand Down Expand Up @@ -216,6 +218,17 @@ private void Initialize(List<EventSourceConfiguration> eventSources, IHealthRepo
}
// eventSources is a collection created by us, so we can modify it as necessary
eventSources.RemoveAll(config => invalidConfigurationItems.Contains(config));

// Special case: because of .NET bug https://github.com/dotnet/coreclr/issues/14434, using Microsoft-ApplicationInsights-Data will result in infinite loop.
// So we will disable it by default, unless there is explicit configuration for this EventSource
bool hasConfigForAppInsightsDataSource = eventSources.Any(config =>
AppInsightsDataEventSource.Equals(config.ProviderName, StringComparison.Ordinal) ||
AppInsightsDataEventSource.Equals(config.DisabledProviderNamePrefix, StringComparison.Ordinal));
if (!hasConfigForAppInsightsDataSource)
{
eventSources.Add(new EventSourceConfiguration() { DisabledProviderNamePrefix = AppInsightsDataEventSource });
}

this.EventSources = eventSources;

bool haveDisabledSources = this.EventSources.Any(config => !string.IsNullOrWhiteSpace(config.DisabledProviderNamePrefix));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Provides an input implementation for capturing diagnostics data sourced through System.Diagnostics.Tracing.EventSource infrastructure.</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<VersionPrefix>1.4.1</VersionPrefix>
<VersionPrefix>1.4.2</VersionPrefix>
<Authors>Microsoft</Authors>
<TargetFrameworks>netstandard1.6;net46;netstandard2.0</TargetFrameworks>
<AssemblyName>Microsoft.Diagnostics.EventFlow.Inputs.EventSource</AssemblyName>
Expand Down

0 comments on commit 887bc51

Please sign in to comment.