static Counter CreateCounter(string name, string category, bool logMessages, bool isTimer)
        {
            if (category == null)
            {
                category = "Global";
            }

            lock (counters) {
                CounterCategory cat = GetCategory(category);
                if (cat == null)
                {
                    cat = new CounterCategory(category);
                    categories.Add(cat);
                }

                Counter c = isTimer ? new TimerCounter(name, cat) : new Counter(name, cat);
                c.LogMessages = logMessages;
                cat.AddCounter(c);

                Counter old;
                if (counters.TryGetValue(name, out old))
                {
                    old.Disposed = true;
                }
                counters [name] = c;
                return(c);
            }
        }
		void AppendCategory (TreeIter it, CounterCategory cat)
		{
			TreeIter catIt;
			if (it.Equals (TreeIter.Zero))
				catIt = store.AppendValues (false, cat.Name, cat, null, false);
			else
				catIt = store.AppendValues (it, false, cat.Name, cat, null, false);
			
			foreach (Counter c in cat.Counters)
				store.AppendValues (catIt, false, c.Name, null, c, true);
		}
        static Counter CreateCounter(string name, string category, bool logMessages, string id, bool isTimer)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name", "Counters must have a Name");
            }

            InitializeHandlers();

            if (category == null)
            {
                category = "Global";
            }

            lock (counters) {
                CounterCategory cat = GetCategory(category);
                if (cat == null)
                {
                    cat = new CounterCategory(category);
                    categories.Add(cat);
                }

                Counter c = isTimer ? new TimerCounter(name, cat) : new Counter(name, cat);
                c.Id          = id;
                c.LogMessages = logMessages;
                cat.AddCounter(c);

                Counter old;
                if (counters.TryGetValue(name, out old))
                {
                    old.Disposed = true;
                }
                counters [name] = c;
                if (!string.IsNullOrEmpty(id))
                {
                    countersByID [id] = c;
                }

                foreach (var h in handlers)
                {
                    if (h.SupportsCounter(c))
                    {
                        c.Handlers.Add(h);
                    }
                }
                c.UpdateStatus();

                return(c);
            }
        }
예제 #4
0
        static Counter CreateCounter(string name, string category, bool logMessages, string id, bool isTimer)
        {
            InitializeHandlers();

            if (category == null)
            {
                category = "Global";
            }

            lock (counters) {
                CounterCategory cat = GetCategory(category);
                if (cat == null)
                {
                    cat = new CounterCategory(category);
                    categories.Add(cat);
                }

                Counter c = isTimer ? new TimerCounter(name, cat) : new Counter(name, cat);
                c.Id          = id;
                c.LogMessages = logMessages;
                cat.AddCounter(c);

                Counter old;
                if (counters.TryGetValue(name, out old))
                {
                    old.Disposed = true;
                }
                counters [name] = c;

                foreach (var h in handlers)
                {
                    if (h.SupportsCounter(c))
                    {
                        c.Handlers.Add(h);
                    }
                }
                c.UpdateStatus();

                return(c);
            }
        }
        static Counter CreateCounter <T> (string name, string?category, bool logMessages, string?id, bool isTimer) where T : CounterMetadata, new()
        {
            if (name == null)
            {
                throw new ArgumentNullException("name", "Counters must have a Name");
            }

            InitializeHandlers();

            if (category == null)
            {
                category = "Global";
            }

            lock (counters) {
                CounterCategory?cat = GetCategory(category);
                if (cat == null)
                {
                    cat = new CounterCategory(category);
                    categories.Add(cat);
                }

                var c = isTimer ? new TimerCounter <T> (name, cat) : (Counter) new Counter <T> (name, cat);
                c.Id          = id !;
                c.LogMessages = logMessages;
                cat.AddCounter(c);

                Counter old;
                if (counters.TryGetValue(name, out old))
                {
                    old.Disposed = true;
                }
                counters [name] = c;
                if (!string.IsNullOrEmpty(id))
                {
                    countersByID [id !] = c;
예제 #6
0
		internal Counter (string name, CounterCategory category)
		{
			this.name = name;
			this.category = category;
		}
		static Counter CreateCounter (string name, string category, bool logMessages, string id, bool isTimer)
		{
			InitializeHandlers ();
			
			if (category == null)
				category = "Global";
				
			lock (counters) {
				CounterCategory cat = GetCategory (category);
				if (cat == null) {
					cat = new CounterCategory (category);
					categories.Add (cat);
				}
				
				Counter c = isTimer ? new TimerCounter (name, cat) : new Counter (name, cat);
				c.Id = id;
				c.LogMessages = logMessages;
				cat.AddCounter (c);
				
				Counter old;
				if (counters.TryGetValue (name, out old))
					old.Disposed = true;
				counters [name] = c;
				
				foreach (var h in handlers) {
					if (h.SupportsCounter (c))
						c.Handlers.Add (h);
				}
				c.UpdateStatus ();
				
				return c;
			}
		}
 internal Counter(string name, CounterCategory category)
 {
     this.name     = name;
     this.category = category;
 }
예제 #9
0
		public TimerCounter (string name, CounterCategory category): base (name, category)
		{
		}
예제 #10
0
 public TimerCounter(string name, CounterCategory category) : base(name, category)
 {
 }
		static Counter CreateCounter (string name, string category, bool logMessages, string id, bool isTimer)
		{
			if (name == null)
				throw new ArgumentNullException ("name", "Counters must have a Name");

			InitializeHandlers ();
			
			if (category == null)
				category = "Global";
				
			lock (counters) {
				CounterCategory cat = GetCategory (category);
				if (cat == null) {
					cat = new CounterCategory (category);
					categories.Add (cat);
				}
				
				Counter c = isTimer ? new TimerCounter (name, cat) : new Counter (name, cat);
				c.Id = id;
				c.LogMessages = logMessages;
				cat.AddCounter (c);
				
				Counter old;
				if (counters.TryGetValue (name, out old))
					old.Disposed = true;
				counters [name] = c;
				if (!string.IsNullOrEmpty (id)) {
					countersByID [id] = c;
				}

				foreach (var h in handlers) {
					if (h.SupportsCounter (c))
						c.Handlers.Add (h);
				}
				c.UpdateStatus ();
				
				return c;
			}
		}
		static Counter CreateCounter (string name, string category, bool logMessages, bool isTimer)
		{
			if (category == null)
				category = "Global";
				
			lock (counters) {
				CounterCategory cat = GetCategory (category);
				if (cat == null) {
					cat = new CounterCategory (category);
					categories.Add (cat);
				}
				
				Counter c = isTimer ? new TimerCounter (name, cat) : new Counter (name, cat);
				c.LogMessages = logMessages;
				cat.AddCounter (c);
				
				Counter old;
				if (counters.TryGetValue (name, out old))
					old.Disposed = true;
				counters [name] = c;
				return c;
			}
		}
예제 #13
0
		void AppendCategory (CounterCategory cat)
		{
			IEnumerable<Counter> counters = cat.Counters.Where (c => c is TimerCounter);
			if (counters.Any ()) {
				TimeSpan time = TimeSpan.Zero;
				TimeSpan min = TimeSpan.MaxValue;
				TimeSpan max = TimeSpan.Zero;
				int count = 0;
				foreach (TimerCounter c in counters) {
					if (c.CountWithDuration > 0) {
						time += c.TotalTime;
						count += c.CountWithDuration;
						if (c.MinTime < min)
							min = c.MinTime;
						if (c.MaxTime > max)
							max = c.MaxTime;
					}
				}
				double avg = count > 0 ? (time.TotalMilliseconds / count) : 0d;
				if (count == 0)
					min = TimeSpan.Zero;
				
				TreeIter it = store.AppendValues (null, cat.Name, count, (float)time.TotalMilliseconds, (float)avg, (double)min.TotalMilliseconds, (double)max.TotalMilliseconds, false, null, null, true, false, normalColor);
				foreach (Counter c in counters)
					AppendCounter (it, (TimerCounter) c);
			}
		}