コード例 #1
0
        /// <summary>Track a single invocation for a named source.</summary>
        /// <param name="source">The name of the source.</param>
        /// <param name="entry">The entry.</param>
        public void Track(string source, PerformanceCounterEntry entry)
        {
            // add entry
            if (!this.PerformanceCounters.ContainsKey(source))
            {
                this.PerformanceCounters.Add(source, new PerformanceCounter(this, source));
            }
            this.PerformanceCounters[source].Add(entry);

            // raise alert
            if (this.EnableAlerts)
            {
                this.TriggeredPerformanceCounters.Add(new AlertContext(source, entry.ElapsedMilliseconds));
            }
        }
コード例 #2
0
        /// <summary>Add a performance counter entry to the list, update monitoring, and raise alerts if needed.</summary>
        /// <param name="entry">The entry to add.</param>
        public void Add(PerformanceCounterEntry entry)
        {
            // add entry
            if (this.Entries.Count > this.MaxEntries)
            {
                this.Entries.Pop();
            }
            this.Entries.Push(entry);

            // update metrics
            if (this.PeakPerformanceCounterEntry == null || entry.ElapsedMilliseconds > this.PeakPerformanceCounterEntry.Value.ElapsedMilliseconds)
            {
                this.PeakPerformanceCounterEntry = entry;
            }

            // raise alert
            if (this.EnableAlerts && entry.ElapsedMilliseconds > this.AlertThresholdMilliseconds)
            {
                this.ParentCollection.AddAlert(entry.ElapsedMilliseconds, this.AlertThresholdMilliseconds, new AlertContext(this.Source, entry.ElapsedMilliseconds));
            }
        }