001package org.avaje.metric.spi; 002 003import java.util.Collection; 004import java.util.List; 005 006import org.avaje.metric.*; 007import org.avaje.metric.statistics.MetricStatistics; 008 009/** 010 * The SPI for the underlying implementation that is plugged in via service locator. 011 */ 012public interface SpiMetricManager extends JvmMetrics, RequestTimingManager { 013 014 /** 015 * Create a MetricName based on the class and name. 016 * Typically name is a method name. 017 */ 018 MetricName name(Class<?> cls, String name); 019 020 /** 021 * Create a Metric name by parsing a name that is expected to include periods. 022 * <p> 023 * The name is expected to be in dot notation similar to <code>package.class.method</code>. 024 */ 025 MetricName name(String name); 026 027 /** 028 * Return the TimedMetric using the metric name. 029 */ 030 TimedMetric getTimedMetric(MetricName name); 031 032 /** 033 * Return the BucketTimedMetric using the given base metric name and bucketRanges. 034 * 035 * @param name 036 * The metric name 037 * @param bucketRanges 038 * Time in milliseconds which are used to create buckets. 039 */ 040 TimedMetric getTimedMetric(MetricName name, int... bucketRanges); 041 042 /** 043 * Return the CounterMetric using the metric name. 044 */ 045 CounterMetric getCounterMetric(MetricName name); 046 047 /** 048 * Return the ValueMetric using the metric name. 049 */ 050 ValueMetric getValueMetric(MetricName name); 051 052 /** 053 * Return the TimedMetricGroup using the given base metric name. 054 */ 055 TimedMetricGroup getTimedMetricGroup(MetricName baseName); 056 057 /** 058 * Return the MetricNameCache using the class as a base name. 059 */ 060 MetricNameCache getMetricNameCache(Class<?> cls); 061 062 /** 063 * Return the MetricNameCache using a MetricName as a base name. 064 */ 065 MetricNameCache getMetricNameCache(MetricName baseName); 066 067 /** 068 * Return the collection of metrics that are considered non-empty. This means these are metrics 069 * that have collected statistics since the last time they were collected. 070 * <p> 071 * This gets the non emtpy metrics to add themselves to the report list. 072 * </p> 073 */ 074 List<MetricStatistics> collectNonEmptyMetrics(); 075 076 /** 077 * Return the collection of JVM metrics that are non-empty (for reporting). 078 */ 079 List<MetricStatistics> collectNonEmptyJvmMetrics(); 080 081 /** 082 * Return a collection of all the metrics. 083 */ 084 Collection<Metric> getMetrics(); 085 086 /** 087 * Return a collection of the JVM metrics. 088 */ 089 Collection<Metric> getJvmMetrics(); 090 091 /** 092 * Create and register a GaugeMetric using the gauge supplied (double values). 093 */ 094 GaugeDoubleMetric register(MetricName name, GaugeDouble gauge); 095 096 /** 097 * Create and register a GaugeCounterMetric using the gauge supplied (long values). 098 */ 099 GaugeLongMetric register(MetricName name, GaugeLong gauge); 100 101 /** 102 * When a request completes it is reported to the manager. 103 */ 104 void reportTiming(RequestTiming requestTiming); 105 106 /** 107 * Add a metric supplier. 108 */ 109 void addSupplier(MetricSupplier supplier); 110 111}