diff --git a/changelog/@unreleased/pr-1478.v2.yml b/changelog/@unreleased/pr-1478.v2.yml new file mode 100644 index 000000000..781843d2f --- /dev/null +++ b/changelog/@unreleased/pr-1478.v2.yml @@ -0,0 +1,10 @@ +type: deprecation +deprecation: + description: |- + Remove unused @MetricGroup annotation helpers + + This was never used and the code for it has rotted, so time to purge. + The @MetricGroup annotation still exists to prevent any immediate ABI + breaks, but have been deprecated and will be removed in future. + links: + - https://github.com/palantir/tritium/pull/1478 diff --git a/tritium-lib/src/test/java/com/palantir/tritium/TritiumTest.java b/tritium-lib/src/test/java/com/palantir/tritium/TritiumTest.java index 8306b8acf..b783a2725 100644 --- a/tritium-lib/src/test/java/com/palantir/tritium/TritiumTest.java +++ b/tritium-lib/src/test/java/com/palantir/tritium/TritiumTest.java @@ -166,10 +166,6 @@ public void rethrowOutOfMemoryErrorMetrics() { .meter(MetricRegistry.name(methodMetricName, "failures")) .getCount()) .isOne(); - assertThat(metricRegistry - .meter(MetricRegistry.name(methodMetricName, "failures", "java.lang.OutOfMemoryError")) - .getCount()) - .isOne(); } @Test diff --git a/tritium-lib/src/test/java/com/palantir/tritium/proxy/InstrumentationTest.java b/tritium-lib/src/test/java/com/palantir/tritium/proxy/InstrumentationTest.java index 8ea78bae2..2a6d84b24 100644 --- a/tritium-lib/src/test/java/com/palantir/tritium/proxy/InstrumentationTest.java +++ b/tritium-lib/src/test/java/com/palantir/tritium/proxy/InstrumentationTest.java @@ -48,7 +48,6 @@ import com.palantir.tritium.event.log.LoggingInvocationEventHandler; import com.palantir.tritium.event.metrics.MetricsInvocationEventHandler; import com.palantir.tritium.event.metrics.TaggedMetricsServiceInvocationEventHandler; -import com.palantir.tritium.event.metrics.annotations.MetricGroup; import com.palantir.tritium.metrics.MetricRegistries; import com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry; import com.palantir.tritium.metrics.registry.MetricName; @@ -80,17 +79,6 @@ @SuppressWarnings({"NullAway", "SystemOut", "WeakerAccess"}) // mock injection, dumping metrics to standard out public abstract class InstrumentationTest { - @MetricGroup("DEFAULT") - public interface AnnotatedInterface { - @MetricGroup("ONE") - void method(); - - @MetricGroup("ONE") - void otherMethod(); - - void defaultMethod(); - } - private static final String EXPECTED_METRIC_NAME = TestInterface.class.getName() + ".test"; // Exceed the HotSpot JIT thresholds @@ -177,38 +165,6 @@ void testBuilder() { .report(); } - @Test - void testMetricGroupBuilder() { - AnnotatedInterface delegate = mock(AnnotatedInterface.class); - String globalPrefix = "com.business.service"; - - MetricRegistry metricRegistry = MetricRegistries.createWithHdrHistogramReservoirs(); - - AnnotatedInterface instrumentedService = Instrumentation.builder(AnnotatedInterface.class, delegate) - .withMetrics(metricRegistry, globalPrefix) - .withPerformanceTraceLogging() - .build(); - // call - instrumentedService.method(); - instrumentedService.otherMethod(); - instrumentedService.defaultMethod(); - - assertThat(metricRegistry - .timer(AnnotatedInterface.class.getName() + ".ONE") - .getCount()) - .isEqualTo(2L); - assertThat(metricRegistry.timer(globalPrefix + ".ONE").getCount()).isEqualTo(2L); - assertThat(metricRegistry - .timer(AnnotatedInterface.class.getName() + ".DEFAULT") - .getCount()) - .isOne(); - assertThat(metricRegistry.timer(globalPrefix + ".DEFAULT").getCount()).isOne(); - assertThat(metricRegistry - .timer(AnnotatedInterface.class.getName() + ".method") - .getCount()) - .isOne(); - } - private void executeManyTimes(TestInterface instrumentedService, int invocations) { Stopwatch timer = Stopwatch.createStarted(); for (int i = 0; i < invocations; i++) { diff --git a/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandler.java b/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandler.java index aa2bad69e..1dd4e373a 100644 --- a/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandler.java +++ b/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandler.java @@ -19,16 +19,12 @@ import static com.palantir.logsafe.Preconditions.checkNotNull; import com.codahale.metrics.MetricRegistry; -import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMap; import com.palantir.logsafe.Safe; import com.palantir.tritium.event.AbstractInvocationEventHandler; import com.palantir.tritium.event.DefaultInvocationContext; import com.palantir.tritium.event.InstrumentationProperties; import com.palantir.tritium.event.InvocationContext; import com.palantir.tritium.event.InvocationEventHandler; -import com.palantir.tritium.event.metrics.annotations.AnnotationHelper; -import com.palantir.tritium.event.metrics.annotations.MetricGroup; import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; @@ -44,33 +40,22 @@ public final class MetricsInvocationEventHandler extends AbstractInvocationEvent @Safe private final String serviceName; - // consider creating annotation handlers as separate objects - private final ImmutableMap metricGroups; - - @Safe - @Nullable - private final String globalGroupPrefix; - @SuppressWarnings("WeakerAccess") // public API public MetricsInvocationEventHandler(MetricRegistry metricRegistry, @Safe String serviceName) { super(getEnabledSupplier(serviceName)); this.metricRegistry = checkNotNull(metricRegistry, "metricRegistry"); this.serviceName = checkNotNull(serviceName, "serviceName"); - this.metricGroups = ImmutableMap.of(); - this.globalGroupPrefix = null; } @SuppressWarnings("InconsistentOverloads") public MetricsInvocationEventHandler( MetricRegistry metricRegistry, - Class serviceClass, + Class _serviceClass, @Safe String serviceName, - @Safe @Nullable String globalGroupPrefix) { + @Safe @Nullable String _globalGroupPrefix) { super(getEnabledSupplier(serviceName)); this.metricRegistry = checkNotNull(metricRegistry, "metricRegistry"); this.serviceName = checkNotNull(serviceName, "serviceName"); - this.metricGroups = createMethodGroupMapping(checkNotNull(serviceClass)); - this.globalGroupPrefix = Strings.emptyToNull(globalGroupPrefix); } @SuppressWarnings("WeakerAccess") // public API @@ -79,26 +64,6 @@ public MetricsInvocationEventHandler( this(metricRegistry, serviceClass, checkNotNull(serviceClass.getName()), globalGroupPrefix); } - private static ImmutableMap createMethodGroupMapping( - Class serviceClass) { - ImmutableMap.Builder builder = ImmutableMap.builder(); - - MetricGroup classGroup = AnnotationHelper.getSuperTypeAnnotation(serviceClass, MetricGroup.class); - - for (Method method : serviceClass.getMethods()) { - AnnotationHelper.MethodSignature sig = AnnotationHelper.MethodSignature.of(method); - MetricGroup methodGroup = AnnotationHelper.getMethodAnnotation(MetricGroup.class, serviceClass, sig); - - if (methodGroup != null) { - builder.put(sig, methodGroup.value()); - } else if (classGroup != null) { - builder.put(sig, classGroup.value()); - } - } - - return builder.build(); - } - // explicitly qualifying BooleanSupplier types for deconfliction @SuppressWarnings({"NoFunctionalReturnType", "UnnecessarilyFullyQualified"}) static java.util.function.BooleanSupplier getEnabledSupplier(String serviceName) { @@ -114,31 +79,23 @@ public InvocationContext preInvocation(@Nonnull Object instance, @Nonnull Method public void onSuccess(@Nullable InvocationContext context, @Nullable Object _result) { debugIfNullContext(context); if (context != null) { - long nanos = updateTimer(context); - handleSuccessAnnotations(context, nanos); + updateTimer(context); } } @Override - public void onFailure(@Nullable InvocationContext context, @Nonnull Throwable cause) { + public void onFailure(@Nullable InvocationContext context, @Nonnull Throwable _cause) { markGlobalFailure(); debugIfNullContext(context); if (context != null) { - String failuresMetricName = getBaseMetricName(context) + '.' + FAILURES; - metricRegistry.meter(failuresMetricName).mark(); - metricRegistry - .meter(failuresMetricName + '.' + cause.getClass().getName()) - .mark(); - long nanos = updateTimer(context); - handleFailureAnnotations(context, nanos); + metricRegistry.meter(getBaseMetricName(context) + '.' + FAILURES).mark(); } } @SuppressWarnings("PreferJavaTimeOverload") // performance sensitive - private long updateTimer(InvocationContext context) { + private void updateTimer(InvocationContext context) { long nanos = System.nanoTime() - context.getStartTimeNanos(); metricRegistry.timer(getBaseMetricName(context)).update(nanos, TimeUnit.NANOSECONDS); - return nanos; } private String getBaseMetricName(InvocationContext context) { @@ -148,37 +105,4 @@ private String getBaseMetricName(InvocationContext context) { private void markGlobalFailure() { metricRegistry.meter(FAILURES).mark(); } - - @SuppressWarnings("PreferJavaTimeOverload") // performance sensitive - private void handleSuccessAnnotations(InvocationContext context, long nanos) { - String metricName = getAnnotatedMetricName(context); - if (metricName != null) { - metricRegistry.timer(serviceName + '.' + metricName).update(nanos, TimeUnit.NANOSECONDS); - - if (globalGroupPrefix != null) { - metricRegistry.timer(globalGroupPrefix + '.' + metricName).update(nanos, TimeUnit.NANOSECONDS); - } - } - } - - @SuppressWarnings("PreferJavaTimeOverload") // performance sensitive - private void handleFailureAnnotations(InvocationContext context, long nanos) { - String metricName = getAnnotatedMetricName(context); - if (metricName != null) { - metricRegistry - .timer(serviceName + '.' + metricName + '.' + FAILURES) - .update(nanos, TimeUnit.NANOSECONDS); - - if (globalGroupPrefix != null) { - metricRegistry - .timer(globalGroupPrefix + '.' + metricName + '.' + FAILURES) - .update(nanos, TimeUnit.NANOSECONDS); - } - } - } - - @Nullable - private String getAnnotatedMetricName(InvocationContext context) { - return metricGroups.get(AnnotationHelper.MethodSignature.of(context.getMethod())); - } } diff --git a/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/annotations/AnnotationHelper.java b/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/annotations/AnnotationHelper.java index f63c3332b..755808037 100644 --- a/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/annotations/AnnotationHelper.java +++ b/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/annotations/AnnotationHelper.java @@ -18,15 +18,17 @@ import static com.palantir.logsafe.Preconditions.checkNotNull; -import com.google.common.annotations.VisibleForTesting; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Arrays; -import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.Set; import javax.annotation.Nullable; +/** + * Do not use, will be removed in future release. + * @deprecated Do not use, will be removed in future release. + */ +@Deprecated +@SuppressWarnings("InlineMeSuggester") // this will just go away public final class AnnotationHelper { private AnnotationHelper() { @@ -34,74 +36,29 @@ private AnnotationHelper() { } /** - * Annotation as implemented on passed in type or parent of that type, works for both super classes and interfaces. - * - * @param clazz - Class type to scan for annotations - * @param annotation - Annotation type to scan for - * @return - First matching annotation found in depth first search, or null if not found + * Do not use, will be removed in future release. + * @return always null + * @deprecated Do not use, will be removed in future release. */ + @Deprecated @Nullable - public static T getSuperTypeAnnotation(Class clazz, Class annotation) { - if (clazz.isAnnotationPresent(annotation)) { - return clazz.getAnnotation(annotation); - } - - for (Class ifaces : getParentClasses(clazz)) { - T superAnnotation = getSuperTypeAnnotation(ifaces, annotation); - if (superAnnotation != null) { - return superAnnotation; - } - } - + public static T getSuperTypeAnnotation(Class _clazz, Class _annotation) { return null; } /** - * Depth first search up the Type hierarchy to find a matching annotation, Types which do not implement the - * specified method signature are ignored. - * - * @param annotation - Annotation type to scan for - * @param clazz - Class type to scan for matching annotations - * @param methodSignature - Method to search annotation for - * @return - First found matching annotation or null + * Do not use, will be removed in future release. + * @return always null + * @deprecated Do not use, will be removed in future release. */ + @Deprecated @Nullable public static T getMethodAnnotation( - Class annotation, Class clazz, MethodSignature methodSignature) { - Method method; - try { - method = clazz.getMethod(methodSignature.getMethodName(), methodSignature.getParameterTypes()); - } catch (NoSuchMethodException e) { - return null; - } - - if (method.isAnnotationPresent(annotation)) { - return method.getAnnotation(annotation); - } - - for (Class iface : getParentClasses(clazz)) { - T foundAnnotation = getMethodAnnotation(annotation, iface, methodSignature); - if (foundAnnotation != null) { - return foundAnnotation; - } - } - + Class _annotation, Class _clazz, MethodSignature _methodSignature) { return null; } - @VisibleForTesting - private static Set> getParentClasses(Class clazz) { - Set> parentClasses = Collections.newSetFromMap(new IdentityHashMap<>()); - parentClasses.addAll(Arrays.asList(clazz.getInterfaces())); - Class superclass = clazz.getSuperclass(); - while (superclass != null) { - parentClasses.addAll(Arrays.asList(superclass.getInterfaces())); - parentClasses.add(superclass); - superclass = superclass.getSuperclass(); - } - return parentClasses; - } - + @Deprecated public static final class MethodSignature { private final String methodName; private final Class[] parameterTypes; diff --git a/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/annotations/MetricGroup.java b/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/annotations/MetricGroup.java index 3d902543e..c77717f28 100644 --- a/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/annotations/MetricGroup.java +++ b/tritium-metrics/src/main/java/com/palantir/tritium/event/metrics/annotations/MetricGroup.java @@ -22,11 +22,12 @@ import java.lang.annotation.Target; /** - * Instrumentation instruction to tritium to group calls into a common metric name. Setting Type (class) level applies a - * default metric group to all Methods that are annotated + * Do not use, will be removed in future release. + * @deprecated Do not use, will be removed in future release. */ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) +@Deprecated public @interface MetricGroup { /** * String identifier grouped metrics. diff --git a/tritium-metrics/src/test/java/com/palantir/tritium/annotations/AnnotationHelperTest.java b/tritium-metrics/src/test/java/com/palantir/tritium/annotations/AnnotationHelperTest.java deleted file mode 100644 index 7328100c2..000000000 --- a/tritium-metrics/src/test/java/com/palantir/tritium/annotations/AnnotationHelperTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * (c) Copyright 2017 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.tritium.annotations; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -import com.palantir.tritium.event.metrics.annotations.AnnotationHelper; -import com.palantir.tritium.event.metrics.annotations.MetricGroup; -import org.junit.jupiter.api.Test; - -@SuppressWarnings("NullAway") // implicitly testing null handling -public class AnnotationHelperTest { - - @MetricGroup("DEFAULT") - public interface TestSuperInterface { - - @MetricGroup("ONE") - void method(); - - @MetricGroup("OVERLOAD") - void method(String arg); - - @MetricGroup("TWO") - void hasParams(String arg); - - @MetricGroup("VARGS") - void vargMethod(String... vargs); - - void otherMethod(); - } - - public interface TestOverrideInterface extends TestSuperInterface { - @Override - @MetricGroup("OVERRIDE") - void method(); - } - - @Test - public void testParentInterfaceAnnotations() throws NoSuchMethodException { - TestSuperInterface impl = mock(TestSuperInterface.class); - - // discovery annotation on parent class - MetricGroup cls = AnnotationHelper.getSuperTypeAnnotation(impl.getClass(), MetricGroup.class); - assertThat(cls).isNotNull().extracting(MetricGroup::value).isEqualTo("DEFAULT"); - - // find annotation by class method - MetricGroup met = AnnotationHelper.getMethodAnnotation( - MetricGroup.class, - impl.getClass(), - AnnotationHelper.MethodSignature.of(impl.getClass().getMethod("method"))); - assertThat(met).isNotNull().extracting(MetricGroup::value).isEqualTo("ONE"); - - // find annotation by string descriptor - MetricGroup descriptor = AnnotationHelper.getMethodAnnotation( - MetricGroup.class, impl.getClass(), AnnotationHelper.MethodSignature.of("method")); - assertThat(descriptor).isNotNull().extracting(MetricGroup::value).isEqualTo("ONE"); - - // validate overloaded methods - MetricGroup overload = AnnotationHelper.getMethodAnnotation( - MetricGroup.class, impl.getClass(), AnnotationHelper.MethodSignature.of("method", String.class)); - assertThat(overload).isNotNull().extracting(MetricGroup::value).isEqualTo("OVERLOAD"); - - // return null if annotation does not exist - MetricGroup noAnnotation = AnnotationHelper.getMethodAnnotation( - MetricGroup.class, - impl.getClass(), - AnnotationHelper.MethodSignature.of(impl.getClass().getMethod("otherMethod"))); - assertThat(noAnnotation).isNull(); - - // validate method matching with parameters - MetricGroup clsParams = AnnotationHelper.getMethodAnnotation( - MetricGroup.class, - impl.getClass(), - AnnotationHelper.MethodSignature.of(impl.getClass().getMethod("hasParams", String.class))); - assertThat(clsParams).isNotNull().extracting(MetricGroup::value).isEqualTo("TWO"); - - // validate signature matching with parameters - MetricGroup sigParams = AnnotationHelper.getMethodAnnotation( - MetricGroup.class, impl.getClass(), AnnotationHelper.MethodSignature.of("hasParams", String.class)); - assertThat(sigParams).isNotNull().extracting(MetricGroup::value).isEqualTo("TWO"); - - // return null if method does not exist - MetricGroup noMethod = AnnotationHelper.getMethodAnnotation( - MetricGroup.class, impl.getClass(), AnnotationHelper.MethodSignature.of("noMethod")); - assertThat(noMethod).isNull(); - } - - @Test - public void testMethodSignatureEquality() throws NoSuchMethodException { - assertThat(AnnotationHelper.MethodSignature.of(TestSuperInterface.class.getMethod("method"))) - .isEqualTo(AnnotationHelper.MethodSignature.of("method")); - - assertThat(AnnotationHelper.MethodSignature.of(TestSuperInterface.class.getMethod("hasParams", String.class))) - .isEqualTo(AnnotationHelper.MethodSignature.of("hasParams", String.class)); - } - - @Test - public void testVargVariants() throws NoSuchMethodException { - TestSuperInterface impl = mock(TestSuperInterface.class); - AnnotationHelper.MethodSignature vargSig = AnnotationHelper.MethodSignature.of("vargMethod", String[].class); - - // validate signature matching with vargs - MetricGroup vargParams = AnnotationHelper.getMethodAnnotation(MetricGroup.class, impl.getClass(), vargSig); - - assertThat(vargParams).isNotNull().extracting(MetricGroup::value).isEqualTo("VARGS"); - - assertThat(vargSig) - .isEqualTo( - AnnotationHelper.MethodSignature.of(impl.getClass().getMethod("vargMethod", String[].class))); - } - - @Test - public void testOverrideInterface() { - TestOverrideInterface impl = mock(TestOverrideInterface.class); - - // validate signature matching with vargs - MetricGroup override = AnnotationHelper.getMethodAnnotation( - MetricGroup.class, impl.getClass(), AnnotationHelper.MethodSignature.of("method")); - - assertThat(override).isNotNull().extracting(MetricGroup::value).isEqualTo("OVERRIDE"); - } -} diff --git a/tritium-metrics/src/test/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandlerTest.java b/tritium-metrics/src/test/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandlerTest.java index 38ed4a8b5..609a3aadf 100644 --- a/tritium-metrics/src/test/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandlerTest.java +++ b/tritium-metrics/src/test/java/com/palantir/tritium/event/metrics/MetricsInvocationEventHandlerTest.java @@ -21,31 +21,24 @@ import static org.mockito.Mockito.when; import com.codahale.metrics.MetricRegistry; -import com.palantir.tritium.event.DefaultInvocationContext; import com.palantir.tritium.event.InvocationContext; -import com.palantir.tritium.event.metrics.annotations.MetricGroup; import org.junit.jupiter.api.Test; @SuppressWarnings("NullAway") final class MetricsInvocationEventHandlerTest { - @MetricGroup("DEFAULT") interface AnnotatedTestInterface { - @MetricGroup("ONE") String methodA(); - @MetricGroup("ONE") void methodB(); - @MetricGroup("TWO") void methodC(); // Should match the default void methodD(); } - @MetricGroup("DEFAULT") interface AnnotatedOtherInterface { void methodE(); } @@ -95,59 +88,4 @@ void testSystemPropertySupplier_Handler_Enabled() { assertThat(MetricsInvocationEventHandler.getEnabledSupplier("test").getAsBoolean()) .isTrue(); } - - @Test - void testMetricGroupAnnotations() throws Exception { - AnnotatedTestInterface obj = mock(AnnotatedTestInterface.class); - when(obj.methodA()).thenReturn("ok"); - - AnnotatedOtherInterface other = mock(AnnotatedOtherInterface.class); - - MetricRegistry metricRegistry = new MetricRegistry(); - String globalPrefix = "com.business.myservice"; - - MetricsInvocationEventHandler handler = - new MetricsInvocationEventHandler(metricRegistry, obj.getClass(), globalPrefix); - - MetricsInvocationEventHandler otherHandler = - new MetricsInvocationEventHandler(metricRegistry, other.getClass(), globalPrefix); - - // AnnotatedTestInterface - callVoidMethod(handler, obj, "methodA", /* success= */ true); - callVoidMethod(handler, obj, "methodB", /* success= */ true); - callVoidMethod(handler, obj, "methodC", /* success= */ true); - callVoidMethod(handler, obj, "methodD", /* success= */ true); - callVoidMethod(handler, obj, "methodA", /* success= */ false); - - assertThat(metricRegistry.timer(obj.getClass().getName() + ".ONE").getCount()) - .isEqualTo(2L); - assertThat(metricRegistry.timer(obj.getClass().getName() + ".TWO").getCount()) - .isOne(); - assertThat(metricRegistry.timer(obj.getClass().getName() + ".DEFAULT").getCount()) - .isOne(); - assertThat(metricRegistry - .timer(obj.getClass().getName() + ".ONE.failures") - .getCount()) - .isOne(); - - // AnnotatedOtherInterface - callVoidMethod(otherHandler, other, "methodE", /* success= */ true); - assertThat(metricRegistry.timer(other.getClass().getName() + ".DEFAULT").getCount()) - .isOne(); - - // GlobalPrefix Tests - assertThat(metricRegistry.timer(globalPrefix + ".DEFAULT").getCount()).isEqualTo(2L); - assertThat(metricRegistry.timer(globalPrefix + ".ONE").getCount()).isEqualTo(2L); - } - - private static void callVoidMethod( - MetricsInvocationEventHandler handler, Object obj, String methodName, boolean success) throws Exception { - InvocationContext context = - DefaultInvocationContext.of(obj, obj.getClass().getMethod(methodName), null); - if (success) { - handler.onSuccess(context, null); - } else { - handler.onFailure(context, new RuntimeException("test failure")); - } - } }