Skip to content

Commit

Permalink
Improve config name
Browse files Browse the repository at this point in the history
Also fix Instance.toString()
  • Loading branch information
tylerbenson committed May 21, 2019
1 parent 89fca05 commit 8e04526
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/datadog/jmxfetch/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,10 @@ public void init(boolean forceNewConnection) {
}

for (LinkedHashMap<String, Object> configInstance : configInstances) {
if (appConfig.isAllowDirectInstances() != isDirectInstance(configInstance)) {
log.debug("Skipping instance '{}'. allowDirectInstances={} jvm_direct={}",
if (appConfig.isTargetDirectInstances() != isDirectInstance(configInstance)) {
log.debug("Skipping instance '{}'. targetDirectInstances={} jvm_direct={}",
name,
appConfig.isAllowDirectInstances(),
appConfig.isTargetDirectInstances(),
isDirectInstance(configInstance));
continue;
}
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/org/datadog/jmxfetch/AppConfig.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package org.datadog.jmxfetch;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;

Expand All @@ -12,7 +9,6 @@
import org.datadog.jmxfetch.converter.ReporterConverter;
import org.datadog.jmxfetch.reporter.ConsoleReporter;
import org.datadog.jmxfetch.reporter.Reporter;
import org.datadog.jmxfetch.reporter.ReporterFactory;
import org.datadog.jmxfetch.validator.Log4JLevelValidator;
import org.datadog.jmxfetch.validator.PositiveIntegerValidator;
import org.datadog.jmxfetch.validator.ReporterValidator;
Expand Down Expand Up @@ -209,7 +205,7 @@ public class AppConfig {
* If set to true, other instances will be ignored.
*/
@Builder.Default
private boolean allowDirectInstances = false;
private boolean targetDirectInstances = false;

// This is used by things like APM agent to provide configuration from resources
private List<String> instanceConfigResources;
Expand Down Expand Up @@ -346,8 +342,8 @@ public String getJmxLaunchFile() {
return getTmpDirectory() + "/" + AD_LAUNCH_FILE;
}

public boolean isAllowDirectInstances() {
return allowDirectInstances;
public boolean isTargetDirectInstances() {
return targetDirectInstances;
}

public List<String> getInstanceConfigResources() {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/datadog/jmxfetch/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ public void init(boolean forceNewConnection)
/** Returns a string representation for the instance. */
@Override
public String toString() {
if (this.instanceMap.get(PROCESS_NAME_REGEX) != null) {
if (isDirectInstance(instanceMap)) {
return "jvm_direct";
} else if (this.instanceMap.get(PROCESS_NAME_REGEX) != null) {
return "process_regex: `" + this.instanceMap.get(PROCESS_NAME_REGEX) + "`";
} else if (this.instanceMap.get("jmx_url") != null) {
return (String) this.instanceMap.get("jmx_url");
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/datadog/jmxfetch/TestApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public void testApp() throws Exception {
registerMBean(testApp, "org.datadog.jmxfetch.test:type=SimpleTestJavaApp");

// We do a first collection
when(appConfig.isAllowDirectInstances()).thenReturn(true);
when(appConfig.isTargetDirectInstances()).thenReturn(true);
initApplication("jmx.yaml");

run();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/datadog/jmxfetch/TestServiceChecks.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void testServiceCheckOK() throws Exception {
registerMBean(new SimpleTestJavaApp(), "org.datadog.jmxfetch.test:type=ServiceCheckTest");

// We do a first collection
when(appConfig.isAllowDirectInstances()).thenReturn(true);
when(appConfig.isTargetDirectInstances()).thenReturn(true);
initApplication("jmx.yaml");

run();
Expand Down Expand Up @@ -155,7 +155,7 @@ public void testServiceCheckCRITICAL() throws Exception {

@Test
public void testServiceCheckCounter() throws Exception {
when(appConfig.isAllowDirectInstances()).thenReturn(true);
when(appConfig.isTargetDirectInstances()).thenReturn(true);
initApplication("jmx.yaml");

Reporter repo = getReporter();
Expand Down

0 comments on commit 8e04526

Please sign in to comment.