Skip to content

Commit

Permalink
Add a config flag to disable metrics jmx reporting
Browse files Browse the repository at this point in the history
Disables reporting for both the driver's registry and our registry
  • Loading branch information
tsegismont committed Apr 29, 2016
1 parent c635826 commit d351f66
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Expand Up @@ -27,6 +27,7 @@
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.CASSANDRA_RESETDB;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.CASSANDRA_USESSL;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.DEFAULT_TTL;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.DISABLE_METRICS_JMX;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.USE_VIRTUAL_CLOCK;
import static org.hawkular.metrics.api.jaxrs.config.ConfigurationKey.WAIT_FOR_SERVICE;

Expand Down Expand Up @@ -140,6 +141,11 @@ public enum State {
@ConfigurationProperty(DEFAULT_TTL)
private String defaultTTL;

@Inject
@Configurable
@ConfigurationProperty(DISABLE_METRICS_JMX)
private String disableMetricsJmxReporting;

@Inject
@ServiceReady
Event<ServiceReadyEvent> metricsServiceReady;
Expand Down Expand Up @@ -229,8 +235,10 @@ private void startMetricsService() {
metricsService.setDefaultTTL(getDefaultTTL());

MetricRegistry metricRegistry = MetricRegistryProvider.INSTANCE.getMetricRegistry();
jmxReporter = JmxReporter.forRegistry(metricRegistry).inDomain("hawkular.metrics").build();
jmxReporter.start();
if (!Boolean.parseBoolean(disableMetricsJmxReporting)) {
jmxReporter = JmxReporter.forRegistry(metricRegistry).inDomain("hawkular.metrics").build();
jmxReporter.start();
}
metricsService.startUp(session, keyspace, false, false, metricRegistry);

initJobs();
Expand Down Expand Up @@ -279,6 +287,10 @@ private Session createSession() {
}
}

if (Boolean.parseBoolean(disableMetricsJmxReporting)) {
clusterBuilder.withoutJMXReporting();
}

Cluster cluster = clusterBuilder.build();
cluster.init();
Session createdSession = null;
Expand Down
Expand Up @@ -36,7 +36,8 @@ public enum ConfigurationKey {
CASSANDRA_USESSL("hawkular-metrics.cassandra-use-ssl", "false", "CASSANDRA_USESSL", false),
WAIT_FOR_SERVICE("hawkular.metrics.waitForService", null, null, true),
USE_VIRTUAL_CLOCK("hawkular.metrics.use-virtual-clock", "false", "USE_VIRTUAL_CLOCK", false),
DEFAULT_TTL("hawkular.metrics.default-ttl", "7", "DEFAULT_TTL", false);
DEFAULT_TTL("hawkular.metrics.default-ttl", "7", "DEFAULT_TTL", false),
DISABLE_METRICS_JMX("hawkular.metrics.disable-metrics-jmx-reporting", null, "DISABLE_METRICS_JMX", true);

private final String name;
private final String env;
Expand Down

0 comments on commit d351f66

Please sign in to comment.