use Slf4j annotation.
This commit is contained in:
parent
abffe1779b
commit
2041d56de8
|
@ -5,6 +5,7 @@ import static io.opentracing.log.Fields.ERROR_OBJECT;
|
|||
import io.opentracing.Span;
|
||||
import io.opentracing.tag.Tags;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Collections;
|
||||
import okhttp3.Connection;
|
||||
import okhttp3.Request;
|
||||
|
@ -70,16 +71,17 @@ public interface OkHttpClientSpanDecorator {
|
|||
@Override
|
||||
public void onResponse(
|
||||
final Connection connection, final Response response, final Span span) {
|
||||
final InetAddress inetAddress = connection.socket().getInetAddress();
|
||||
|
||||
Tags.HTTP_STATUS.set(span, response.code());
|
||||
Tags.PEER_HOSTNAME.set(span, connection.socket().getInetAddress().getHostName());
|
||||
Tags.PEER_HOSTNAME.set(span, inetAddress.getHostName());
|
||||
Tags.PEER_PORT.set(span, connection.socket().getPort());
|
||||
|
||||
final String address = connection.socket().getInetAddress().getHostAddress();
|
||||
String ipvKey = Tags.PEER_HOST_IPV4.getKey();
|
||||
if (connection.socket().getInetAddress() instanceof Inet6Address) {
|
||||
if (inetAddress instanceof Inet6Address) {
|
||||
ipvKey = Tags.PEER_HOST_IPV6.getKey();
|
||||
}
|
||||
span.setTag(ipvKey, address);
|
||||
span.setTag(ipvKey, inetAddress.getHostAddress());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Dispatcher;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* OkHttp interceptor to trace client requests. Interceptor adds span context into outgoing
|
||||
|
@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
|
|||
*
|
||||
* @author Pavol Loffay
|
||||
*/
|
||||
@Slf4j
|
||||
public class TracingInterceptor implements Interceptor {
|
||||
|
||||
private final Tracer tracer;
|
||||
|
@ -119,8 +120,7 @@ public class TracingInterceptor implements Interceptor {
|
|||
tracer, tagWrapper.getSpan().context(), decorators)
|
||||
.intercept(chain);
|
||||
} else {
|
||||
LoggerFactory.getLogger(TracingInterceptor.class.getName())
|
||||
.error("tag is null or not an instance of TagWrapper, skipping decorator onResponse()");
|
||||
log.error("tag is null or not an instance of TagWrapper, skipping decorator onResponse()");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue