metrics-spring
metrics-spring copied to clipboard
Support for meta-annotations
Hi,
i tried to create a meta annotation (http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#beans-meta-annotations) that uses spring retry and metrics-spring:
@Inherited
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Metered
@ExceptionMetered(cause = RuntimeException.class)
@Retryable(include = {
DuplicateKeyException.class,
OptimisticLockingFailureException.class})
public @interface ServiceMethod {
}
so that i only have to define one simple annotation at service level:
@ServiceMethod
public void methodA() {
}
This seems to work for spring retry but not for metrics-spring.
Yea, I'm afraid I haven't added support for this yet. It's on the todo list.
I would like to have this feature too. :+1:
I created a pull request. It is a good starting point for enabling meta annotations. There are 2 tests (CovariantReturnTypeTest + MeteredInterfaceTest) that will break because annotations at interface level will now be taken into consideration. I think this should be the correct behaviour because the codahale annotations are marked with Inherited.
I added a test (MetaAnnotationTest). The Counted annotation has no support for element type ANNOTATION_TYPE. So there is no test for that case. I do not understand why the annotation from codahale is not used in the CountedMethodInterceptor. Why does your Counted annotation exist?