What is the purpose of the last argument of type `IDictionary <String, String>` in the `EventListener.EnableEvents` method?

I am trying to find out how the last argument ( IDictionary<String, String> ) in the EventListener.EnableEvents(EventSource, EventLevel, EventKeywords, IDictionary<String, String>) method EventListener.EnableEvents(EventSource, EventLevel, EventKeywords, IDictionary<String, String>) affects the behavior of the method.

I checked the MSDN documentation , but the description is not clear and there is no example how to use it. What are the arguments for the event and how are they indicated in the dictionary? If someone can give an example, it will be more than perfect.

+5
source share
2 answers

IDictionary<String, String> in EventListener.EnableEvents are the arguments to the command and passed to the EventSource. This is mainly an extensibility engine built into EventSource. For example, a custom event source can override OnEventCommand and respond to arbitrary commands.

The command arguments that are currently supported by System.Diagnostics.Tracing.EventSource are "ActivitySamplingStartEvent", "ActivitySampling" and "EtwSessionKeyword".

Here is an example of how they are used from the semantic log application block Filtering and filtering events :

 var listener = new ObservableEventListener(); listener.EnableEvents("MyCustomEventSource", EventLevel.Informational, Keywords.None, new Dictionary<string, string> { { "ActivitySampling", "true" } }); 
+2
source

The closest I found to answer this question was this article on MSDN .

You register events from the application, and also want to capture events from event sources that are not defined in the application, but that are related to the application. For example, you want to capture the RequestStarted event raised by ASP.NET when the request is received by your application. However, you do not want to collect all these events, because the volume created by these additional sources will suppress your journal store or make it difficult to analyze the registration information. To solve this problem, you need to collect only a sample of events, not all of them, and also be able to filter the processes from which you collect events.

+1
source

All Articles