示例#1
0
        /// <summary>
        /// Creates a new meter metric and registers it under the given type and name
        /// </summary>
        /// <param name="context">The context for this metric</param>
        /// <param name="name">The metric name</param>
        /// <param name="eventType">The plural name of the type of events the meter is measuring (e.g., <code>"requests"</code>)</param>
        /// <param name="unit">The rate unit of the new meter</param>
        /// <param name="rate">The rate  of the new meter</param>
        /// <returns></returns>
        public PerSecondCounterMetric TimedCounter(string context, string name, string eventType)
        {
            var     metricName = new MetricName(context, name);
            IMetric existingMetric;

            if (_metrics.TryGetValue(metricName, out existingMetric))
            {
                return((PerSecondCounterMetric)existingMetric);
            }

            var metric          = PerSecondCounterMetric.New(eventType);
            var justAddedMetric = _metrics.GetOrAdd(metricName, metric);

            return(justAddedMetric == null ? metric : (PerSecondCounterMetric)justAddedMetric);
        }
示例#2
0
 public void RemovePerSecondCounterMetric(PerSecondCounterMetric perSecondCounterMetricToRemove)
 {
     perSecondCounterMetrics.TryRemove(perSecondCounterMetricToRemove);
 }
示例#3
0
 public void AddPerSecondCounterMetric(PerSecondCounterMetric newPerSecondCounterMetric)
 {
     perSecondCounterMetrics.Add(newPerSecondCounterMetric);
 }
示例#4
0
 public void RemovePerSecondCounterMetric(PerSecondCounterMetric perSecondCounterMetricToRemove)
 {
     perSecondCounterMetrics.TryRemove(perSecondCounterMetricToRemove);
 }
示例#5
0
 public void AddPerSecondCounterMetric(PerSecondCounterMetric newPerSecondCounterMetric)
 {
     perSecondCounterMetrics.Add(newPerSecondCounterMetric);
 }