Beispiel #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)));
        }
Beispiel #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)));
        }
Beispiel #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()));
 }
Beispiel #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)));
        }
Beispiel #5
0
 private CounterMetric(MetricName metricName, AtomicLong count)
 {
     Name   = metricName;
     _count = count;
 }
Beispiel #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)));
 }
Beispiel #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()));
 }
Beispiel #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;
 }
Beispiel #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()));
 }
Beispiel #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)));
 }
Beispiel #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)));
 }
Beispiel #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())));
 }
Beispiel #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)));
 }
Beispiel #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))
 {
 }
Beispiel #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)));
 }
Beispiel #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();
 }
Beispiel #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));
 }
Beispiel #18
0
 private MeterMetric(MetricName metricName, string eventType, TimeUnit rateUnit)
 {
     Name      = metricName;
     EventType = eventType;
     RateUnit  = rateUnit;
 }
Beispiel #19
0
 internal CounterMetric(MetricName metricName)
 {
     Name = metricName;
 }