-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37fc55f
commit c25dcc3
Showing
9 changed files
with
192 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/org/datadog/jmxfetch/util/ServiceCheckHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.datadog.jmxfetch.util; | ||
|
||
import org.apache.commons.lang.StringUtils; | ||
|
||
public class ServiceCheckHelper { | ||
/** | ||
* Formats the service check prefix. | ||
* First implemented here: | ||
* https://github.com/DataDog/jmxfetch/commit/0428c41ebf7a14404ae50928e3ecfc229701c042 | ||
* | ||
* <p>The formatted service check name is kept for backward compatibility only. | ||
* Previously there were 2 JMXFetch integrations for activemq: one called activemq | ||
* for older versions of activemq, the other called activemq_58 for v5.8+ of activemq, | ||
* see https://github.com/DataDog/dd-agent/tree/5.10.x/conf.d | ||
* And we still wanted both integrations to send the service check with the activemq prefix. | ||
* */ | ||
public static String formatServiceCheckPrefix(String fullname) { | ||
String[] chunks = fullname.split("\\."); | ||
chunks[0] = chunks[0].replaceAll("[A-Z0-9:_\\-]", ""); | ||
return StringUtils.join(chunks, "."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/test/java/org/datadog/jmxfetch/util/ServiceCheckHelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.datadog.jmxfetch.util; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class ServiceCheckHelperTest { | ||
|
||
@Test | ||
public void testFormatServiceCheckPrefix() { | ||
// Let's get a list of Strings to test (add real versionned check names | ||
// here when you add new versionned check) | ||
String[][] data = { | ||
{"activemq_58.foo.bar12", "activemq.foo.bar12"}, | ||
{"test_package-X86_64-VER1:0.weird.metric_name", "testpackage.weird.metric_name"} | ||
}; | ||
|
||
// Let's test them all | ||
for (String[] datum : data) { | ||
assertEquals(datum[1], ServiceCheckHelper.formatServiceCheckPrefix(datum[0])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
init_config: | ||
service_check_prefix: null | ||
|
||
instances: | ||
- jvm_direct: true | ||
name: jmx_test_instance | ||
conf: | ||
- include: | ||
domain: org.datadog.jmxfetch.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
init_config: | ||
service_check_prefix: myprefix | ||
|
||
instances: | ||
- jvm_direct: true | ||
name: jmx_test_instance | ||
conf: | ||
- include: | ||
domain: org.datadog.jmxfetch.test |