Minor improvements to error messages for netflix.atlas.uri problems
This commit is contained in:
@@ -95,9 +95,14 @@ public class AtlasMetricObserver implements MetricObserver {
|
||||
}
|
||||
|
||||
protected static String normalizeAtlasUri(String uri) {
|
||||
Matcher matcher = Pattern.compile("(.+?)(/api/v1/publish)?/?").matcher(uri);
|
||||
matcher.matches();
|
||||
return matcher.group(1) + "/api/v1/publish";
|
||||
if (uri != null) {
|
||||
Matcher matcher = Pattern.compile("(.+?)(/api/v1/publish)?/?").matcher(uri);
|
||||
if (matcher.matches())
|
||||
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
|
||||
|
||||
@@ -53,6 +53,16 @@ public class AtlasMetricObserverTests {
|
||||
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
|
||||
public void checkValidityOfTags() {
|
||||
assertTrue(AtlasMetricObserver.validTags(BasicTagList.of("foo", "bar")));
|
||||
|
||||
Reference in New Issue
Block a user