Skip to content

Commit

Permalink
Remove messages for non-ERROR can_connect service checks (#369)
Browse files Browse the repository at this point in the history
* Remove messages for non-ERROR can_connect service checks

* Modify logic to be more straightforward

* Remove warn status

* Change to if status is not error
  • Loading branch information
yzhan289 authored Aug 24, 2021
1 parent f8a1a40 commit 3236430
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/datadog/jmxfetch/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,11 @@ private void sendServiceCheck(
private void sendCanConnectServiceCheck(Reporter reporter, String checkName,
String serviceCheckPrefix, String status, String message, String[] tags) {
String serviceCheckName = String.format("%s.can_connect", serviceCheckPrefix);

if (status != Status.STATUS_ERROR) {
message = null;
}

reporter.sendServiceCheck(
checkName, serviceCheckName, status, message, tags);
}
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/org/datadog/jmxfetch/TestServiceChecks.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ public void testServiceCheckWarning() throws Exception {
assertNotNull(sc.get("name"));
assertNotNull(sc.get("status"));

// Message should not be null anymore and reports a high number of metrics warning
assertNotNull(sc.get("message"));
// Despite there being a high number of metrics warning, message should be null.
// Non-ERROR statuses are set to OK, and OK statuses should have null messages.
assertNull(sc.get("message"));
assertNotNull(sc.get("tags"));

String scName = (String) (sc.get("name"));
Expand Down

0 comments on commit 3236430

Please sign in to comment.