INNER CODE UNIT · Java
SpanUtils
opentracing-contrib/java-spring-cloud · instrument-starters/opentracing-spring-cloud-core/src/main/java/io/opentracing/contrib/spring/cloud/SpanUtils.java:26
public class SpanUtils {
private SpanUtils() {
}
/**
* Add appropriate error tags and logs to a span when an exception occurs
*
* @param span the span "monitoring" the code which threw the exception
* @param ex captured exception
*/
public static void captureException(Span span, Exception ex) {
Map<String, Object> exceptionLogs = new LinkedHashMap<>(2);
exceptionLogs.put("event", Tags.ERROR.getKey());
exceptionLogs.put("error.object", ex);
span.log(exceptionLogs);
Tags.ERROR.set(span, true);
}