...
Code Block | ||
---|---|---|
| ||
public class Metrics { /** The metrics reporters container. */ private final List<MetricsReporter> reporters; /** The metrics group. */ private final MetricGroupList<MetricGroup> metricGroupmetricGroups; /** Register metrics to MetricGroup. @param name The name of metric. @param metric The metric to register. */ public void registerMetrics(String name, Metric metric, int groupIndex) {} } |
MetricGroup
MetricGroup
is a class responsible for metrics registering and tagging, there is a metrics container in it. It provides register method for each type of measurable metric, registering metrics will put metrics to the metrics container.
Code Block | ||
---|---|---|
| ||
public class MetricGroup { /** tags of metric group. */ private final Map<String, Set<String>> tags = new HashMap<>(); /** Map of gauge metrics. */ private final Map<String, Gauge<?>> gauges = new HashMap<>(); /** Map of counter metrics. */ private final Map<String, Counter> counters = new HashMap<>(); /** Map of counter metrics. */ private final Map<String, Histogram> histograms = new HashMap<>(); /** Register gauge metric. */ public void gauge(String name, Gauge gauge) {} /** Register counter metric. */ public void counter(String name, Counter counter) {} /** Register histogram metric. */ public void histogram(String name, Histogram counter) {} /** Add tag for metricsmetric group. */ public void addTag(Metric metric, String tag, String value) {} } |
...
Take CommitMetrics
as example, the CommitMetrics
will be instantiated by FileStoreCommitImpl
, then commit related metrics will be registered by the corresponding MetricGroup in singleton the
Metrics instance
.
The
Metrics
has instance of MetricGroup
MetricGroups
and MetricsReporters
set. MetricGroup
maintains metrics map containers. Metrics registering is a process of putting metrics instances into the metric (gauge, counter) map container.
...