Skip to content

Commit

Permalink
Make sure that metrics are not created from SmallRye internal classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartisk committed Aug 9, 2019
1 parent 5de2bed commit a4b265d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,16 @@ void registerMetricsFromAnnotatedMethods(SmallRyeMetricsRecorder metrics,
switch (metricAnnotationTarget.kind()) {
case METHOD: {
MethodInfo method = metricAnnotationTarget.asMethod();
collectedMetricsMethods.add(method);
if (!method.declaringClass().name().toString().startsWith("io.smallrye.metrics")) {
collectedMetricsMethods.add(method);
}
break;
}
case CLASS: {
ClassInfo clazz = metricAnnotationTarget.asClass();
collectMetricsClassAndSubClasses(index, collectedMetricsClasses, clazz);
if (!clazz.name().toString().startsWith("io.smallrye.metrics")) {
collectMetricsClassAndSubClasses(index, collectedMetricsClasses, clazz);
}
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;

import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -149,6 +150,16 @@ public void testEndpointWithMetricsThrowingException() {
.statusCode(404);
}

/**
* Verify that no metrics are created from SmallRye internal classes (for example the
* io.smallrye.metrics.interceptors package)
*/
@Test
public void testNoMetricsFromSmallRyeInternalClasses() {
RestAssured.when().get("/metrics/application").then()
.body(not(containsString("io_smallrye_metrics")));
}

private void assertMetricExactValue(String name, String val) {
RestAssured.when().get("/metrics").then()
.body(containsString(name + " " + val));
Expand Down

0 comments on commit a4b265d

Please sign in to comment.