OkHttp instumentation: simplify error case
This commit is contained in:
parent
1aaa3cafeb
commit
a882a5439c
|
@ -4,12 +4,15 @@ import io.opentracing.Span;
|
|||
import io.opentracing.tag.Tags;
|
||||
import java.net.Inet4Address;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import okhttp3.Connection;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
|
||||
/**
|
||||
* Span decorator to add tags, logs and operation name.
|
||||
*
|
||||
|
@ -64,7 +67,7 @@ public interface OkHttpClientSpanDecorator {
|
|||
@Override
|
||||
public void onError(final Throwable throwable, final Span span) {
|
||||
Tags.ERROR.set(span, Boolean.TRUE);
|
||||
span.log(errorLogs(throwable));
|
||||
span.log(Collections.singletonMap(ERROR_OBJECT, throwable));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,13 +84,5 @@ public interface OkHttpClientSpanDecorator {
|
|||
Tags.PEER_HOST_IPV6.set(span, connection.socket().getInetAddress().toString());
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, Object> errorLogs(final Throwable throwable) {
|
||||
final Map<String, Object> errorLogs = new HashMap<>(2);
|
||||
errorLogs.put("event", Tags.ERROR.getKey());
|
||||
errorLogs.put("error.object", throwable);
|
||||
|
||||
return errorLogs;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue