@ThreadSafe public final class MetricsSystem extends Object
Modifier and Type | Class and Description |
---|---|
static class |
MetricsSystem.InstanceType
An enum of supported instance type.
|
static class |
MetricsSystem.MultiTimerContext
A timer context with multiple timers.
|
Modifier and Type | Field and Description |
---|---|
static String |
CLUSTER |
static com.codahale.metrics.MetricRegistry |
METRIC_REGISTRY |
static String |
SINK_REGEX |
Modifier and Type | Method and Description |
---|---|
static Map<String,MetricValue> |
allMetrics() |
static void |
checkMinimalPollingPeriod(TimeUnit pollUnit,
int pollPeriod)
Checks if the poll period is smaller that the minimal poll period which is 1 second.
|
static void |
clearAllMetrics()
Resets the metric registry and removes all the metrics.
|
static com.codahale.metrics.Counter |
counter(String name)
Get or add counter with the given name.
|
static com.codahale.metrics.Counter |
counterWithTags(String name,
boolean shouldReport,
String... tags)
Get or add counter with the given name with tags.
|
static String |
escape(AlluxioURI uri)
Escapes a URI, replacing "/" with "%2F".
|
static String |
getHubAgentMetricName(String name)
Builds metric registry name for hub agent instance.
|
static String |
getHubManagerMetricName(String name)
Builds metric registry name for hub manager instance.
|
static String |
getJobWorkerMetricName(String name)
Builds metric registry name for job worker instance.
|
static String |
getMasterMetricName(String name)
Builds metric registry names for master instance.
|
static Map<String,Set<Metric>> |
getMasterMetrics(Set<String> metricNames)
Gets all the master metrics belongs to the given metric names.
|
static String |
getMetricName(String name)
Converts a simple string to a qualified metric name based on the process type.
|
static Metric |
getMetricValue(String fullName)
Gets metric with the given full metric name.
|
static int |
getNumSinks() |
static String |
getResourcePoolMetricName(Object obj)
Get metrics name based on class.
|
static void |
initShouldReportMetrics(MetricsSystem.InstanceType instanceType)
Initialize the
SHOULD_REPORT_METRICS . |
static com.codahale.metrics.Meter |
meter(String name)
Get or add meter with the given name.
|
static com.codahale.metrics.Meter |
meterWithTags(String name,
boolean shouldReport,
String... tags)
Get or add meter with the given name.
|
static <T> void |
registerCachedGaugeIfAbsent(String name,
com.codahale.metrics.Gauge<T> metric)
Registers a cached gauge if it has not been registered.
|
static <T> void |
registerGaugeIfAbsent(String name,
com.codahale.metrics.Gauge<T> metric)
Registers a gauge if it has not been registered.
|
static List<Metric> |
reportClientMetrics() |
static List<Metric> |
reportWorkerMetrics() |
static void |
resetAllMetrics()
Resets all the metrics in the MetricsSystem.
|
static void |
resetCountersAndGauges()
Resets all counters to 0 and unregisters gauges for testing.
|
static void |
startSinks(String metricsConfFile)
Starts sinks specified in the configuration.
|
static void |
startSinksFromConfig(MetricsConfig config)
Starts sinks from a given metrics configuration.
|
static void |
stopSinks()
Stops all the sinks.
|
static String |
stripInstanceAndHost(String metricsName)
Removes the instance and host from the given metric name, returning the result.
|
static com.codahale.metrics.Timer |
timer(String name)
Get or add timer with the given name.
|
static String |
unescape(String uri)
Unescapes a URI, reverts it to before the escape, to display it correctly.
|
public static final String CLUSTER
public static final com.codahale.metrics.MetricRegistry METRIC_REGISTRY
public static final String SINK_REGEX
public static void startSinks(String metricsConfFile)
metricsConfFile
- the location of the metrics configuration filepublic static void startSinksFromConfig(MetricsConfig config)
config
- the metrics configpublic static void stopSinks()
public static int getNumSinks()
public static String getResourcePoolMetricName(Object obj)
obj
- object for the resource poolpublic static String getMetricName(String name)
name
- the name of the metricpublic static String getMasterMetricName(String name)
name
- the metric namepublic static String getJobWorkerMetricName(String name)
name
- the metric namepublic static String getHubAgentMetricName(String name)
name
- the metric namepublic static String getHubManagerMetricName(String name)
name
- the metric namepublic static void checkMinimalPollingPeriod(TimeUnit pollUnit, int pollPeriod) throws IllegalArgumentException
pollUnit
- the polling unitpollPeriod
- the polling periodIllegalArgumentException
- if the polling period is invalidpublic static String stripInstanceAndHost(String metricsName)
metricsName
- the long metrics name with instance and host namepublic static String escape(AlluxioURI uri)
uri
- the URI to escapepublic static String unescape(String uri)
uri
- the escaped URI to unescapepublic static com.codahale.metrics.Counter counter(String name)
name
- the name of the metricpublic static com.codahale.metrics.Counter counterWithTags(String name, boolean shouldReport, String... tags)
name
- the metric nameshouldReport
- whether this metric should be reportedtags
- the tag name and tag value pairspublic static com.codahale.metrics.Meter meter(String name)
resetAllMetrics()
name
- the name of the metricpublic static com.codahale.metrics.Meter meterWithTags(String name, boolean shouldReport, String... tags)
resetAllMetrics()
If this metric can be aggregated at cluster level and should report to leading master,
add it to the should report metrics map.
This method is added to add worker metrics with ufs tags into the should report metrics map.name
- the name of the metricshouldReport
- whether this metric should be reportedtags
- the tag name and tag value pairspublic static com.codahale.metrics.Timer timer(String name)
resetAllMetrics()
name
- the name of the metricpublic static <T> void registerGaugeIfAbsent(String name, com.codahale.metrics.Gauge<T> metric)
T
- the typename
- the gauge namemetric
- the gaugepublic static <T> void registerCachedGaugeIfAbsent(String name, com.codahale.metrics.Gauge<T> metric)
T
- the typename
- the gauge namemetric
- the gaugepublic static List<Metric> reportWorkerMetrics()
public static List<Metric> reportClientMetrics()
public static Map<String,Set<Metric>> getMasterMetrics(Set<String> metricNames)
metricNames
- the name of the metrics to get@Nullable public static Metric getMetricValue(String fullName)
fullName
- the full name of the metric to getpublic static Map<String,MetricValue> allMetrics()
MetricValue
public static void initShouldReportMetrics(MetricsSystem.InstanceType instanceType)
SHOULD_REPORT_METRICS
. This should be called only once.
Note that this method is able to catch most of the should report metrics
except worker metrics with ufs tags.instanceType
- the instance typepublic static void resetAllMetrics()
public static void clearAllMetrics()
public static void resetCountersAndGauges()
Copyright © 2023. All Rights Reserved.