Package com.codahale.metrics
Class Slf4jReporter.Builder
- java.lang.Object
-
- com.codahale.metrics.Slf4jReporter.Builder
-
- Enclosing class:
- Slf4jReporter
public static class Slf4jReporter.Builder extends Object
A builder forSlf4jReporter
instances. Defaults to logging tometrics
, not using a marker, 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 Slf4jReporter
build()
Builds aSlf4jReporter
with the given properties.Slf4jReporter.Builder
convertDurationsTo(TimeUnit durationUnit)
Convert durations to the given time unit.Slf4jReporter.Builder
convertRatesTo(TimeUnit rateUnit)
Convert rates to the given time unit.Slf4jReporter.Builder
disabledMetricAttributes(Set<MetricAttribute> disabledMetricAttributes)
Don't report the passed metric attributes for all metrics (e.g.Slf4jReporter.Builder
filter(MetricFilter filter)
Only report metrics which match the given filter.Slf4jReporter.Builder
markWith(org.slf4j.Marker marker)
Mark all logged metrics with the given marker.Slf4jReporter.Builder
outputTo(org.slf4j.Logger logger)
Log metrics to the given logger.Slf4jReporter.Builder
prefixedWith(String prefix)
Prefix all metric names with the given string.Slf4jReporter.Builder
scheduleOn(ScheduledExecutorService executor)
Specifies the executor to use while scheduling reporting of metrics.Slf4jReporter.Builder
shutdownExecutorOnStop(boolean shutdownExecutorOnStop)
Specifies whether or not, the executor (used for reporting) will be stopped with same time with reporter.Slf4jReporter.Builder
withLoggingLevel(Slf4jReporter.LoggingLevel loggingLevel)
Use Logging Level when reporting.
-
-
-
Method Detail
-
shutdownExecutorOnStop
public Slf4jReporter.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 Slf4jReporter.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 Slf4jReporter.Builder outputTo(org.slf4j.Logger logger)
Log metrics to the given logger.- Parameters:
logger
- an SLF4JLogger
- Returns:
this
-
markWith
public Slf4jReporter.Builder markWith(org.slf4j.Marker marker)
Mark all logged metrics with the given marker.- Parameters:
marker
- an SLF4JMarker
- Returns:
this
-
prefixedWith
public Slf4jReporter.Builder prefixedWith(String prefix)
Prefix all metric names with the given string.- Parameters:
prefix
- the prefix for all metric names- Returns:
this
-
convertRatesTo
public Slf4jReporter.Builder convertRatesTo(TimeUnit rateUnit)
Convert rates to the given time unit.- Parameters:
rateUnit
- a unit of time- Returns:
this
-
convertDurationsTo
public Slf4jReporter.Builder convertDurationsTo(TimeUnit durationUnit)
Convert durations to the given time unit.- Parameters:
durationUnit
- a unit of time- Returns:
this
-
filter
public Slf4jReporter.Builder filter(MetricFilter filter)
Only report metrics which match the given filter.- Parameters:
filter
- aMetricFilter
- Returns:
this
-
withLoggingLevel
public Slf4jReporter.Builder withLoggingLevel(Slf4jReporter.LoggingLevel loggingLevel)
Use Logging Level when reporting.- Parameters:
loggingLevel
- a (@link Slf4jReporter.LoggingLevel}- Returns:
this
-
disabledMetricAttributes
public Slf4jReporter.Builder disabledMetricAttributes(Set<MetricAttribute> disabledMetricAttributes)
Don't report the passed metric attributes for all metrics (e.g. "p999", "stddev" or "m15"). SeeMetricAttribute
.- Parameters:
disabledMetricAttributes
- a set ofMetricAttribute
- Returns:
this
-
build
public Slf4jReporter build()
Builds aSlf4jReporter
with the given properties.- Returns:
- a
Slf4jReporter
-
-