Capgemini / spring-boot-capgemini

Apache License 2.0
16 stars 8 forks source link

Implement an easy Starter #6

Closed rhart closed 9 years ago

rhart commented 9 years ago

We should implement a very simple Starter (including example app) just to test out the build and release process as quickly as possible. Even if the Starter is throw away.

rhart commented 9 years ago

I think something like this would be a good first candidate:

@Configuration
@EnableAspectJAutoProxy(proxyTargetClass=true)
public class TraceLoggerConfig {

    @Bean
    public CustomizableTraceInterceptor customizableTraceInterceptor() {
        CustomizableTraceInterceptor customizableTraceInterceptor = new CustomizableTraceInterceptor();
        customizableTraceInterceptor.setUseDynamicLogger(true);
        customizableTraceInterceptor.setEnterMessage("Entering $[methodName]($[arguments])");
        customizableTraceInterceptor.setExitMessage("Leaving  $[methodName](), returned $[returnValue]");
        return customizableTraceInterceptor;
    }

    @Bean
    public Advisor jpaRepositoryAdvisor() {
        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
        pointcut.setExpression("execution(public * org.springframework.data.jpa.repository.JpaRepository+.*(..))");
        return new DefaultPointcutAdvisor(pointcut, customizableTraceInterceptor());
    }

}

Except we need to generalize the Advisor and allow configuration of the pointcut expression. Or maybe dynamically create advisors based on properties.

andrewharmellaw commented 9 years ago

+1 for that

On Tue, 24 Mar 2015 at 15:44 Rus notifications@github.com wrote:

I think something like this would be a good first candidate:

@Configuration @EnableAspectJAutoProxy(proxyTargetClass=true) public class TraceLoggerConfig {

@Bean
public CustomizableTraceInterceptor customizableTraceInterceptor() {
    CustomizableTraceInterceptor customizableTraceInterceptor = new CustomizableTraceInterceptor();
    customizableTraceInterceptor.setUseDynamicLogger(true);
    customizableTraceInterceptor.setEnterMessage("Entering $[methodName]($[arguments])");
    customizableTraceInterceptor.setExitMessage("Leaving  $[methodName](), returned $[returnValue]");
    return customizableTraceInterceptor;
}

@Bean
public Advisor jpaRepositoryAdvisor() {
    AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
    pointcut.setExpression("execution(public * org.springframework.data.jpa.repository.JpaRepository+.*(..))");
    return new DefaultPointcutAdvisor(pointcut, customizableTraceInterceptor());
}

}

Except we need to generalize the Advisor and allow configuration of the pointcut expression. Or maybe dynamically create advisors based on properties.

— Reply to this email directly or view it on GitHub https://github.com/Capgemini/spring-boot-capgemini/issues/6#issuecomment-85567732 .

craigwilliams84 commented 9 years ago

I'll start working on this by the end of the week.

rhart commented 9 years ago

Great!

I think we need a new sub module to house it. Something like spring-boot-diagnostics or something else that nicely describes logging, tracing, metrics etc. But probably not "actuator" :)

Let's tackle it in 3 stages so we can unblock other tasks and iterate it into something that I think will be quite useful actually:

  1. Single Advisor with a configurable pointcut expression. Simple to do but we could end up with a very complex pointcut expression.
  2. Dynamically create multiple Advisor based on properties like method-trace.repository=..... method-trace.cgs=..... method-trace.fgs=...... This will allow many simple expressions.
  3. Allow runtime reload of pointcut expressions. So if we change an expression (or disable one) the app won't require a restart. Not sure how feasible this is at the moment.

Feel free to break this down into smaller tasks if that makes sense. Is probably a good idea so we can show progress easier.

craigwilliams84 commented 9 years ago

Closing this issue and creating new issues for trace logging tasks