Package org.apache.kafka.common.metrics
Class JmxReporter
java.lang.Object
org.apache.kafka.common.metrics.JmxReporter
- All Implemented Interfaces:
AutoCloseable
,Configurable
,MetricsReporter
,Reconfigurable
public class JmxReporter extends Object implements MetricsReporter
Register metrics in JMX as dynamic mbeans based on the metric names
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_EXCLUDE
static String
DEFAULT_INCLUDE
static String
EXCLUDE_CONFIG
static String
EXCLUDE_CONFIG_ALIAS
static String
INCLUDE_CONFIG
static String
INCLUDE_CONFIG_ALIAS
static String
METRICS_CONFIG_PREFIX
static Set<String>
RECONFIGURABLE_CONFIGS
-
Constructor Summary
Constructors Constructor Description JmxReporter()
JmxReporter(String prefix)
Deprecated.Since 2.6.0. -
Method Summary
Modifier and Type Method Description void
close()
Called when the metrics repository is closed.static Predicate<String>
compilePredicate(Map<String,?> originalConfig)
void
configure(Map<String,?> configs)
Configure this class with the given key-value pairsboolean
containsMbean(String mbeanName)
void
contextChange(MetricsContext metricsContext)
Sets the context labels for the service or library exposing metrics.void
init(List<KafkaMetric> metrics)
This is called when the reporter is first registered to initially register all existing metricsvoid
metricChange(KafkaMetric metric)
This is called whenever a metric is updated or addedvoid
metricRemoval(KafkaMetric metric)
This is called whenever a metric is removedSet<String>
reconfigurableConfigs()
Returns the names of configs that may be reconfigured.void
reconfigure(Map<String,?> configs)
Reconfigures this instance with the given key-value pairs.void
validateReconfiguration(Map<String,?> configs)
Validates the provided configuration.
-
Field Details
-
METRICS_CONFIG_PREFIX
- See Also:
- Constant Field Values
-
EXCLUDE_CONFIG
- See Also:
- Constant Field Values
-
EXCLUDE_CONFIG_ALIAS
- See Also:
- Constant Field Values
-
INCLUDE_CONFIG
- See Also:
- Constant Field Values
-
INCLUDE_CONFIG_ALIAS
- See Also:
- Constant Field Values
-
RECONFIGURABLE_CONFIGS
-
DEFAULT_INCLUDE
- See Also:
- Constant Field Values
-
DEFAULT_EXCLUDE
- See Also:
- Constant Field Values
-
-
Constructor Details
-
JmxReporter
public JmxReporter() -
JmxReporter
Deprecated.Since 2.6.0. UseJmxReporter()
Initialize JmxReporter withcontextChange(MetricsContext)
Populate prefix by adding _namespace/prefix key value pair toMetricsContext
Create a JMX reporter that prefixes all metrics with the given string.
-
-
Method Details
-
configure
Description copied from interface:Configurable
Configure this class with the given key-value pairs- Specified by:
configure
in interfaceConfigurable
-
reconfigurableConfigs
Description copied from interface:Reconfigurable
Returns the names of configs that may be reconfigured.- Specified by:
reconfigurableConfigs
in interfaceMetricsReporter
- Specified by:
reconfigurableConfigs
in interfaceReconfigurable
-
validateReconfiguration
Description copied from interface:Reconfigurable
Validates the provided configuration. The provided map contains all configs including any reconfigurable configs that may be different from the initial configuration. Reconfiguration will be not performed if this method throws any exception.- Specified by:
validateReconfiguration
in interfaceMetricsReporter
- Specified by:
validateReconfiguration
in interfaceReconfigurable
- Throws:
ConfigException
- if the provided configs are not valid. The exception message from ConfigException will be returned to the client in the AlterConfigs response.
-
reconfigure
Description copied from interface:Reconfigurable
Reconfigures this instance with the given key-value pairs. The provided map contains all configs including any reconfigurable configs that may have changed since the object was initially configured usingConfigurable.configure(Map)
. This method will only be invoked if the configs have passed validation usingReconfigurable.validateReconfiguration(Map)
.- Specified by:
reconfigure
in interfaceMetricsReporter
- Specified by:
reconfigure
in interfaceReconfigurable
-
init
Description copied from interface:MetricsReporter
This is called when the reporter is first registered to initially register all existing metrics- Specified by:
init
in interfaceMetricsReporter
- Parameters:
metrics
- All currently existing metrics
-
containsMbean
-
metricChange
Description copied from interface:MetricsReporter
This is called whenever a metric is updated or added- Specified by:
metricChange
in interfaceMetricsReporter
-
metricRemoval
Description copied from interface:MetricsReporter
This is called whenever a metric is removed- Specified by:
metricRemoval
in interfaceMetricsReporter
-
close
public void close()Description copied from interface:MetricsReporter
Called when the metrics repository is closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceMetricsReporter
-
compilePredicate
-
contextChange
Description copied from interface:MetricsReporter
Sets the context labels for the service or library exposing metrics. This will be called beforeMetricsReporter.init(List)
and may be called anytime after that.- Specified by:
contextChange
in interfaceMetricsReporter
- Parameters:
metricsContext
- the metric context
-