public async Task EventCounterTriggerWithEventPipePipelineTest() { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { throw new SkipTestException("https://github.com/dotnet/diagnostics/issues/2568"); } EventCounterTriggerSettings settings = new() { ProviderName = EventCounterConstants.RuntimeProviderName, CounterName = EventCounterConstants.CpuUsageCounterName, GreaterThan = 5, SlidingWindowDuration = TimeSpan.FromSeconds(3), CounterIntervalSeconds = 1 }; await using (var testExecution = StartTraceeProcess("TriggerRemoteTest")) { //TestRunner should account for start delay to make sure that the diagnostic pipe is available. DiagnosticsClient client = new(testExecution.TestRunner.Pid); TaskCompletionSource <object> waitSource = new(TaskCreationOptions.RunContinuationsAsynchronously); await using EventPipeTriggerPipeline <EventCounterTriggerSettings> pipeline = new( client, new EventPipeTriggerPipelineSettings <EventCounterTriggerSettings> { Configuration = EventCounterTrigger.CreateConfiguration(settings), TriggerFactory = new EventCounterTriggerFactory(), TriggerSettings = settings, Duration = Timeout.InfiniteTimeSpan }, traceEvent => { waitSource.TrySetResult(null); }); await PipelineTestUtilities.ExecutePipelineWithDebugee( _output, pipeline, testExecution, waitSource); Assert.True(waitSource.Task.IsCompletedSuccessfully); }
/// <inheritdoc/> public ICollectionRuleTrigger Create(IEndpointInfo endpointInfo, Action callback, EventCounterOptions options) { EventCounterTriggerSettings settings = new() { ProviderName = options.ProviderName, CounterIntervalSeconds = _counterOptions.CurrentValue.GetIntervalSeconds(), CounterName = options.CounterName, GreaterThan = options.GreaterThan, LessThan = options.LessThan, SlidingWindowDuration = options.SlidingWindowDuration.GetValueOrDefault(TimeSpan.Parse(EventCounterOptionsDefaults.SlidingWindowDuration)) }; return(_eventPipeTriggerFactory.Create( endpointInfo, EventCounterTrigger.CreateConfiguration(settings), _traceEventTriggerFactory, settings, callback)); } }