Ejemplo n.º 1
0
        public static CounterGroup GetCounter(string action)
        {
            //
            //  remove the response text from the action
            //
            if (string.IsNullOrWhiteSpace(action))
            {
                action = "unknown";
            }
            if (action.EndsWith("Response", StringComparison.OrdinalIgnoreCase))
            {
                action = action.Remove(action.Length - 8);
            }
            if (action.Length > 200)
            {
                action = action.Remove(200);
            }
            action = action.Replace('/', '-');
            CounterGroup counterGroup = null;

            //
            //  check if we have our perfmon counter
            //      for this action in our dictionary object
            //

            counterGroup = GetExistingInstance(action);

            if (counterGroup != null)
            {
                return(counterGroup);
            }

            return(CreateInstance(action));
        }
Ejemplo n.º 2
0
        private static CounterGroup CreateGroupPerformanceCounter(string action)
        {
            if (!PerformanceCounterCategory.Exists(CategoryName))
            {
                return(null);
            }

            var result = new CounterGroup
            {
                Executing           = new PerformanceCounter(CategoryName, CounterName_Executing, action, false),
                Hits                = new PerformanceCounter(CategoryName, CounterName_Hits, action, false),
                TimeTaken           = new PerformanceCounter(CategoryName, CounterName_TimeTaken, action, false),
                AverageDuration     = new PerformanceCounter(CategoryName, CounterName_AverageDuration, action, false),
                AverageDurationBase = new PerformanceCounter(CategoryName, CounterName_AverageDurationBase, action, false),
                HitsPerSecond       = new PerformanceCounter(CategoryName, CounterName_HitsPerSecond, action, false)
            };

            result.Executing.RawValue = 0;
            result.Hits.RawValue      = 0;
            result.TimeTaken.RawValue = 0;
            return(result);
        }
        private static CounterGroup CreateGroupPerformanceCounter(string action)
        {
            if (!PerformanceCounterCategory.Exists(CategoryName))
            {
                return null;
            }

            var result = new CounterGroup
            {
                Executing = new PerformanceCounter(CategoryName, CounterName_Executing, action, false),
                Hits = new PerformanceCounter(CategoryName, CounterName_Hits, action, false),
                TimeTaken = new PerformanceCounter(CategoryName, CounterName_TimeTaken, action, false),
                AverageDuration = new PerformanceCounter(CategoryName, CounterName_AverageDuration, action, false),
                AverageDurationBase = new PerformanceCounter(CategoryName, CounterName_AverageDurationBase, action, false),
                HitsPerSecond = new PerformanceCounter(CategoryName, CounterName_HitsPerSecond, action, false)
            };

            result.Executing.RawValue = 0;
            result.Hits.RawValue = 0;
            result.TimeTaken.RawValue = 0;
            return result;
        }