Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Will this break?
Browse files Browse the repository at this point in the history
carlosroman committed May 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent fc57775 commit 5c64b58
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/org/datadog/jmxfetch/App.java
Original file line number Diff line number Diff line change
@@ -133,7 +133,10 @@ public App(final AppConfig appConfig) {
}
this.configs = getConfigs(this.appConfig);

this.initTelemetryBean();
if (this.appConfig.getJmxfetchTelemetry()) {
log.info("Enabling JMX Fetch Telemetry");
this.initTelemetryBean();
}
}

private ObjectName getAppTelemetryBeanName() {
@@ -176,6 +179,9 @@ private void initTelemetryBean() {
}

private void teardownTelemetry() {
if (!this.appConfig.getJmxfetchTelemetry()) {
return;
}
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName appTelemetryBeanName = getAppTelemetryBeanName();
if (appTelemetryBeanName == null) {
6 changes: 6 additions & 0 deletions src/test/java/org/datadog/jmxfetch/TestApp.java
Original file line number Diff line number Diff line change
@@ -22,6 +22,9 @@ public class TestApp extends TestCommon {
/** Tag metrics with MBean parameters based on user supplied regex */
@Test
public void testBeanRegexTags() throws Exception {
// When we enable JMXFetch telemetry
when(appConfig.getJmxfetchTelemetry()).thenReturn(true);

// We expose a few metrics through JMX
registerMBean(
new SimpleTestJavaApp(),
@@ -53,6 +56,9 @@ public void testBeanRegexTags() throws Exception {
/** Tag metrics with MBeans parameters. */
@Test
public void testBeanTags() throws Exception {
// When we enable JMXFetch telemetry
when(appConfig.getJmxfetchTelemetry()).thenReturn(true);

// We expose a few metrics through JMX
registerMBean(
new SimpleTestJavaApp(),

0 comments on commit 5c64b58

Please sign in to comment.