Example #1
0
        public static void Start(string applicationName)
        {
            var filters = PerfItMvcRuntime.FindAllFilters();

            foreach (var filter in filters)
            {
                foreach (var counterType in filter.Counters)
                {
                    if (!PerfItMvcRuntime.HandlerFactories.ContainsKey(counterType))
                    {
                        throw new ArgumentException("Counter type not registered: " + counterType);
                    }

                    var counterHandler = PerfItMvcRuntime.HandlerFactories[counterType](applicationName, filter);
                    if (!_counterContexts.Keys.Contains(counterHandler.Name))
                    {
                        _counterContexts.Add(counterHandler.Name, new PerfItCounterContext()
                        {
                            Handler = counterHandler,
                            Name    = counterHandler.Name
                        });
                    }
                }
            }
        }
Example #2
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (!PerfItMvcRuntime.IsEnabled)
            {
                base.OnActionExecuted(filterContext);
                return;
            }

            this.Name         = !String.IsNullOrWhiteSpace(Name) ? Name : filterContext.ActionDescriptor.ControllerDescriptor.ControllerName + "." + filterContext.ActionDescriptor.ActionName;
            this.CategoryName = !String.IsNullOrWhiteSpace(CategoryName) ? CategoryName : filterContext.Controller.GetType().Assembly.GetName().Name;
            base.OnActionExecuted(filterContext);
            foreach (string counterType in Counters)
            {
                PerfItMvcRuntime.OnActionExecuted(this.Name + "." + counterType, filterContext);
            }
        }