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

Add a new command to test rate metrics #267

Merged
merged 4 commits into from
Feb 21, 2020
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
Next Next commit
Add a new command to test rate metrics
For end to end testing, we use the `list_with_metrics` command. It only
does one iteration though, which means we don't have output for counters
and rates. This adds a new command running 2 iterations.
therve committed Feb 12, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit e81284b66f749e49b041dd24693f626d9fb31a76
14 changes: 14 additions & 0 deletions src/main/java/org/datadog/jmxfetch/App.java
Original file line number Diff line number Diff line change
@@ -227,6 +227,9 @@ public static int run(AppConfig config) {
if (action.equals(AppConfig.ACTION_LIST_WITH_METRICS)) {
app.displayMetrics();
}
if (action.equals(AppConfig.ACTION_LIST_WITH_RATE_METRICS)) {
app.displayRateMetrics();
}
return 0;
}

@@ -384,6 +387,17 @@ void displayMetrics() {
doIteration();
}

/* Display metrics on the console report, including rate metrics */
void displayRateMetrics() {
doIteration();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
log.warn(e.getMessage(), e);
}
doIteration();
}

void start() {
// Main Loop that will periodically collect metrics from the JMX Server
FileInputStream adPipe = null;
4 changes: 3 additions & 1 deletion src/main/java/org/datadog/jmxfetch/AppConfig.java
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ public class AppConfig {
public static final String ACTION_LIST_COLLECTED = "list_collected_attributes";
public static final String ACTION_LIST_MATCHING = "list_matching_attributes";
public static final String ACTION_LIST_WITH_METRICS = "list_with_metrics";
public static final String ACTION_LIST_WITH_RATE_METRICS = "list_with_rate_metrics";
public static final String ACTION_LIST_NOT_MATCHING = "list_not_matching_attributes";
public static final String ACTION_LIST_LIMITED = "list_limited_attributes";
public static final String ACTION_HELP = "help";
@@ -41,6 +42,7 @@ public class AppConfig {
ACTION_LIST_COLLECTED,
ACTION_LIST_MATCHING,
ACTION_LIST_WITH_METRICS,
ACTION_LIST_WITH_RATE_METRICS,
ACTION_LIST_NOT_MATCHING,
ACTION_LIST_LIMITED,
ACTION_HELP,
@@ -186,7 +188,7 @@ public class AppConfig {
description =
"Action to take, should be in [help, version, collect, "
+ "list_everything, list_collected_attributes, list_matching_attributes, "
+ "list_with_metrics, list_not_matching_attributes, "
+ "list_with_metrics, list_with_rate_metrics, list_not_matching_attributes, "
+ "list_limited_attributes, list_jvms]",
required = true)
private List<String> action;
Original file line number Diff line number Diff line change
@@ -432,7 +432,7 @@ public void testParsingAction() {
String expectedMessage =
"Main parameters are required (\"Action to take, should be in [help, version, collect, "
+ "list_everything, list_collected_attributes, list_matching_attributes, "
+ "list_with_metrics, list_not_matching_attributes, list_limited_attributes, list_jvms]\")";
+ "list_with_metrics, list_with_rate_metrics, list_not_matching_attributes, list_limited_attributes, list_jvms]\")";
assertEquals(expectedMessage, pe.getMessage());
}

@@ -451,7 +451,7 @@ public void testParsingAction() {
String expectedMessage =
"Main parameters are required (\"Action to take, should be in [help, version, collect, "
+ "list_everything, list_collected_attributes, list_matching_attributes, "
+ "list_with_metrics, list_not_matching_attributes, list_limited_attributes, list_jvms]\")";
+ "list_with_metrics, list_with_rate_metrics, list_not_matching_attributes, list_limited_attributes, list_jvms]\")";
assertEquals(expectedMessage, pe.getMessage());
}
}