-
Notifications
You must be signed in to change notification settings - Fork 70
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 class name and class regex filters #277
Merged
AlexandreYang
merged 9 commits into
DataDog:master
from
AlexandreYang:alex/add_class_name
Mar 3, 2020
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fb9582b
Add class name
AlexandreYang 0803441
Add tests
AlexandreYang db59c39
Rename method
AlexandreYang bb9ad5e
Merge branch 'master' into alex/add_class_name
AlexandreYang 8714944
Refactor getMatchingAttributes
AlexandreYang 2114b50
Minor clean up
AlexandreYang 0577cbc
Fix style
AlexandreYang 3e9207d
Factor match name
AlexandreYang 77d9024
Make SimpleTestJavaApp2 a inner class
AlexandreYang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -256,6 +256,65 @@ public void testDomainRegex() throws Exception { | |
assertEquals(15, metrics.size()); | ||
} | ||
|
||
@Test | ||
public void testClassInclude() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🍰 |
||
// We expose a few metrics through JMX | ||
registerMBean(new SimpleTestJavaApp(), "org.datadog.jmxfetch.includeme:type=AType"); | ||
initApplication("jmx_class_include.yaml"); | ||
|
||
// Collecting metrics | ||
run(); | ||
List<Map<String, Object>> metrics = getMetrics(); | ||
|
||
// First filter 29 = 13 metrics from java.lang + 16 metrics implicitly defined | ||
assertEquals(29, metrics.size()); | ||
} | ||
|
||
@Test | ||
public void testClassExclude() throws Exception { | ||
class SimpleTestJavaAnotherApp extends SimpleTestJavaApp { | ||
|
||
} | ||
|
||
// We expose a few metrics through JMX | ||
registerMBean(new SimpleTestJavaApp(), "org.datadog.jmxfetch.includeme:type=AType"); | ||
registerMBean(new SimpleTestJavaAnotherApp(), "org.datadog.jmxfetch.includeme2:type=AnotherType"); | ||
|
||
// Initializing application | ||
initApplication("jmx_class_exclude.yaml"); | ||
|
||
// Collecting metrics | ||
run(); | ||
List<Map<String, Object>> metrics = getMetrics(); | ||
|
||
// First filter 14 = 13 metrics from java.lang + 2 metrics explicitly define- 1 implicitly | ||
// defined in the exclude section | ||
assertEquals(14, metrics.size()); | ||
} | ||
|
||
@Test | ||
public void testClassRegex() throws Exception { | ||
class SimpleTestJavaAppIncludeMe extends SimpleTestJavaApp { } | ||
class SimpleTestJavaAppIncludeMeToo extends SimpleTestJavaApp { } | ||
class SimpleTestJavaAppIncludeMeNotMeX extends SimpleTestJavaApp { } | ||
|
||
// We expose a few metrics through JMX | ||
registerMBean(new SimpleTestJavaAppIncludeMe(), "org.datadog.jmxfetch.includeme:type=AType"); | ||
registerMBean(new SimpleTestJavaAppIncludeMeToo(), "org.datadog.jmxfetch.includeme.too:type=AType"); | ||
registerMBean(new SimpleTestJavaAppIncludeMeNotMeX(), "org.datadog.jmxfetch.includeme.not.me:type=AType"); | ||
|
||
// Initializing application | ||
initApplication("jmx_class_regex.yaml"); | ||
|
||
// Collecting metrics | ||
run(); | ||
List<Map<String, Object>> metrics = getMetrics(); | ||
|
||
// First filter 15 = 13 metrics from java.lang + 3 metrics explicitly defined - 1 implicitly | ||
// defined in exclude section | ||
assertEquals(15, metrics.size()); | ||
} | ||
|
||
@Test | ||
public void testParameterMatch() throws Exception { | ||
// Do not match beans which do not contain types specified in the conf | ||
|
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,13 @@ | ||
init_config: | ||
|
||
instances: | ||
- process_name_regex: .*surefire.* | ||
name: jmx_test_instance | ||
conf: | ||
- include: | ||
attribute: | ||
ShouldBe100: | ||
metric_type: gauge | ||
alias: this.is.100 | ||
exclude: | ||
class: org.datadog.jmxfetch.TestApp$1SimpleTestJavaAnotherApp |
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,8 @@ | ||
init_config: | ||
|
||
instances: | ||
- process_name_regex: .*surefire.* | ||
name: jmx_test_instance | ||
conf: | ||
- include: | ||
class: org.datadog.jmxfetch.SimpleTestJavaApp |
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,14 @@ | ||
init_config: | ||
|
||
instances: | ||
- process_name_regex: .*surefire.* | ||
name: jmx_test_instance | ||
conf: | ||
- include: | ||
class_regex: .*IncludeMe.* | ||
attribute: | ||
ShouldBe100: | ||
metric_type: gauge | ||
alias: this.is.100 | ||
exclude: | ||
class_regex: .*Me$ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: I was going to say these new log lines perhaps didn't add much value, but since we're calling methods on
connection
we can probably trigger anIOException
with these, so it's probably justified.