Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Lombok Builder for AppConfig, Formalize jvm_direct Connection #225

Merged
merged 4 commits into from
May 21, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/org/datadog/jmxfetch/App.java
Original file line number Diff line number Diff line change
@@ -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={}",
tylerbenson marked this conversation as resolved.
Show resolved Hide resolved
name,
appConfig.isAllowDirectInstances(),
appConfig.isTargetDirectInstances(),
isDirectInstance(configInstance));
continue;
}
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;

@@ -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;
@@ -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;
@@ -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() {
4 changes: 3 additions & 1 deletion src/main/java/org/datadog/jmxfetch/Instance.java
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion src/test/java/org/datadog/jmxfetch/TestApp.java
Original file line number Diff line number Diff line change
@@ -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();
4 changes: 2 additions & 2 deletions src/test/java/org/datadog/jmxfetch/TestServiceChecks.java
Original file line number Diff line number Diff line change
@@ -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();
@@ -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();