-
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
Support the empty_default_hostname instance field #184
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ac14c23
support the empty_default_hostname instance field
xvello c8ccc03
fix ident
xvello 6d1dce4
use base boolean, catch NullPointerException
xvello 0be5008
Merge branch 'master' into xvello/emptydefaulthostname
truthbk 6d874b6
[test] we've got more metrics now - bumping metric count
truthbk 91a7940
[test][travis] logs are too verbose, lets curb it
truthbk 1bb7f17
[test][travis] make it explicit its for travis + include actual file
truthbk 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
log4j.rootLogger=INFO,stdout | ||
log4j.logger.com.endeca=INFO | ||
# Logger for crawl metrics | ||
log4j.logger.com.endeca.itl.web.metrics=INFO | ||
|
||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | ||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.stdout.layout.ConversionPattern=%p\t%d{ISO8601}\t%r\t%c\t[%t]\t%m%n |
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 |
---|---|---|
@@ -1,34 +1,75 @@ | ||
package org.datadog.jmxfetch; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.HashMap; | ||
import java.util.LinkedList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.junit.Test; | ||
|
||
public class TestInstance extends TestCommon { | ||
private final static Logger LOGGER = Logger.getLogger("Test Instance"); | ||
|
||
@Test | ||
public void testMinCollectionInterval() throws Exception { | ||
registerMBean(new SimpleTestJavaApp(), "org.datadog.jmxfetch.test:foo=Bar,qux=Baz"); | ||
initApplication("jmx_min_collection_period.yml"); | ||
|
||
run(); | ||
LinkedList<HashMap<String, Object>> metrics = getMetrics(); | ||
assertEquals(15, metrics.size()); | ||
|
||
run(); | ||
metrics = getMetrics(); | ||
assertEquals(0, metrics.size()); | ||
|
||
LOGGER.info("sleeping before the next collection"); | ||
Thread.sleep(5000); | ||
run(); | ||
metrics = getMetrics(); | ||
assertEquals(15, metrics.size()); | ||
} | ||
|
||
// assertHostnameTags is used by testEmptyDefaultHostname | ||
private void assertHostnameTags(List<String> tagList) throws Exception { | ||
// Fixed instance tag | ||
assertTrue(tagList.contains(new String("jmx:fetch"))); | ||
|
||
if (tagList.contains(new String("instance:jmx_test_default_hostname"))) { | ||
// Nominal case | ||
assertFalse(tagList.contains(new String("host:"))); | ||
} else if (tagList.contains(new String("instance:jmx_test_no_hostname"))) { | ||
// empty_default_hostname case | ||
assertTrue(tagList.contains(new String("host:"))); | ||
} else { | ||
fail("unexpected instance tag"); | ||
} | ||
} | ||
|
||
@Test | ||
public void testEmptyDefaultHostname() 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. 🍰 |
||
registerMBean(new SimpleTestJavaApp(), "org.datadog.jmxfetch.test:foo=Bar,qux=Baz"); | ||
initApplication("jmx_empty_default_hostname.yaml"); | ||
run(); | ||
|
||
LinkedList<HashMap<String, Object>> metrics = getMetrics(); | ||
assertEquals(28, metrics.size()); | ||
for (HashMap<String, Object> metric : metrics) { | ||
String[] tags = (String[]) metric.get("tags"); | ||
this.assertHostnameTags(Arrays.asList(tags)); | ||
} | ||
|
||
LinkedList<HashMap<String, Object>> serviceChecks = getServiceChecks(); | ||
assertEquals(2, serviceChecks.size()); | ||
for (HashMap<String, Object> sc : serviceChecks) { | ||
String[] tags = (String[]) sc.get("tags"); | ||
this.assertHostnameTags(Arrays.asList(tags)); | ||
} | ||
} | ||
} |
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,27 @@ | ||
init_config: | ||
|
||
instances: | ||
- process_name_regex: .*surefire.* | ||
name: jmx_test_default_hostname | ||
tags: | ||
- jmx:fetch | ||
conf: | ||
- include: | ||
domain: org.datadog.jmxfetch.test | ||
attribute: | ||
ShouldBe100: | ||
metric_type: gauge | ||
alias: this.is.100.$foo.$qux | ||
|
||
- process_name_regex: .*surefire.* | ||
empty_default_hostname: true | ||
name: jmx_test_no_hostname | ||
tags: | ||
- jmx:fetch | ||
conf: | ||
- include: | ||
domain: org.datadog.jmxfetch.test | ||
attribute: | ||
ShouldBe100: | ||
metric_type: gauge | ||
alias: this.is.100.$foo.$qux |
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.
How do you feel we should handle the case where the instanceTags
host
tag is set (for whatever reason), butemptyDefaultHostname
is true. IMHO it might make sense to just evict it from the HashMap and make the boolean option take precedence.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.
For python/golang checks, we want to support an empty default hostname + check-provided hostname override (for kubernetes events node events / kube_state node metrics), so it's a legit use case.
It's currently not possible as an instance tag as it'll be sanitized to bean_host, but could it be added as a bean tag?
If so, do you think there's a better method to plug this logic into?
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.
Let's leave as-is, I think its probably fine.