Use string instead of int representation for IPv4
MODIFY
dd-java-agent-ittests/src/test/java/datadog/trace/agent/integration/MongoAsyncClientInstrumentationTest.java
dd-java-agent-ittests/src/test/java/datadog/trace/agent/integration/MongoAsyncClientInstrumentationTest.java
@@ -13,8 +13,6 @@ import datadog.opentracing.DDTracer;
import datadog.trace.agent.test.TestUtils;
import datadog.trace.common.writer.ListWriter;
import io.opentracing.tag.Tags;
-import java.net.InetAddress;
-import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicBoolean;
import org.bson.Document;
import org.junit.AfterClass;
@@ -113,9 +111,7 @@ public class MongoAsyncClientInstrumentationTest {
Assert.assertEquals(createCollectionQuery, trace0.getTags().get(Tags.DB_STATEMENT.getKey()));
Assert.assertEquals(MONGO_DB_NAME, trace0.getTags().get(Tags.DB_INSTANCE.getKey()));
Assert.assertEquals(MONGO_HOST, trace0.getTags().get(Tags.PEER_HOSTNAME.getKey()));
- Assert.assertEquals(
- ByteBuffer.wrap(InetAddress.getByName("127.0.0.1").getAddress()).getInt(),
- trace0.getTags().get(Tags.PEER_HOST_IPV4.getKey()));
+ Assert.assertEquals("127.0.0.1", trace0.getTags().get(Tags.PEER_HOST_IPV4.getKey()));
Assert.assertEquals(MONGO_PORT, trace0.getTags().get(Tags.PEER_PORT.getKey()));
Assert.assertEquals("mongo", trace0.getTags().get(Tags.DB_TYPE.getKey()));
}

MODIFY
dd-java-agent-ittests/src/test/java/datadog/trace/agent/integration/MongoClientInstrumentationTest.java
dd-java-agent-ittests/src/test/java/datadog/trace/agent/integration/MongoClientInstrumentationTest.java
@@ -16,9 +16,7 @@ import de.flapdoodle.embed.mongo.config.Net;
import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.process.runtime.Network;
import io.opentracing.tag.Tags;
-import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.nio.ByteBuffer;
import org.bson.Document;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -110,9 +108,7 @@ public class MongoClientInstrumentationTest {
Assert.assertEquals(createCollectionQuery, trace0.getTags().get(Tags.DB_STATEMENT.getKey()));
Assert.assertEquals(MONGO_DB_NAME, trace0.getTags().get(Tags.DB_INSTANCE.getKey()));
Assert.assertEquals(MONGO_HOST, trace0.getTags().get(Tags.PEER_HOSTNAME.getKey()));
- Assert.assertEquals(
- ByteBuffer.wrap(InetAddress.getByName("127.0.0.1").getAddress()).getInt(),
- trace0.getTags().get(Tags.PEER_HOST_IPV4.getKey()));
+ Assert.assertEquals("127.0.0.1", trace0.getTags().get(Tags.PEER_HOST_IPV4.getKey()));
Assert.assertEquals(MONGO_PORT, trace0.getTags().get(Tags.PEER_PORT.getKey()));
Assert.assertEquals("mongo", trace0.getTags().get(Tags.DB_TYPE.getKey()));
}

MODIFY
dd-java-agent/instrumentation/mongo-3.1/src/main/java/datadog/trace/instrumentation/mongo/DDTracingCommandListener.java
dd-java-agent/instrumentation/mongo-3.1/src/main/java/datadog/trace/instrumentation/mongo/DDTracingCommandListener.java
@@ -10,7 +10,6 @@ import io.opentracing.Tracer;
import io.opentracing.tag.Tags;
import java.net.Inet4Address;
import java.net.InetAddress;
-import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -96,8 +95,7 @@ public class DDTracingCommandListener implements CommandListener {
InetAddress inetAddress =
event.getConnectionDescription().getServerAddress().getSocketAddress().getAddress();
if (inetAddress instanceof Inet4Address) {
- byte[] address = inetAddress.getAddress();
- Tags.PEER_HOST_IPV4.set(span, ByteBuffer.wrap(address).getInt());
+ Tags.PEER_HOST_IPV4.set(span, inetAddress.getHostAddress());
} else {
Tags.PEER_HOST_IPV6.set(span, inetAddress.getHostAddress());
}

Use string instead of int representation for IPv4