Commit e994971b by Jon Schneider

Minor improvements to error messages for netflix.atlas.uri problems

parent 0ddfb42d
...@@ -95,9 +95,14 @@ public class AtlasMetricObserver implements MetricObserver { ...@@ -95,9 +95,14 @@ public class AtlasMetricObserver implements MetricObserver {
} }
protected static String normalizeAtlasUri(String uri) { protected static String normalizeAtlasUri(String uri) {
if (uri != null) {
Matcher matcher = Pattern.compile("(.+?)(/api/v1/publish)?/?").matcher(uri); Matcher matcher = Pattern.compile("(.+?)(/api/v1/publish)?/?").matcher(uri);
matcher.matches(); if (matcher.matches())
return matcher.group(1) + "/api/v1/publish"; return matcher.group(1) + "/api/v1/publish";
else
throw new IllegalStateException("netflix.atlas.uri is not a valid uri");
}
throw new IllegalStateException("netflix.atlas.uri was not found in your properties and is required to communicate with Atlas");
} }
@Override @Override
......
...@@ -53,6 +53,16 @@ public class AtlasMetricObserverTests { ...@@ -53,6 +53,16 @@ public class AtlasMetricObserverTests {
assertEquals(normalized, AtlasMetricObserver.normalizeAtlasUri("http://localhost:7001/api/v1/publish/")); assertEquals(normalized, AtlasMetricObserver.normalizeAtlasUri("http://localhost:7001/api/v1/publish/"));
} }
@Test(expected = IllegalStateException.class)
public void emptyAtlasUriThrowsException() {
AtlasMetricObserver.normalizeAtlasUri("");
}
@Test(expected = IllegalStateException.class)
public void missingAtlasUriThrowsException() {
AtlasMetricObserver.normalizeAtlasUri(null);
}
@Test @Test
public void checkValidityOfTags() { public void checkValidityOfTags() {
assertTrue(AtlasMetricObserver.validTags(BasicTagList.of("foo", "bar"))); assertTrue(AtlasMetricObserver.validTags(BasicTagList.of("foo", "bar")));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment