public abstract class AbstractMetricManager extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected static boolean |
isEnableMetric
Is metric service enabled
|
protected static MetricConfig |
METRIC_CONFIG |
protected Map<MetricInfo,IMetric> |
metrics
metric type -> metric name -> metric info
|
protected Map<String,MetricInfo.MetaInfo> |
nameToTagInfo
metric name -> tag keys
|
| 构造器和说明 |
|---|
AbstractMetricManager() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
count(long delta,
String name,
MetricLevel metricLevel,
String... tags)
Update counter. if exists, then update counter by delta. if not, then create and update.
|
protected abstract <T> Gauge |
createAutoGauge(MetricInfo metricInfo,
T obj,
ToLongFunction<T> mapper) |
protected abstract Counter |
createCounter(MetricInfo metricInfo) |
protected abstract Gauge |
createGauge(MetricInfo metricInfo) |
protected abstract Histogram |
createHistogram(MetricInfo metricInfo) |
protected abstract Rate |
createRate(MetricInfo metricInfo) |
protected abstract Timer |
createTimer(MetricInfo metricInfo) |
boolean |
equals(Object o) |
void |
gauge(long value,
String name,
MetricLevel metricLevel,
String... tags)
Set value of gauge. if exists, then set gauge by value. if not, then create and set.
|
protected Map<String[],Counter> |
getAllCounters()
Get all counters
|
protected Map<String[],Gauge> |
getAllGauges()
Get all gauges
|
protected Map<String[],Histogram> |
getAllHistograms()
Get all histograms
|
protected List<String[]> |
getAllMetricKeys()
Get all metric keys.
|
protected Map<String[],Rate> |
getAllRates()
Get all rates
|
protected Map<String[],Timer> |
getAllTimers()
Get all timers
|
<T> Gauge |
getOrCreateAutoGauge(String name,
MetricLevel metricLevel,
T obj,
ToLongFunction<T> mapper,
String... tags)
Get autoGauge. return if exists, create if not.
|
Counter |
getOrCreateCounter(String name,
MetricLevel metricLevel,
String... tags)
Get counter. return if exists, create if not.
|
Gauge |
getOrCreateGauge(String name,
MetricLevel metricLevel,
String... tags)
Get counter. return if exists, create if not.
|
Histogram |
getOrCreateHistogram(String name,
MetricLevel metricLevel,
String... tags)
Get histogram. return if exists, create if not.
|
Rate |
getOrCreateRate(String name,
MetricLevel metricLevel,
String... tags)
Get rate. return if exists, create if not.
|
Timer |
getOrCreateTimer(String name,
MetricLevel metricLevel,
String... tags)
Get timer. return if exists, create if not.
|
int |
hashCode() |
void |
histogram(long value,
String name,
MetricLevel metricLevel,
String... tags)
Update histogram. if exists, then update histogram by value. if not, then create and update
|
boolean |
isEnableMetric()
Is metric service enabled
|
boolean |
isEnableMetricInGivenLevel(MetricLevel metricLevel)
Is metric service enabled in specific level
|
void |
rate(long value,
String name,
MetricLevel metricLevel,
String... tags)
Mark rate. if exists, then mark rate by value. if not, then create and mark.
|
protected abstract void |
remove(MetricType type,
MetricInfo metricInfo) |
void |
remove(MetricType type,
String name,
String... tags)
remove name
|
protected boolean |
stop()
Stop and clear metric manager
|
protected abstract boolean |
stopFramework() |
void |
timer(long delta,
TimeUnit timeUnit,
String name,
MetricLevel metricLevel,
String... tags)
Update timer. if exists, then update timer by delta and timeUnit. if not, then create and
update
|
protected static final MetricConfig METRIC_CONFIG
protected static boolean isEnableMetric
protected Map<String,MetricInfo.MetaInfo> nameToTagInfo
protected Map<MetricInfo,IMetric> metrics
public Counter getOrCreateCounter(String name, MetricLevel metricLevel, String... tags)
name - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"protected abstract Counter createCounter(MetricInfo metricInfo)
public <T> Gauge getOrCreateAutoGauge(String name, MetricLevel metricLevel, T obj, ToLongFunction<T> mapper, String... tags)
AutoGauge keep a weak reference of the obj, so it will not prevent gc of the obj. Notice: if you call this gauge's value() when the obj has already been cleared by gc, then you will get 0L.
name - the name of namemetricLevel - the level of nameobj - which will be monitored automaticallymapper - use which to map the obj to a long valueprotected abstract <T> Gauge createAutoGauge(MetricInfo metricInfo, T obj, ToLongFunction<T> mapper)
public Gauge getOrCreateGauge(String name, MetricLevel metricLevel, String... tags)
name - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"protected abstract Gauge createGauge(MetricInfo metricInfo)
public Rate getOrCreateRate(String name, MetricLevel metricLevel, String... tags)
name - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"protected abstract Rate createRate(MetricInfo metricInfo)
public Histogram getOrCreateHistogram(String name, MetricLevel metricLevel, String... tags)
name - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"protected abstract Histogram createHistogram(MetricInfo metricInfo)
public Timer getOrCreateTimer(String name, MetricLevel metricLevel, String... tags)
name - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"protected abstract Timer createTimer(MetricInfo metricInfo)
public void count(long delta,
String name,
MetricLevel metricLevel,
String... tags)
delta - the value to updatename - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"public void gauge(long value,
String name,
MetricLevel metricLevel,
String... tags)
value - the value of gaugename - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"public void rate(long value,
String name,
MetricLevel metricLevel,
String... tags)
value - the value to markname - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"public void histogram(long value,
String name,
MetricLevel metricLevel,
String... tags)
value - the value to updatename - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"public void timer(long delta,
TimeUnit timeUnit,
String name,
MetricLevel metricLevel,
String... tags)
delta - the value to updatetimeUnit - the unit of deltaname - the name of namemetricLevel - the level of nametags - string pairs, like sg="ln" will be "sg", "ln"protected List<String[]> getAllMetricKeys()
protected Map<String[],Counter> getAllCounters()
protected Map<String[],Gauge> getAllGauges()
protected Map<String[],Histogram> getAllHistograms()
protected Map<String[],Timer> getAllTimers()
public void remove(MetricType type, String name, String... tags)
type - the type of namename - the name of nametags - string pairs, like sg="ln" will be "sg", "ln"protected abstract void remove(MetricType type, MetricInfo metricInfo)
public boolean isEnableMetric()
public boolean isEnableMetricInGivenLevel(MetricLevel metricLevel)
protected boolean stop()
protected abstract boolean stopFramework()
Copyright © 2022 The Apache Software Foundation. All rights reserved.