OkHttp instumentation: simplify error case
MODIFY
dd-java-agent/instrumentation/okhttp-3/src/main/java/datadog/trace/instrumentation/okhttp3/OkHttpClientSpanDecorator.java
dd-java-agent/instrumentation/okhttp-3/src/main/java/datadog/trace/instrumentation/okhttp3/OkHttpClientSpanDecorator.java
@@ -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;
- }
};
}

OkHttp instumentation: simplify error case