Example #1
0
        /// <inheritdoc/>
        public ICollectionRuleTrigger Create(IEndpointInfo endpointInfo, Action callback, AspNetRequestCountOptions options)
        {
            var settings = new AspNetRequestCountTriggerSettings
            {
                ExcludePaths          = options.ExcludePaths,
                IncludePaths          = options.IncludePaths,
                RequestCount          = options.RequestCount,
                SlidingWindowDuration = options.SlidingWindowDuration ?? TimeSpan.Parse(AspNetRequestCountOptionsDefaults.SlidingWindowDuration, CultureInfo.InvariantCulture),
            };

            var aspnetTriggerSourceConfiguration = new AspNetTriggerSourceConfiguration();

            return(_eventPipeTriggerFactory.Create(endpointInfo, aspnetTriggerSourceConfiguration, _traceEventTriggerFactory, settings, callback));
        }
        /// <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));
        }
    }