Merge pull request #217 from DataDog/tyler/ipv4-string
Use string instead of int representation for IPv4
This commit is contained in:
commit
b557776bcf
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue