From 307a52f378055dc457adecdf8ad3fbb1789e889a Mon Sep 17 00:00:00 2001 From: Karol Zadora-Przylecki Date: Tue, 18 Apr 2017 12:06:27 -0700 Subject: [PATCH] Suppress TaskParallelLibrary EventSource events. --- .../Microsoft.Diagnostics.EventFlow.Inputs.Etw.csproj | 2 +- .../StandardTraceEventSession.cs | 11 ++++++++++- .../EventSourceInput.cs | 7 ++++++- ...ft.Diagnostics.EventFlow.Inputs.EventSource.csproj | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.Diagnostics.EventFlow.Inputs.Etw/Microsoft.Diagnostics.EventFlow.Inputs.Etw.csproj b/src/Microsoft.Diagnostics.EventFlow.Inputs.Etw/Microsoft.Diagnostics.EventFlow.Inputs.Etw.csproj index 417e7e90..74423834 100644 --- a/src/Microsoft.Diagnostics.EventFlow.Inputs.Etw/Microsoft.Diagnostics.EventFlow.Inputs.Etw.csproj +++ b/src/Microsoft.Diagnostics.EventFlow.Inputs.Etw/Microsoft.Diagnostics.EventFlow.Inputs.Etw.csproj @@ -9,7 +9,7 @@ Microsoft.Diagnostics.EventFlow.Inputs.Etw ../../PublicKey.snk true - 1.1.0 + 1.1.1 true Microsoft.Diagnostics.EventFlow.Inputs.Etw Microsoft;Diagnostics;EventFlow;Inputs;ETW;Event Tracing for Windows diff --git a/src/Microsoft.Diagnostics.EventFlow.Inputs.Etw/StandardTraceEventSession.cs b/src/Microsoft.Diagnostics.EventFlow.Inputs.Etw/StandardTraceEventSession.cs index 1afde797..649553c1 100644 --- a/src/Microsoft.Diagnostics.EventFlow.Inputs.Etw/StandardTraceEventSession.cs +++ b/src/Microsoft.Diagnostics.EventFlow.Inputs.Etw/StandardTraceEventSession.cs @@ -10,6 +10,7 @@ using Microsoft.Diagnostics.Tracing; using Microsoft.Diagnostics.Tracing.Session; using Validation; +using Microsoft.Diagnostics.EventFlow.Utilities.Etw; namespace Microsoft.Diagnostics.EventFlow.Inputs { @@ -73,7 +74,15 @@ public void Process(Action onEvent) if (!isProcessing) { isProcessing = true; - this.inner.Source.Dynamic.All += (traceEvent) => onEvent(traceEvent.ToEventData(this.healthReporter)); + this.inner.Source.Dynamic.All += (traceEvent) => + { + // Suppress events from TplEventSource--they are mostly interesting for debugging task processing and interaction, + // and not that useful for production tracing. However, TPL EventSource must be enabled to get hierarchical activity IDs. + if (!TplActivities.TplEventSourceGuid.Equals(traceEvent.ProviderGuid)) + { + onEvent(traceEvent.ToEventData(this.healthReporter)); + } + }; this.inner.Source.Process(); } } diff --git a/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/EventSourceInput.cs b/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/EventSourceInput.cs index 41705305..adb90824 100644 --- a/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/EventSourceInput.cs +++ b/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/EventSourceInput.cs @@ -71,7 +71,12 @@ public override void Dispose() protected override void OnEventWritten(EventWrittenEventArgs eventArgs) { - this.subject.OnNext(eventArgs.ToEventData(this.healthReporter, nameof(EventSourceInput))); + // Suppress events from TplEventSource--they are mostly interesting for debugging task processing and interaction, + // and not that useful for production tracing. However, TPL EventSource must be enabled to get hierarchical activity IDs. + if (!TplActivities.TplEventSourceGuid.Equals(eventArgs.EventSource.Guid)) + { + this.subject.OnNext(eventArgs.ToEventData(this.healthReporter, nameof(EventSourceInput))); + } } protected override void OnEventSourceCreated(EventSource eventSource) diff --git a/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/Microsoft.Diagnostics.EventFlow.Inputs.EventSource.csproj b/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/Microsoft.Diagnostics.EventFlow.Inputs.EventSource.csproj index a6881d5f..d1eff51e 100644 --- a/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/Microsoft.Diagnostics.EventFlow.Inputs.EventSource.csproj +++ b/src/Microsoft.Diagnostics.EventFlow.Inputs.EventSource/Microsoft.Diagnostics.EventFlow.Inputs.EventSource.csproj @@ -3,7 +3,7 @@ Provides an input implementation for capturing diagnostics data sourced through System.Diagnostics.Tracing.EventSource infrastructure. © Microsoft Corporation. All rights reserved. - 1.1.0 + 1.1.1 Microsoft netstandard1.6;net46 true