Example #1
0
    /// <summary>
    /// Initializes a new instance of the <see cref=" Meter"/> class by using
    /// the specified meter name, rate unit and clock.
    /// </summary>
    /// <param name="config">
    /// A <see cref="MetricConfig"/> containing the configuration settings
    /// for the metric.
    /// </param>
    /// <param name="rate_unit">
    /// The time unit of the meter's rate.
    /// </param>
    /// <param name="context">
    /// A <see cref="MetricContext"/> that contains the shared
    /// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
    /// </param>
    internal Meter(MetricConfig config, TimeUnit rate_unit,
      MetricContext context) : base(config, context) {
      const string kStatistic = "statistic";

      mean_rate_ = new MeanRate(
        config.WithAdditionalTag(new Tag(kStatistic, "mean_rate")), rate_unit,
        context);

      ewma_1_rate_ = ExponentialWeightedMovingAverage
        .ForOneMinute(
          config.WithAdditionalTag(new Tag(kStatistic, "ewma_m1_rate")),
          rate_unit, context);

      ewma_5_rate_ = ExponentialWeightedMovingAverage
        .ForFiveMinutes(
          config.WithAdditionalTag(new Tag(kStatistic, "ewma_m5_rate")),
          rate_unit, context);

      ewma_15_rate_ = ExponentialWeightedMovingAverage
        .ForFifteenMinutes(
          config.WithAdditionalTag(new Tag(kStatistic, "ewma_m15_rate")),
          rate_unit, context);

      metrics_ = new ReadOnlyCollection<IMetric>(
        new IMetric[] {
          mean_rate_, ewma_1_rate_, ewma_5_rate_, ewma_15_rate_
        });
    }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Builder"/>
 /// class that creates a <see cref="BucketTimer"/> instance
 /// with the configured values.
 /// </summary>
 /// <param name="config">
 /// a <see cref="MetricConfig"/> object containing configuration
 /// information about the metric to be created.
 /// </param>
 public Builder(MetricConfig config)
 {
     Config      = config;
     TimeUnit    = TimeUnit.Milliseconds;
     MeasureUnit = TimeUnit.Seconds;
     Context     = MetricContext.ForCurrentProcess;
     Buckets     = new long[0];
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractMetric"/> class
 /// by using the given <paramref name="config"/> object.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="context">
 /// A <see cref="MetricContext"/> that contains the shared
 /// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
 /// </param>
 protected AbstractMetric(MetricConfig config, MetricContext context)
 {
     if (config == null || context == null)
     {
         throw new ArgumentNullException(config == null ? "config" : "context");
     }
     Config   = config;
     context_ = context;
 }
Example #4
0
        /// <summary>
        /// Determines whether the specified <paramref name="config"/> is equal
        /// to the current <see cref="MetricConfig"/> object.
        /// </summary>
        /// <param name="config">
        /// The <see cref="config"/> to compare with the current
        /// <see cref="MetricConfig"/> object.
        /// </param>
        /// <returns>
        /// <c>true</c> if <paramref name="config"/> and the current
        /// <see cref="MetricConfig"/> object represents the same object;
        /// ohtherwise, <c>false</c>.
        /// </returns>
        public bool Equals(MetricConfig config)
        {
            if ((object)config == null)
            {
                return(false);
            }

            return((config.Name == Name) && config.Tags.EqualsTo(Tags));
        }
Example #5
0
 CallableGaugeWrapper PercentileGauge(MetricConfig config, double percentile)
 {
     // We need to divide the percentile to 100 because the percentiles from
     // the SnapshotConfig is in range 0 to 100 and the Snapshot.Quantile
     // methof computes percentiles in range 0.0 to 1.0.
     return
         (new CallableGaugeWrapper(
              config.WithAdditionalTag("statistic",
                                       "percentile_" + (percentile).ToString("#0.####")),
              snapshot => snapshot.Quantile(percentile / 100)));
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>, initial value and
 /// <see cref="MetricContext"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 /// <param name="initial">
 /// The initial value of the counter.
 /// </param>
 /// <param name="unit">
 /// The unit to be used to report the computed rate.
 /// </param>
 /// <param name="context">
 /// The <see cref="MetricContext"/> to be used by the counter.
 /// </param>
 public StepCounter(MetricConfig config, long initial, TimeUnit unit,
                    MetricContext context)
     : base(
         config
         .WithAdditionalTag(MetricType.Normalized.AsTag())
         .WithAdditionalTag("unit", unit.Name()), context)
 {
     prev_count_ = initial;
     curr_count_ = initial;
     prev_tick_  = curr_tick_ = context.Tick;
     unit_       = unit;
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="ExponentialWeightedMovingAverage"/> class by using the
 /// specified smoothing constant, expected tick interval and time unit of
 /// the tick interval.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="alpha">
 /// The smoothing constant.
 /// </param>
 /// <param name="interval">
 /// The expected tick interval.
 /// </param>
 /// <param name="unit">
 /// The time unit that should be used to compute the rate.
 /// </param>
 /// <param name="context">
 /// A <see cref="MetricContext"/> that contains the shared
 /// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
 /// </param>
 public ExponentialWeightedMovingAverage(MetricConfig config, double alpha,
                                         TimeSpan interval, TimeUnit unit, MetricContext context)
     : base(config.WithAdditionalTag(MetricType.EWMA.AsTag()), context)
 {
     interval_       = interval.Ticks;
     alpha_          = alpha;
     ticks_per_unit_ = 1.ToTicks(unit);
     uncounted_      = 0;
     rate_           = 0.0;
     last_tick_      = context_.Tick;
     initialized_    = false;
 }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Histogram"/> by using the
        /// given <see cref="IResevoir"/>.
        /// </summary>
        /// <param name="config">
        /// A <see cref="MetricConfig"/> containing the configuration settings
        /// for the metric.
        /// </param>
        /// <param name="stats">
        /// A <see cref="SnapshotConfig"/> that defines the statistics that should
        /// be computed.
        /// </param>
        /// <param name="resevoir">
        /// A <see cref="IResevoir"/> that can be used to store the computed
        /// values.
        /// </param>
        /// <param name="context">
        /// A <see cref="MetricContext"/> that contains the shared
        /// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
        /// </param>
        public Histogram(MetricConfig config, SnapshotConfig stats,
                         IResevoir resevoir, MetricContext context)
            : base(config, context)
        {
            resevoir_ = resevoir;

            gauges_ = new List <CallableGaugeWrapper>();

            if (stats.ComputeCount)
            {
                gauges_.Add(CountGauge(config));
            }

            if (stats.ComputeMax)
            {
                gauges_.Add(MaxGauge(config));
            }

            if (stats.ComputeMean)
            {
                gauges_.Add(MeanGauge(config));
            }

            if (stats.ComputeMedian)
            {
                gauges_.Add(MedianGauge(config));
            }

            if (stats.ComputeMin)
            {
                gauges_.Add(MinGauge(config));
            }

            if (stats.ComputeStdDev)
            {
                gauges_.Add(StdDevGauge(config));
            }

            foreach (var percentile in stats.Percentiles)
            {
                gauges_.Add(PercentileGauge(config, percentile));
            }
        }
Example #9
0
        public Timer(MetricConfig config, TimeUnit unit, MetricContext context)
            : base(config, context)
        {
            unit_ = unit;

            MetricConfig cfg = config.WithAdditionalTag("unit", unit.Name());

            count_      = new Counter(cfg.WithAdditionalTag(kStatistic, kCount), context);
            max_        = new StepMaxGauge(cfg.WithAdditionalTag(kStatistic, kMax));
            min_        = new StepMinGauge(cfg.WithAdditionalTag(kStatistic, kMin));
            total_time_ =
                new Counter(cfg.WithAdditionalTag(kStatistic, kTotal), context);

            metrics_ = new ReadOnlyCollection <IMetric>(
                new IMetric[] {
                count_,
                new MeasureTransformer(max_, ConvertToUnit),
                new MeasureTransformer(min_, ConvertToUnit),
                new MeasureTransformer(total_time_, ConvertToUnit)
            });
        }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Func{T}"/>
 /// by using the specified <see cref="Func{T}"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="callable">
 /// A <see cref="Func{T}"/> that is used to compute the gauge
 /// values.
 /// </param>
 public CallableGauge(MetricConfig config, Func <Measure> callable)
     : base(config)
 {
     callable_ = callable;
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MaxGauge"/> class
 /// by using the given <paramref name="config"/> object.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 public MaxGauge(MetricConfig config)
     : base(config.WithAdditionalTag(MetricType.Gauge.AsTag()))
 {
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/> and
 /// <see cref="MetricContext"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 /// <param name="context">
 /// The <see cref="MetricContext"/> to be used by the counter.
 /// </param>
 public StepCounter(MetricConfig config, MetricContext context)
     : this(config, TimeUnit.Seconds, context)
 {
 }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>.
 /// </summary>
 /// <param name="unit">
 /// The unit to be used to report the computed rate.
 /// </param>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 public StepCounter(MetricConfig config, TimeUnit unit)
   : this(config, 0, unit) {
 }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="ExponentialWeightedMovingAverage"/> class by using the
 /// given smoothing constant, a 5 seconds tick interval and and seconds as
 /// the time unit.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="alpha">
 /// The smoothing constant.
 /// </param>
 public ExponentialWeightedMovingAverage(MetricConfig config, double alpha)
     : this(config, alpha, TimeSpan.FromSeconds(kFiveSecondsInterval),
            TimeUnit.Seconds)
 {
 }
Example #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Counter"/> class that
 /// uses the specified executor to perform the counter updates (
 /// increment/decrement).
 /// </summary>
 public Counter(MetricConfig config) : this(config, 0) {
 }
Example #16
0
 CallableGaugeWrapper StdDevGauge(MetricConfig config) {
   return
     new CallableGaugeWrapper(
       config.WithAdditionalTag("statistic", "stddev"),
       snapshot => snapshot.StdDev);
 }
Example #17
0
 CallableGaugeWrapper PercentileGauge(MetricConfig config, double percentile) {
   // We need to divide the percentile to 100 because the percentiles from
   // the SnapshotConfig is in range 0 to 100 and the Snapshot.Quantile
   // methof computes percentiles in range 0.0 to 1.0.
   return
     new CallableGaugeWrapper(
       config.WithAdditionalTag("statistic",
         "percentile_" + (percentile).ToString("#0.####")),
       snapshot => snapshot.Quantile(percentile/100));
 }
Example #18
0
 CallableGaugeWrapper MaxGauge(MetricConfig config) {
   return
     new CallableGaugeWrapper(
       config.WithAdditionalTag("statistic", "max"),
       snapshot => snapshot.Max);
 }
Example #19
0
 CallableGaugeWrapper CountGauge(MetricConfig config) {
   return
     new CallableGaugeWrapper(
       config.WithAdditionalTag("statistic", "count"),
       snapshot => snapshot.Size);
 }
Example #20
0
 public CallableGaugeWrapper(MetricConfig config,
   Func<Snapshot, double> callable) {
   config_ = config;
   callable_ = callable;
 }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>, initial value and
 /// <see cref="MetricContext"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 /// <param name="initial">
 /// The initial value of the counter.
 /// </param>
 /// <param name="unit">
 /// The unit to be used to report the computed rate.
 /// </param>
 /// <param name="context">
 /// The <see cref="MetricContext"/> to be used by the counter.
 /// </param>
 public StepCounter(MetricConfig config, long initial, TimeUnit unit,
   MetricContext context)
   : base(
     config
       .WithAdditionalTag(MetricType.Normalized.AsTag())
       .WithAdditionalTag("unit", unit.Name()), context) {
   prev_count_ = initial;
   curr_count_ = initial;
   prev_tick_ = curr_tick_ = context.Tick;
   unit_ = unit;
 }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/> and
 /// <see cref="MetricContext"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 /// <param name="context">
 /// The <see cref="MetricContext"/> to be used by the counter.
 /// </param>
 public StepCounter(MetricConfig config, MetricContext context)
   : this(config, TimeUnit.Seconds, context) {
 }
Example #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BasicCompositeMetric"/> by
 /// using the given list of sub-metrics.
 /// </summary>
 /// <param name="metrics">
 /// </param>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 public BasicCompositeMetric(MetricConfig config,
                             IEnumerable <IMetric> metrics)
     : this(config, metrics, MetricContext.ForCurrentProcess)
 {
 }
Example #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Histogram"/> that uses
 /// the <see cref="ExponentiallyDecayingResevoir"/> as resevoir.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="stats">
 /// A <see cref="SnapshotConfig"/> that defines the statistics that should
 /// be computed.
 /// </param>
 public Histogram(MetricConfig config, SnapshotConfig stats)
   : this(config, stats, new ExponentiallyDecayingResevoir(),
     MetricContext.ForCurrentProcess) {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BasicCompositeMetric"/> by
 /// using the given list of sub-metrics.
 /// </summary>
 /// <param name="metrics">
 /// </param>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 public BasicCompositeMetric(MetricConfig config,
   IEnumerable<IMetric> metrics)
   : this(config, metrics, MetricContext.ForCurrentProcess) {
 }
Example #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Histogram"/> by using the
 /// given <see cref="IResevoir"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="stats">
 /// A <see cref="SnapshotConfig"/> that defines the statistics that should
 /// be computed.
 /// </param>
 /// <param name="resevoir">
 /// A <see cref="IResevoir"/> that can be used to store the computed
 /// values.
 /// </param>
 public Histogram(MetricConfig config, SnapshotConfig stats,
   IResevoir resevoir)
   : this(config, stats, resevoir, MetricContext.ForCurrentProcess) {
 }
Example #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>,
 /// <see cref="MetricContext"/> and <paramref name="initial"/> value.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 /// <param name="unit">
 /// The unit to be used to report the computed rate.
 /// </param>
 /// <param name="initial">
 /// The initial value of the counter.
 /// </param>
 public StepCounter(MetricConfig config, long initial, TimeUnit unit)
   : this(config, initial, unit, MetricContext.ForCurrentProcess) {
 }
Example #28
0
    /// <summary>
    /// Initializes a new instance of the <see cref="Histogram"/> by using the
    /// given <see cref="IResevoir"/>.
    /// </summary>
    /// <param name="config">
    /// A <see cref="MetricConfig"/> containing the configuration settings
    /// for the metric.
    /// </param>
    /// <param name="stats">
    /// A <see cref="SnapshotConfig"/> that defines the statistics that should
    /// be computed.
    /// </param>
    /// <param name="resevoir">
    /// A <see cref="IResevoir"/> that can be used to store the computed
    /// values.
    /// </param>
    /// <param name="context">
    /// A <see cref="MetricContext"/> that contains the shared
    /// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
    /// </param>
    public Histogram(MetricConfig config, SnapshotConfig stats,
      IResevoir resevoir, MetricContext context)
      : base(config, context) {
      resevoir_ = resevoir;

      gauges_ = new List<CallableGaugeWrapper>();

      if (stats.ComputeCount) {
        gauges_.Add(CountGauge(config));
      }

      if (stats.ComputeMax) {
        gauges_.Add(MaxGauge(config));
      }

      if (stats.ComputeMean) {
        gauges_.Add(MeanGauge(config));
      }

      if (stats.ComputeMedian) {
        gauges_.Add(MedianGauge(config));
      }

      if (stats.ComputeMin) {
        gauges_.Add(MinGauge(config));
      }

      if (stats.ComputeStdDev) {
        gauges_.Add(StdDevGauge(config));
      }

      foreach (var percentile in stats.Percentiles) {
        gauges_.Add(PercentileGauge(config, percentile));
      }
    }
Example #29
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="ExponentialWeightedMovingAverage"/> class by using the
 /// specified smoothing constant, expected tick interval and time unit of
 /// the tick interval.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="alpha">
 /// The smoothing constant.
 /// </param>
 /// <param name="interval">
 /// The expected tick interval.
 /// </param>
 /// <param name="unit">
 /// The time unit that should be used to compute the rate.
 /// </param>
 public ExponentialWeightedMovingAverage(MetricConfig config, double alpha,
                                         TimeSpan interval, TimeUnit unit)
     : this(config, alpha, interval, unit, MetricContext.ForCurrentProcess)
 {
 }
Example #30
0
    /// <summary>
    /// Determines whether the specified <paramref name="config"/> is equal
    /// to the current <see cref="MetricConfig"/> object.
    /// </summary>
    /// <param name="config">
    /// The <see cref="config"/> to compare with the current
    /// <see cref="MetricConfig"/> object.
    /// </param>
    /// <returns>
    /// <c>true</c> if <paramref name="config"/> and the current
    /// <see cref="MetricConfig"/> object represents the same object;
    /// ohtherwise, <c>false</c>.
    /// </returns>
    public bool Equals(MetricConfig config) {
      if ((object) config == null) {
        return false;
      }

      return (config.Name == Name) && config.Tags.EqualsTo(Tags);
    }
Example #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Measure"/> by using
 /// the given measured value.
 /// </summary>
 /// <param name="value">
 /// The measured value.
 /// </param>
 /// <param name="config">
 /// The <see cref="MetricConfig"/> object that has produced the measure.
 /// </param>
 /// <param name="observable">
 /// A value that indicates if the measure shoud be dispatched to a
 /// <see cref="IMeasureObserver"/>.
 /// </param>
 public Measure(MetricConfig config, double value, bool observable = true)
 {
     MetricConfig = config;
     Value        = value;
     IsObservable = observable;
 }
Example #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref=" MeanRate"/> class by
 /// using the specified config, rate unit and <see cref="StopwatchClock"/>
 /// as the clock.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="rate_unit">
 /// The time unit of the meter's rate.
 /// </param>
 public MeanRate(MetricConfig config, TimeUnit rate_unit)
   : this(config, rate_unit, MetricContext.ForCurrentProcess) {
 }
Example #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>,
 /// <see cref="MetricContext"/> and <paramref name="initial"/> value.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 /// <param name="unit">
 /// The unit to be used to report the computed rate.
 /// </param>
 /// <param name="initial">
 /// The initial value of the counter.
 /// </param>
 public StepCounter(MetricConfig config, long initial, TimeUnit unit)
     : this(config, initial, unit, MetricContext.ForCurrentProcess)
 {
 }
Example #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref=" MeanRate"/> class by using
 /// the specified meter name, rate unit and clock.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="unit">
 /// The time unit of the meter's rate.
 /// </param>
 /// <param name="context">
 /// A <see cref="MetricContext"/> that contains the shared
 /// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
 /// </param>
 public MeanRate(MetricConfig config, TimeUnit unit,
   MetricContext context) : base(config, context) {
   start_time_ = context_.Tick;
   count_ = new Counter(config, 0, context);
   ticks_per_unit_ = 1.ToTicks(unit);
 }
Example #35
0
 /// <summary>
 /// Initializes a new instance of the <see cref=" Meter"/> class by using
 /// the specified config and rate unit.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="rate_unit">
 /// The time unit of the meter's rate.
 /// </param>
 public Meter(MetricConfig config, TimeUnit rate_unit)
     : this(config, rate_unit, MetricContext.ForCurrentProcess)
 {
 }
Example #36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Measure"/> by using
 /// the given measured value.
 /// </summary>
 /// <param name="value">
 /// The measured value.
 /// </param>
 /// <param name="config">
 /// The <see cref="MetricConfig"/> object that has produced the measure.
 /// </param>
 /// <param name="observable">
 /// A value that indicates if the measure shoud be dispatched to a
 /// <see cref="IMeasureObserver"/>.
 /// </param>
 public Measure(MetricConfig config, double value, bool observable = true) {
   MetricConfig = config;
   Value = value;
   IsObservable = observable;
 }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Func{T}"/>
 /// by using the specified <see cref="Func{T}"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 protected CallableGauge(MetricConfig config) : base(config)
 {
     callable_ = () => { throw new NotImplementedException(); };
 }
Example #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Histogram"/> that uses
 /// the <see cref="ExponentiallyDecayingResevoir"/> as resevoir.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="stats">
 /// A <see cref="SnapshotConfig"/> that defines the statistics that should
 /// be computed.
 /// </param>
 public Histogram(MetricConfig config, SnapshotConfig stats)
     : this(config, stats, new ExponentiallyDecayingResevoir(),
            MetricContext.ForCurrentProcess)
 {
 }
Example #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Func{T}"/>
 /// by using the specified <see cref="Func{T}"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="callable">
 /// A <see cref="Func{T}"/> that is used to compute the gauge
 /// values.
 /// </param>
 public CallableGauge(MetricConfig config, Func <double> callable)
     : base(config)
 {
     callable_ = () => CreateMeasure(callable());
 }
Example #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Histogram"/> by using the
 /// given <see cref="IResevoir"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="stats">
 /// A <see cref="SnapshotConfig"/> that defines the statistics that should
 /// be computed.
 /// </param>
 /// <param name="resevoir">
 /// A <see cref="IResevoir"/> that can be used to store the computed
 /// values.
 /// </param>
 public Histogram(MetricConfig config, SnapshotConfig stats,
                  IResevoir resevoir)
     : this(config, stats, resevoir, MetricContext.ForCurrentProcess)
 {
 }
Example #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BasicCompositeMetric"/> by
 /// using the given list of sub-metrics.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="metrics">
 /// </param>
 /// <param name="context">
 /// A <see cref="MetricContext"/> that contains the shared
 /// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
 /// </param>
 public BasicCompositeMetric(MetricConfig config,
                             IEnumerable <IMetric> metrics, MetricContext context)
     : base(config, context)
 {
     Metrics = new ReadOnlyCollection <IMetric>(metrics.ToArray());
 }
Example #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Counter"/> class that
 /// uses the specified executor to perform the counter updates (
 /// increment/decrement).
 /// </summary>
 public Counter(MetricConfig config, long initial)
   : this(config, initial, MetricContext.ForCurrentProcess) {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BasicCompositeMetric"/> by
 /// using the given list of sub-metrics.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="metrics">
 /// </param>
 /// <param name="context">
 /// A <see cref="MetricContext"/> that contains the shared
 /// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
 /// </param>
 public BasicCompositeMetric(MetricConfig config,
   IEnumerable<IMetric> metrics, MetricContext context)
   : base(config, context) {
   Metrics = new ReadOnlyCollection<IMetric>(metrics.ToArray());
 }
Example #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Timer"/> class by using
 /// the given configuration.
 /// </summary>
 /// <param name="config">
 /// </param>
 public Timer(MetricConfig config) : this(config, TimeUnit.Milliseconds)
 {
 }
Example #45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Counter"/> class.
 /// </summary>
 /// <param name="config"></param>
 /// <param name="context"></param>
 public Counter(MetricConfig config, MetricContext context)
   : this(config, 0, context) {
 }
Example #46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>,
 /// <see cref="MetricContext"/> and <paramref name="initial"/> value.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 /// <param name="initial">
 /// The initial value of the counter.
 /// </param>
 public StepCounter(MetricConfig config, long initial)
   : this(config, initial, TimeUnit.Seconds) {
 }
Example #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Counter"/> class that
 /// uses the specified executor to perform the counter updates (
 /// increment/decrement).
 /// </summary>
 public Counter(MetricConfig config, long initial, MetricContext context)
   : base(config.WithAdditionalTag(MetricType.Counter.AsTag()), context) {
   count_ = initial;
 }
Example #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractMetric"/> class
 /// by using the given <paramref name="config"/> object.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 protected AbstractMetric(MetricConfig config)
     : this(config, MetricContext.ForCurrentProcess)
 {
 }
Example #49
0
 public Timer(MetricConfig config, TimeUnit unit)
     : this(config, unit, MetricContext.ForCurrentProcess)
 {
 }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="ExponentialWeightedMovingAverage"/> class by using the
 /// given smoothing constant, a 5 seconds tick interval and and seconds as
 /// the time unit.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="alpha">
 /// The smoothing constant.
 /// </param>
 public ExponentialWeightedMovingAverage(MetricConfig config, double alpha)
   : this(config, alpha, TimeSpan.FromSeconds(kFiveSecondsInterval),
     TimeUnit.Seconds) {
 }
Example #51
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="ExponentialWeightedMovingAverage"/> class by using the
 /// given smoothing constant, expected tick interval and seconds as the
 /// time unit.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="alpha">
 /// The smoothing constant.
 /// </param>
 /// <param name="interval">
 /// The expected tick interval.
 /// </param>
 public ExponentialWeightedMovingAverage(MetricConfig config, double alpha,
                                         TimeSpan interval) : this(config, alpha, interval, TimeUnit.Seconds)
 {
 }
Example #52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Func{T}"/>
 /// by using the specified <see cref="Func{T}"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="callable">
 /// A <see cref="Func{T}"/> that is used to compute the gauge
 /// values.
 /// </param>
 public CallableGauge(MetricConfig config, Func<Measure> callable)
   : base(config) {
   callable_ = callable;
 }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="ExponentialWeightedMovingAverage"/> class by using the
 /// specified smoothing constant, expected tick interval and time unit of
 /// the tick interval.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="alpha">
 /// The smoothing constant.
 /// </param>
 /// <param name="interval">
 /// The expected tick interval.
 /// </param>
 /// <param name="unit">
 /// The time unit that should be used to compute the rate.
 /// </param>
 /// <param name="context">
 /// A <see cref="MetricContext"/> that contains the shared
 /// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
 /// </param>
 public ExponentialWeightedMovingAverage(MetricConfig config, double alpha,
   TimeSpan interval, TimeUnit unit, MetricContext context)
   : base(config.WithAdditionalTag(MetricType.EWMA.AsTag()), context) {
   interval_ = interval.Ticks;
   alpha_ = alpha;
   ticks_per_unit_ = 1.ToTicks(unit);
   uncounted_ = 0;
   rate_ = 0.0;
   last_tick_ = context_.Tick;
   initialized_ = false;
 }
Example #54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>.
 /// </summary>
 /// <param name="unit">
 /// The unit to be used to report the computed rate.
 /// </param>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 public StepCounter(MetricConfig config, TimeUnit unit)
     : this(config, 0, unit)
 {
 }
Example #55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepMaxGauge"/>
 /// class by using the given <see cref="MetricConfig"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that shoud be used by the <see cref="StepMaxGauge"/> object.
 /// </param>
 public StepMaxGauge(MetricConfig config)
 {
     max_gauge_ = new MaxGauge(config);
 }
Example #56
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>,
 /// <see cref="MetricContext"/> and <paramref name="initial"/> value.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 /// <param name="initial">
 /// The initial value of the counter.
 /// </param>
 public StepCounter(MetricConfig config, long initial)
     : this(config, initial, TimeUnit.Seconds)
 {
 }
Example #57
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Func{T}"/>
 /// by using the specified <see cref="Func{T}"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 protected CallableGauge(MetricConfig config) : base(config) {
   callable_ = () => { throw new NotImplementedException(); };
 }
Example #58
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 public StepCounter(MetricConfig config)
   : this(config, TimeUnit.Seconds) {
 }
Example #59
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Func{T}"/>
 /// by using the specified <see cref="Func{T}"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> containing the configuration settings
 /// for the metric.
 /// </param>
 /// <param name="callable">
 /// A <see cref="Func{T}"/> that is used to compute the gauge
 /// values.
 /// </param>
 public CallableGauge(MetricConfig config, Func<double> callable)
   : base(config) {
   callable_ = () => CreateMeasure(callable());
 }
Example #60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StepCounter"/> class
 /// by using the given <see cref="MetricConfig"/>.
 /// </summary>
 /// <param name="config">
 /// A <see cref="MetricConfig"/> object containing the configuration
 /// that should be used by the <see cref="StepCounter"/> object.
 /// </param>
 public StepCounter(MetricConfig config)
     : this(config, TimeUnit.Seconds)
 {
 }