Package com.codahale.metrics
Class ConsoleReporter.Builder
- java.lang.Object
-
- com.codahale.metrics.ConsoleReporter.Builder
-
- Enclosing class:
- ConsoleReporter
public static class ConsoleReporter.Builder extends Object
A builder forConsoleReporter
instances. Defaults to using the default locale and time zone, writing toSystem.out
, converting rates to events/second, converting durations to milliseconds, and not filtering metrics.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConsoleReporter
build()
Builds aConsoleReporter
with the given properties.ConsoleReporter.Builder
convertDurationsTo(TimeUnit durationUnit)
Convert durations to the given time unit.ConsoleReporter.Builder
convertRatesTo(TimeUnit rateUnit)
Convert rates to the given time unit.ConsoleReporter.Builder
disabledMetricAttributes(Set<MetricAttribute> disabledMetricAttributes)
Don't report the passed metric attributes for all metrics (e.g.ConsoleReporter.Builder
filter(MetricFilter filter)
Only report metrics which match the given filter.ConsoleReporter.Builder
formattedFor(Locale locale)
Format numbers for the givenLocale
.ConsoleReporter.Builder
formattedFor(TimeZone timeZone)
Use the givenTimeZone
for the time.ConsoleReporter.Builder
outputTo(PrintStream output)
Write to the givenPrintStream
.ConsoleReporter.Builder
scheduleOn(ScheduledExecutorService executor)
Specifies the executor to use while scheduling reporting of metrics.ConsoleReporter.Builder
shutdownExecutorOnStop(boolean shutdownExecutorOnStop)
Specifies whether or not, the executor (used for reporting) will be stopped with same time with reporter.ConsoleReporter.Builder
withClock(Clock clock)
Use the givenClock
instance for the time.
-
-
-
Method Detail
-
shutdownExecutorOnStop
public ConsoleReporter.Builder shutdownExecutorOnStop(boolean shutdownExecutorOnStop)
Specifies whether or not, the executor (used for reporting) will be stopped with same time with reporter. Default value is true. Setting this parameter to false, has the sense in combining with providing external managed executor viascheduleOn(ScheduledExecutorService)
.- Parameters:
shutdownExecutorOnStop
- if true, then executor will be stopped in same time with this reporter- Returns:
this
-
scheduleOn
public ConsoleReporter.Builder scheduleOn(ScheduledExecutorService executor)
Specifies the executor to use while scheduling reporting of metrics. Default value is null. Null value leads to executor will be auto created on start.- Parameters:
executor
- the executor to use while scheduling reporting of metrics.- Returns:
this
-
outputTo
public ConsoleReporter.Builder outputTo(PrintStream output)
Write to the givenPrintStream
.- Parameters:
output
- aPrintStream
instance.- Returns:
this
-
formattedFor
public ConsoleReporter.Builder formattedFor(Locale locale)
Format numbers for the givenLocale
.- Parameters:
locale
- aLocale
- Returns:
this
-
withClock
public ConsoleReporter.Builder withClock(Clock clock)
Use the givenClock
instance for the time.- Parameters:
clock
- aClock
instance- Returns:
this
-
formattedFor
public ConsoleReporter.Builder formattedFor(TimeZone timeZone)
Use the givenTimeZone
for the time.- Parameters:
timeZone
- aTimeZone
- Returns:
this
-
convertRatesTo
public ConsoleReporter.Builder convertRatesTo(TimeUnit rateUnit)
Convert rates to the given time unit.- Parameters:
rateUnit
- a unit of time- Returns:
this
-
convertDurationsTo
public ConsoleReporter.Builder convertDurationsTo(TimeUnit durationUnit)
Convert durations to the given time unit.- Parameters:
durationUnit
- a unit of time- Returns:
this
-
filter
public ConsoleReporter.Builder filter(MetricFilter filter)
Only report metrics which match the given filter.- Parameters:
filter
- aMetricFilter
- Returns:
this
-
disabledMetricAttributes
public ConsoleReporter.Builder disabledMetricAttributes(Set<MetricAttribute> disabledMetricAttributes)
Don't report the passed metric attributes for all metrics (e.g. "p999", "stddev" or "m15"). SeeMetricAttribute
.- Parameters:
disabledMetricAttributes
- aMetricFilter
- Returns:
this
-
build
public ConsoleReporter build()
Builds aConsoleReporter
with the given properties.- Returns:
- a
ConsoleReporter
-
-