public enum MetricManager extends Enum<MetricManager>
MetricRegistry
. Borrowed from Titan's approach to
managing Metrics.Enum Constant and Description |
---|
INSTANCE |
Modifier and Type | Method and Description |
---|---|
void |
addConsoleReporter(long reportIntervalInMS)
Create a
ConsoleReporter attached to the MetricsRegistry . |
void |
addCsvReporter(long reportIntervalInMS,
String output)
Create a
CsvReporter attached to the MetricsRegistry . |
void |
addGangliaReporter(String groupOrHost,
int port,
String addressingMode,
int ttl,
Boolean protocol31,
UUID hostUUID,
String spoof,
long reportIntervalInMS)
Create a
GangliaReporter attached to the MetricsRegistry . |
void |
addGraphiteReporter(String host,
int port,
String prefix,
long reportIntervalInMS)
Create a
GraphiteReporter attached to the MetricsRegistry . |
void |
addJmxReporter(String domain,
String agentId)
Create a
JmxReporter attached to the MetricsRegistry . |
void |
addSlf4jReporter(long reportIntervalInMS,
String loggerName)
Create a
Slf4jReporter attached to the MetricsRegistry . |
Counter |
getCounter(String name) |
Counter |
getCounter(String prefix,
String... names) |
<T> <any> |
getGuage(<any> gauge,
String name) |
<T> <any> |
getGuage(<any> gauge,
String prefix,
String... names) |
Histogram |
getHistogram(String name) |
Histogram |
getHistogram(String prefix,
String... names) |
Meter |
getMeter(String name) |
Meter |
getMeter(String prefix,
String... names) |
MetricRegistry |
getRegistry()
Return the
MetricsRegistry . |
Timer |
getTimer(String name) |
Timer |
getTimer(String prefix,
String... names) |
void |
registerGremlinScriptEngineMetrics(GremlinScriptEngine engine,
String... prefix)
Registers metrics from a
GremlinScriptEngine . |
void |
removeAllMetrics() |
void |
removeAllReporters()
Remove all reporters previously configured through the
add* methods on this class. |
void |
removeConsoleReporter()
Stop a
ConsoleReporter previously created by a call to
addConsoleReporter(long) and release it for GC. |
void |
removeCsvReporter()
Stop a
CsvReporter previously created by a call to
addCsvReporter(long, String) and release it for GC. |
void |
removeGangliaReporter()
Stop a
GangliaReporter previously created by a call to
addGangliaReporter(String, int, GMetric.UDPAddressingMode, int, Boolean, UUID, long)
and release it for GC. |
void |
removeGraphiteReporter()
Stop a
GraphiteReporter previously created by a call to
addGraphiteReporter(String, int, String, long) and release it
for GC. |
void |
removeJmxReporter()
Stop a
JmxReporter previously created by a call to
addJmxReporter(String, String) and release it for GC. |
void |
removeSlf4jReporter()
Stop a
Slf4jReporter previously created by a call to
addSlf4jReporter(long, String) and release it for GC. |
static MetricManager |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static MetricManager[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final MetricManager INSTANCE
public static MetricManager[] values()
for (MetricManager c : MetricManager.values()) System.out.println(c);
public static MetricManager valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic MetricRegistry getRegistry()
MetricsRegistry
.MetricRegistry
used for all of monitoringpublic void addConsoleReporter(long reportIntervalInMS)
ConsoleReporter
attached to the MetricsRegistry
.reportIntervalInMS
- milliseconds to wait between dumping metrics to the consolepublic void removeConsoleReporter()
ConsoleReporter
previously created by a call to
addConsoleReporter(long)
and release it for GC. Idempotent
between calls to the associated add method. Does nothing before the first
call to the associated add method.public void addCsvReporter(long reportIntervalInMS, String output)
CsvReporter
attached to the MetricsRegistry
.
The output
argument must be non-null but need not exist. If it
doesn't already exist, this method attempts to create it by calling
File.mkdirs()
.reportIntervalInMS
- milliseconds to wait between dumping metrics to CSV files in
the configured directoryoutput
- the path to a directory into which Metrics will periodically
write CSV datapublic void removeCsvReporter()
CsvReporter
previously created by a call to
addCsvReporter(long, String)
and release it for GC. Idempotent
between calls to the associated add method. Does nothing before the first
call to the associated add method.public void addJmxReporter(String domain, String agentId)
JmxReporter
attached to the MetricsRegistry
.
If domain
or agentId
is null, then Metrics's uses its own
internal default value(s).
If agentId
is non-null, then
MBeanServerFactory#findMBeanServer(agentId) must return exactly
one MBeanServer
. The reporter will register with that server. If
the findMBeanServer(agentId)
call returns no or multiple servers,
then this method logs an error and falls back on the Metrics default for
agentId
.domain
- the JMX domain in which to continuously expose metricsagentId
- the JMX agent IDpublic void removeJmxReporter()
JmxReporter
previously created by a call to
addJmxReporter(String, String)
and release it for GC. Idempotent
between calls to the associated add method. Does nothing before the first
call to the associated add method.public void addSlf4jReporter(long reportIntervalInMS, String loggerName)
Slf4jReporter
attached to the MetricsRegistry
.
If loggerName
is null, or if it is non-null but
LoggerFactory.getLogger(loggerName) returns null, then Metrics's
default Slf4j logger name is used instead.reportIntervalInMS
- milliseconds to wait between writing metrics to the Slf4j
loggerloggerName
- the name of the Slf4j logger that receives metricspublic void removeSlf4jReporter()
Slf4jReporter
previously created by a call to
addSlf4jReporter(long, String)
and release it for GC. Idempotent
between calls to the associated add method. Does nothing before the first
call to the associated add method.public void addGangliaReporter(String groupOrHost, int port, String addressingMode, int ttl, Boolean protocol31, UUID hostUUID, String spoof, long reportIntervalInMS) throws IOException
GangliaReporter
attached to the MetricsRegistry
.
groupOrHost
and addressingMode
must be non-null. The
remaining non-primitive arguments may be null. If protocol31
is
null, then true is assumed. Null values of hostUUID
or
spoof
are passed into the GMetric
constructor, which
causes Ganglia to use its internal logic for generating a default UUID
and default reporting hostname (respectively).groupOrHost
- the multicast group or unicast hostname to which Ganglia
events are sentport
- the port to which events are sentaddressingMode
- whether to send events with multicast or unicastttl
- multicast ttl (ignored for unicast)protocol31
- true to use Ganglia protocol version 3.1, false to use 3.0hostUUID
- uuid for the hostspoof
- override this machine's IP/hostname as it appears on the
Ganglia serverreportIntervalInMS
- milliseconds to wait before sending data to the ganglia
unicast host or multicast groupIOException
- when a GMetric
can't be instantiated using the
provided argumentspublic void removeGangliaReporter()
GangliaReporter
previously created by a call to
addGangliaReporter(String, int, GMetric.UDPAddressingMode, int, Boolean, UUID, long)
and release it for GC. Idempotent between calls to the associated add
method. Does nothing before the first call to the associated add method.public void addGraphiteReporter(String host, int port, String prefix, long reportIntervalInMS)
GraphiteReporter
attached to the MetricsRegistry
.
If prefix
is null, then Metrics's internal default prefix is used
(empty string at the time this comment was written).host
- the host to which Graphite reports are sentport
- the port to which Graphite reports are sentprefix
- the optional metrics prefixreportIntervalInMS
- milliseconds to wait between sending metrics to the configured
Graphite host and portpublic void removeGraphiteReporter()
GraphiteReporter
previously created by a call to
addGraphiteReporter(String, int, String, long)
and release it
for GC. Idempotent between calls to the associated add method. Does
nothing before the first call to the associated add method.public void removeAllReporters()
add*
methods on this class.public void removeAllMetrics()
public Counter getCounter(String name)
public <T> <any> getGuage(<any> gauge, String name)
public Meter getMeter(String name)
public Timer getTimer(String name)
public Histogram getHistogram(String name)
public void registerGremlinScriptEngineMetrics(GremlinScriptEngine engine, String... prefix)
GremlinScriptEngine
. At this point, this only works for the
GremlinGroovyScriptEngine
as it is the only one that collects metrics at this point. As the
GremlinScriptEngine
implementations achieve greater parity these metrics will get expanded.Copyright © 2013–2019 Apache Software Foundation. All rights reserved.