/// <summary>
        /// Gets a List of performance metrics that will be measured on the action whose data is 
        /// represented by the given action info
        /// </summary>
        /// <param name="info">An ActionInfo object that contains info about the action whose performance
        /// is being measured</param>
        /// <returns>A List of PerformanceMetricBase objects of the metrics to be measured on this action</returns>
        public static List<PerformanceMetricBase> GetPerformanceMetrics(ActionInfo info)
        {
            if (performanceMetrics.ContainsKey(info) == false)
            {
                lock (lockObject)
                {
                    // Check Again
                    if (performanceMetrics.ContainsKey(info) == false)
                    {
                        List<PerformanceMetricBase> metrics = CreateMetricsForAction(info);
                         PerformanceMetricContainer pmc = new PerformanceMetricContainer(info, metrics);
                        performanceMetrics.Add(info, pmc);
                    }
                }
            }

            return performanceMetrics[info].GetPerformanceMetrics();
        }
Пример #2
0
        private static List <PerformanceMetricBase> CreateMetricsForAction(ActionInfo actionInfo)
        {
            List <PerformanceMetricBase> metrics = new List <PerformanceMetricBase>();

            // Add the standard metrics
            metrics.Add(new DeltaCallsMetric(actionInfo));
            metrics.Add(new TimerForEachRequestMetric(actionInfo));
            metrics.Add(new ActiveRequestsMetric(actionInfo));
            metrics.Add(new LastCallElapsedTimeMetric(actionInfo));
            metrics.Add(new DeltaExceptionsThrownMetric(actionInfo));
            metrics.Add(new PostAndPutRequestSizeMetric(actionInfo));

            // Now add any custom metrics the user may have added
            foreach (var x in customMetrics)
            {
                PerformanceMetricBase customMetric = x();
                metrics.Add(customMetric);
            }

            return(metrics);
        }
Пример #3
0
 /// <summary>
 /// Creates a new PerformanceMetricContainer object
 /// </summary>
 /// <param name="actionInfo">An ActionInfo object that describes the action the metrics will apply to</param>
 public PerformanceMetricContainer(ActionInfo actionInfo, List <PerformanceMetricBase> metrics)
 {
     this.ActionInfo         = actionInfo;
     this.performanceMetrics = metrics;
 }
Пример #4
0
 public PerformanceTracker(ActionInfo info)
 {
     this.actionInfo = info;
 }
 /// <summary>
 /// Creates a new PerformanceMetricContainer object
 /// </summary>
 /// <param name="actionInfo">An ActionInfo object that describes the action the metrics will apply to</param>
 public PerformanceMetricContainer(ActionInfo actionInfo, List<PerformanceMetricBase> metrics)
 {
     this.ActionInfo = actionInfo;
     this.performanceMetrics = metrics;
 }
        /// <summary>
        /// Helper method to create the ActionInfo object containing the info about the action that is getting called
        /// </summary>
        /// <param name="actionContext">The ActionExecutingContext from the OnActionExecuting() method</param>
        /// <returns>An ActionInfo object that contains all the information pertaining to what action is being executed</returns>
        private ActionInfo CreateActionInfo(ActionExecutingContext actionContext)
        {
            var parameters = actionContext.ActionDescriptor.GetParameters().Select(p => p.ParameterName);
            String parameterString = String.Join(",", parameters);

            int processId = ConfigInfo.Value.ProcessId;
            String controllerName = actionContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            String actionName = actionContext.ActionDescriptor.ActionName;
            String httpMethod = HttpContext.Current.Request.HttpMethod;
            int contentLength = HttpContext.Current.Request.ContentLength;

            ActionInfo info = new ActionInfo(processId, ACTION_TYPE,
                controllerName, actionName, httpMethod, parameterString,contentLength);

            return info;
        }
        private static List<PerformanceMetricBase> CreateMetricsForAction(ActionInfo actionInfo)
        {
            List<PerformanceMetricBase> metrics = new List<PerformanceMetricBase>();

            // Add the standard metrics
            metrics.Add(new DeltaCallsMetric(actionInfo));
            metrics.Add(new TimerForEachRequestMetric(actionInfo));
            metrics.Add(new ActiveRequestsMetric(actionInfo));
            metrics.Add(new LastCallElapsedTimeMetric(actionInfo));
            metrics.Add(new DeltaExceptionsThrownMetric(actionInfo));
            metrics.Add(new PostAndPutRequestSizeMetric(actionInfo));

            // Now add any custom metrics the user may have added
            foreach (var x in customMetrics)
            {
                PerformanceMetricBase customMetric = x();
                metrics.Add(customMetric);
            }

            return metrics;
        }
 public PerformanceTracker(ActionInfo info) => actionInfo = info;
 public PerformanceTracker(ActionInfo info)
 {
     this.actionInfo = info;
 }