Integration with Spring Sleuth #257

Open
meong1234 opened this Issue Jan 25, 2017 · 2 comments

Projects

None yet

3 participants

@meong1234

it nice if axon provide integration with distrubuted tracing use spring sleuth
https://cloud.spring.io/spring-cloud-sleuth/

@meong1234

`@Aspect
public class TraceEventHandler {

private static final String EVENT_HANDLER_COMPONENT = "eventhandler";

private final Tracer tracer;
private final TraceKeys traceKeys;
private final Pattern skipPattern;

public TraceEventHandler(Tracer tracer, TraceKeys traceKeys, Pattern skipPattern) {
    this.tracer = tracer;
    this.traceKeys = traceKeys;
    this.skipPattern = skipPattern;
}

@Around("execution (@org.axonframework.eventhandling.annotation.EventHandler  * *.*(..))")
public Object traceBackgroundThread(final ProceedingJoinPoint pjp) throws Throwable {
    if (this.skipPattern.matcher(pjp.getTarget().getClass().getName()).matches()) {
        return pjp.proceed();
    }
    String spanName = SpanNameUtil.toLowerHyphen(pjp.getSignature().getName());
    Span span = this.tracer.createSpan(spanName);
    this.tracer.addTag(Span.SPAN_LOCAL_COMPONENT_TAG_NAME, EVENT_HANDLER_COMPONENT);
    this.tracer.addTag(this.traceKeys.getAsync().getPrefix() +
        this.traceKeys.getAsync().getClassNameKey(), pjp.getTarget().getClass().getSimpleName());
    this.tracer.addTag(this.traceKeys.getAsync().getPrefix() +
        this.traceKeys.getAsync().getMethodNameKey(), pjp.getSignature().getName());
    try {
        return pjp.proceed();
    }
    finally {
        this.tracer.close(span);
    }
}

}`

example by use anotation @EventHandler

@abuijze abuijze added the Feature label Jan 25, 2017
@jorgheymans
Contributor

just a thought, IIRC axon3 supports dropwizard, so you might be able to get something working combining https://github.com/opentracing-contrib/java-dropwizard , https://github.com/openzipkin/brave and the zipkin connector of spring cloud sleuth https://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html#_spring_cloud_sleuth_stream_zipkin_collector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment