コード例 #1
0
        public SampleMetrics(IMetrics metrics)
        {
            _metrics = metrics;
            _concurrentRequestsCounter = _metrics.Provider.Counter.Instance(SampleMetricsRegistry.Counters.ConcurrentRequestsCounter);
            _histogramOfData = _metrics.Provider.Histogram.Instance(SampleMetricsRegistry.Histograms.ResultsExample);
            _meter = _metrics.Provider.Meter.Instance(SampleMetricsRegistry.Meters.Requests);
            _setCounter = _metrics.Provider.Counter.Instance(SampleMetricsRegistry.Counters.SetCounter);
            _setMeter = _metrics.Provider.Meter.Instance(SampleMetricsRegistry.Meters.SetMeter);
            _timer = _metrics.Provider.Timer.Instance(SampleMetricsRegistry.Timers.Requests);
            _totalRequestsCounter = _metrics.Provider.Counter.Instance(SampleMetricsRegistry.Counters.Requests);

            // define a simple gauge that will provide the instant value of someValue when requested
            _metrics.Measure.Gauge.SetValue(SampleMetricsRegistry.Gauges.DataValue, () => _someValue);

            _metrics.Measure.Gauge.SetValue(
                SampleMetricsRegistry.Gauges.CustomRatioGauge,
                () => _totalRequestsCounter.GetValueOrDefault().Count / _meter.GetValueOrDefault().FiveMinuteRate);

            _metrics.Measure.Gauge.SetValue(SampleMetricsRegistry.Gauges.Ratio, () => new HitRatioGauge(_meter, _timer, m => m.OneMinuteRate));
        }
コード例 #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="HitPercentageGauge" /> class.
 /// </summary>
 /// <param name="hitMeter">The numerator meter to use.</param>
 /// <param name="totalMeter">The denominator meter to use.</param>
 /// <param name="meterRateFunc">
 ///     The function to extract a value from the MeterValue. Will be applied to both the numerator
 ///     and denominator meters.
 /// </param>
 /// <remarks>
 ///     Creates a new HitPercentageGauge with externally tracked Meters, and uses the provided meter rate function to
 ///     extract the value for the percentage.
 /// </remarks>
 // ReSharper disable MemberCanBePrivate.Global
 public HitPercentageGauge(IMeter hitMeter, IMeter totalMeter, Func <MeterValue, double> meterRateFunc)
 // ReSharper restore MemberCanBePrivate.Global
     : base(() => meterRateFunc(hitMeter.GetValueOrDefault()), () => meterRateFunc(totalMeter.GetValueOrDefault()))
 {
 }
コード例 #3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="HitRatioGauge" /> class.
 /// </summary>
 /// <param name="hitMeter">The numerator meter to use for the ratio.</param>
 /// <param name="totalTimer">The denominator timer to use for the ratio.</param>
 /// <param name="meterRateFunc">
 ///     The function to extract a value from the MeterValue. Will be applied to both the numerator
 ///     and denominator meters.
 /// </param>
 /// <remarks>
 ///     Creates a new HitRatioGauge with externally tracked Meter and Timer, and uses the provided meter rate function to
 ///     extract the value for the ratio.
 /// </remarks>
 public HitRatioGauge(IMeter hitMeter, ITimer totalTimer, Func <MeterValue, double> meterRateFunc)
     : base(() => meterRateFunc(hitMeter.GetValueOrDefault()), () => meterRateFunc(totalTimer.GetValueOrDefault().Rate))
 {
 }
コード例 #4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="HitPercentageGauge" /> class.
 /// </summary>
 /// <param name="hitMeter">The numerator meter to use.</param>
 /// <param name="totalMeter">The denominator meter to use.</param>
 /// <param name="meterRateFunc">
 ///     The function to extract a value from the MeterValue. Will be applied to both the numerator
 ///     and denominator meters.
 /// </param>
 /// <remarks>
 ///     Creates a new HitPercentageGauge with externally tracked Meters, and uses the provided meter rate function to
 ///     extract the value for the percentage.
 /// </remarks>
 public HitPercentageGauge(IMeter hitMeter, IMeter totalMeter, Func <MeterValue, double> meterRateFunc)
     : base(() => meterRateFunc(hitMeter.GetValueOrDefault()), () => meterRateFunc(totalMeter.GetValueOrDefault()))
 {
 }