Skip to content

Instantly share code, notes, and snippets.

@zhaohuabing
Created August 24, 2019 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhaohuabing/76c934e067315769ee6ca71e69da7dc3 to your computer and use it in GitHub Desktop.
Save zhaohuabing/76c934e067315769ee6ca71e69da7dc3 to your computer and use it in GitHub Desktop.
@Aspect
@Component
public class TracingAspect {
@Autowired
Tracer tracer;
@Around("@annotation(com.zhaohuabing.demo.instrument.Traced)")
public Object aroundAdvice(ProceedingJoinPoint jp) throws Throwable {
String class_name = jp.getTarget().getClass().getName();
String method_name = jp.getSignature().getName();
Span span = tracer.buildSpan(class_name + "." + method_name).withTag("class", class_name)
.withTag("method", method_name).start();
Object result = jp.proceed();
span.finish();
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment