Commit 2aaa0bd9 authored by 杨锐's avatar 杨锐

done

parent 67f5e068
......@@ -428,25 +428,22 @@ public class BraveAutoConfiguration {
@Around("target(com.dangdang.ddframe.job.api.ElasticJob)")
public Object dynamicTrace(ProceedingJoinPoint pjp) throws Throwable {
try {
Tracer tracer = tracing().tracer();
/* 防止应用层非法使用(上下文中存在span),不生成root span。 */
if (tracer.currentSpan() == null) {
if (tracer.currentSpan() != null) {
return pjp.proceed();
}
brave.Span span = tracer.newTrace();
try (Tracer.SpanInScope ws = tracer.withSpanInScope(span)) {
// note: try-with-resources closes the scope *before* the catch block
return pjp.proceed();
} catch (RuntimeException | Error e) {
log.error("dynamicTrace error = 【{}】", e);
span.error(e);
throw e;
} finally {
span.finish();
}
}
} finally {
/* just in case, maybe not. */
return pjp.proceed();
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment