metrics-spring icon indicating copy to clipboard operation
metrics-spring copied to clipboard

Support for meta-annotations

Open einachim opened this issue 9 years ago • 3 comments

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.

einachim avatar Jan 22 '16 12:01 einachim

Yea, I'm afraid I haven't added support for this yet. It's on the todo list.

ryantenney avatar Jan 22 '16 14:01 ryantenney

I would like to have this feature too. :+1:

b0n541 avatar Jan 22 '16 15:01 b0n541

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?

einachim avatar Jan 26 '16 10:01 einachim