public static MeterMetric New(string eventType, TimeUnit rateUnit) { var meter = new MeterMetric(eventType, rateUnit); meter.Start(); return(meter); }
private TimerMetric(TimeUnit durationUnit, TimeUnit rateUnit, MeterMetric meter, HistogramMetric histogram, bool clear) { DurationUnit = durationUnit; RateUnit = rateUnit; _meter = meter; _histogram = histogram; if (clear) { Clear(); } }
/// <summary> /// Creates a new meter metric and registers it under the given type and name /// </summary> /// <param name="type">The type that owns the 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="rateUnit">The rate unit of the new meter</param> /// <returns></returns> public MeterMetric Meter(Type type, string name, string eventType, TimeUnit rateUnit) { var metricName = new MetricName(type, name); if (_store.TryGetValue(metricName, out var existingMetric)) { return((MeterMetric)existingMetric); } var metric = MeterMetric.New(eventType, rateUnit); var justAddedMetric = _store.GetOrAdd(metricName, metric); return(justAddedMetric == null ? metric : (MeterMetric)justAddedMetric); }
public TimerMetric(TimeUnit durationUnit, TimeUnit rateUnit) : this(durationUnit, rateUnit, MeterMetric.New("calls", rateUnit), new HistogramMetric(SampleType.Biased), true) { }