Example #1
0
        /// <summary>
        ///     Creates a new counter metric and registers it under the given type and name
        /// </summary>
        /// <param name="owner">The type that owns the metric</param>
        /// <param name="name">The metric name</param>
        /// <returns></returns>
        public CounterMetric Counter(Type owner, string name)
        {
            var metricName = new MetricName(owner, name);

            return(GetOrAdd(metricName, new CounterMetric(metricName)));
        }
Example #2
0
        /// <summary>
        ///     Creates a new histogram metric and registers it under the given type and name
        /// </summary>
        /// <param name="owner">The type that owns the metric</param>
        /// <param name="name">The metric name</param>
        /// <param name="sampleType">The sample type</param>
        /// <returns></returns>
        public HistogramMetric Histogram(Type owner, string name, SampleType sampleType)
        {
            var metricName = new MetricName(owner, name);

            return(GetOrAdd(metricName, new HistogramMetric(metricName, sampleType)));
        }
Example #3
0
 /// <summary>
 /// Return the <see cref="Core.Counter"/> registered under this name; or create and register
 /// a new <see cref="Core.Counter"/> if none is registered.
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <returns>a new or pre-existing <see cref="Core.Counter"/></returns>
 public Counter Counter(MetricName name)
 {
     return(GetOrAdd(name, new Counter()));
 }
Example #4
0
        /// <summary>
        ///     Creates a new gauge metric and registers it under the given type and name
        /// </summary>
        /// <typeparam name="T">The type the gauge measures</typeparam>
        /// <param name="owner">The type that owns the metric</param>
        /// <param name="name">The metric name</param>
        /// <param name="evaluator">The gauge evaluation function</param>
        /// <returns></returns>
        public GaugeMetric <T> Gauge <T>(Type owner, string name, Func <T> evaluator)
        {
            var metricName = new MetricName(owner, name);

            return(GetOrAdd(metricName, new GaugeMetric <T>(metricName, evaluator)));
        }
Example #5
0
 private CounterMetric(MetricName metricName, AtomicLong count)
 {
     Name   = metricName;
     _count = count;
 }
Example #6
0
 /// <summary>
 /// Return the <see cref="Core.Counter"/> registered under this name; or create and register
 /// a new <see cref="Core.Counter"/> if none is registered.
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <returns>a new or pre-existing <see cref="Core.Counter"/></returns>
 public Counter Counter(string name)
 {
     return(Counter(MetricName.build(name)));
 }
Example #7
0
 /// <summary>
 /// Return the <see cref="Core.Timer"/> registered under this name; or create and register
 /// a new <see cref="Core.Timer"/> if none is registered.
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <returns>a new or pre-existing <see cref="Core.Timer"/></returns>
 public Timer Timer(MetricName name)
 {
     return(GetOrAdd(name, new Core.Timer()));
 }
Example #8
0
 internal TimerMetric(MetricName metricName, TimeUnit durationUnit) : this(durationUnit, TimeUnit.Seconds,
                                                                           MeterMetric.New(metricName, "updates", TimeUnit.Seconds),
                                                                           new HistogramMetric(metricName, SampleType.Biased), true)
 {
     Name = metricName;
 }
Example #9
0
 /// <summary>
 /// Return the <see cref="Core.Meter"/> registered under this name; or create and register
 /// a new <see cref="Core.Meter"/> if none is registered.
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <returns>a new or pre-existing <see cref="Core.Meter"/></returns>
 public Meter Meter(MetricName name)
 {
     return(GetOrAdd(name, new Meter()));
 }
Example #10
0
 /// <summary>
 /// Return the <see cref="Core.Timer"/> registered under this name; or create and register
 /// a new <see cref="Core.Timer"/> if none is registered.
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <returns>a new or pre-existing <see cref="Core.Timer"/></returns>
 public Timer Timer(String name)
 {
     return(Timer(MetricName.build(name)));
 }
Example #11
0
 /// <summary>
 /// Return the <see cref="Core.Meter"/> registered under this name; or create and register
 /// a new <see cref="Core.Meter"/> if none is registered.
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <returns>a new or pre-existing <see cref="Core.Meter"/></returns>
 public Meter Meter(string name)
 {
     return(Meter(MetricName.build(name)));
 }
Example #12
0
 /// <summary>
 /// Return the <see cref="Core.Histogram"/> registered under this name; or create and register
 /// a new <see cref="Core.Histogram"/> if none is registered.
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <returns>a new or pre-existing <see cref="Core.Histogram"/></returns>
 public Histogram Histogram(MetricName name)
 {
     return(GetOrAdd(name, new Histogram(new ExponentiallyDecayingReservoir())));
 }
Example #13
0
 /// <summary>
 /// Return the <see cref="Core.Histogram"/> registered under this name; or create and register
 /// a new <see cref="Core.Histogram"/> if none is registered.
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <returns>a new or pre-existing <see cref="Core.Histogram"/></returns>
 public Histogram Histogram(string name)
 {
     return(Histogram(MetricName.build(name)));
 }
Example #14
0
 /// <summary>
 ///     Creates a new <see cref="T:Metrics.HistogramMetric" /> with the given sample type
 /// </summary>
 internal HistogramMetric(MetricName metricName, SampleType type) : this(metricName, NewSample(type))
 {
 }
Example #15
0
 /// <summary>
 /// Return the <see cref="Core.Gauge"/> registered under this name; or create and register
 /// a new <see cref="Core.Gauge"/> if none is registered.
 /// </summary>
 /// <param name="name">The metric name</param>
 /// <param name="evaluator">The evaluator for the gauge</param>
 /// <returns>a new or pre-existing <see cref="Core.Gauge"/></returns>
 public Gauge <T> Gauge <T>(MetricName name, Func <T> evaluator)
 {
     return(GetOrAdd(name, new Gauge <T>(evaluator)));
 }
Example #16
0
 /// <summary>
 ///     Creates a new <see cref="HistogramMetric" /> with the given sample
 /// </summary>
 internal HistogramMetric(MetricName metricName, ISample sample) : this(metricName, sample, true)
 {
     _sample = sample;
     Clear();
 }
Example #17
0
 /// <summary>
 /// Given an <see cref="IMetric"/>, registers it under the given name
 /// </summary>
 /// <typeparam name="T">the type of the metric</typeparam>
 /// <param name="name">the name of the metric</param>
 /// <param name="metric">the metric</param>
 /// <returns><see cref="IMetric"/></returns>
 public T Register <T>(string name, T metric) where T : IMetric
 {
     return(Register(MetricName.build(name), metric));
 }
Example #18
0
 private MeterMetric(MetricName metricName, string eventType, TimeUnit rateUnit)
 {
     Name      = metricName;
     EventType = eventType;
     RateUnit  = rateUnit;
 }
Example #19
0
 internal CounterMetric(MetricName metricName)
 {
     Name = metricName;
 }