Closed rhart closed 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.
+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 .
I'll start working on this by the end of the week.
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:
Advisor
with a configurable pointcut expression. Simple to do but we could end up with a very complex pointcut expression.Advisor
based on properties like method-trace.repository=.....
method-trace.cgs=.....
method-trace.fgs=.....
. This will allow many simple expressions.Feel free to break this down into smaller tasks if that makes sense. Is probably a good idea so we can show progress easier.
Closing this issue and creating new issues for trace logging tasks
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.