public void Test_EventSource_Traits_Dynamic() { TestUtilities.CheckNoEventSourcesRunning("Start"); using (var mySource = new EventSource("DynamicEventSourceWithTraits", EventSourceSettings.Default, "MyTrait", "MyTraitValue", "ETW_GROUP", "{4f50731a-89cf-4782-b3e0-dce8c90476ba}")) { // By default we are self-describing. Assert.Equal(mySource.Settings, EventSourceSettings.EtwSelfDescribingEventFormat); Assert.Equal(mySource.GetTrait("MyTrait"), "MyTraitValue"); Assert.Equal(mySource.GetTrait("ETW_GROUP"), "{4f50731a-89cf-4782-b3e0-dce8c90476ba}"); } TestUtilities.CheckNoEventSourcesRunning("Stop"); }
protected sealed override void OnEventSourceCreated(EventSource eventSource) { base.OnEventSourceCreated(eventSource); if (_log == null) { _eventSources.Add(eventSource); } if (eventSource.GetTrait(TraitName) == TraitValue) { EnableEvents(eventSource, _level); } }