From c61034c945c5b5104183806ef4915f50bc0f8715 Mon Sep 17 00:00:00 2001 From: Richard Startin Date: Tue, 2 Jun 2020 08:03:45 +0100 Subject: [PATCH] Fix elasticsearch test flakiness (DataDog/dd-trace-java#1513) --- .../Elasticsearch6RestClientTest.groovy | 28 ++---- .../Elasticsearch5RestClientTest.groovy | 28 ++---- .../Elasticsearch6RestClientTest.groovy | 29 +++--- .../Elasticsearch6RestClientTest.groovy | 28 ++---- .../Elasticsearch2NodeClientTest.groovy | 22 ++--- .../Elasticsearch2TransportClientTest.groovy | 95 ++++++++++++------- .../Elasticsearch2SpringTemplateTest.groovy | 19 +--- .../Elasticsearch2NodeClientTest.groovy | 19 +--- .../Elasticsearch2TransportClientTest.groovy | 71 ++++++-------- .../Elasticsearch2SpringTemplateTest.groovy | 19 +--- .../Elasticsearch5NodeClientTest.groovy | 19 +--- .../Elasticsearch5TransportClientTest.groovy | 57 +++++------ .../Elasticsearch53NodeClientTest.groovy | 19 +--- .../Elasticsearch53TransportClientTest.groovy | 58 +++++------ .../Elasticsearch53SpringTemplateTest.groovy | 19 +--- .../Elasticsearch6NodeClientTest.groovy | 19 +--- .../Elasticsearch6TransportClientTest.groovy | 46 ++++----- 17 files changed, 226 insertions(+), 369 deletions(-) diff --git a/instrumentation/elasticsearch/elasticsearch-rest-5.0/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-rest-5.0/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy index e9009e8c0e..15713fad72 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-5.0/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-rest-5.0/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy @@ -18,7 +18,6 @@ import io.opentelemetry.auto.bootstrap.instrumentation.decorator.HttpClientDecor import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.apache.http.HttpHost import org.apache.http.client.config.RequestConfig import org.apache.http.util.EntityUtils @@ -27,6 +26,8 @@ import org.elasticsearch.client.RestClient import org.elasticsearch.client.RestClientBuilder import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings +import org.elasticsearch.common.transport.TransportAddress +import org.elasticsearch.http.HttpServerTransport import org.elasticsearch.node.InternalSettingsPreparer import org.elasticsearch.node.Node import org.elasticsearch.transport.Netty4Plugin @@ -37,26 +38,18 @@ import static io.opentelemetry.trace.Span.Kind.INTERNAL class Elasticsearch6RestClientTest extends AgentTestRunner { @Shared - int httpPort - @Shared - int tcpPort + TransportAddress httpTransportAddress @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared RestClient client def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -64,14 +57,13 @@ class Elasticsearch6RestClientTest extends AgentTestRunner { def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) - .put("cluster.name", "test-cluster") + .put("cluster.name", clusterName) .build() testNode = new Node(InternalSettingsPreparer.prepareEnvironment(settings, null), [Netty4Plugin]) testNode.start() + httpTransportAddress = testNode.injector().getInstance(HttpServerTransport).boundAddress().publishAddress() - client = RestClient.builder(new HttpHost("localhost", httpPort)) + client = RestClient.builder(new HttpHost(httpTransportAddress.address, httpTransportAddress.port)) .setMaxRetryTimeoutMillis(Integer.MAX_VALUE) .setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { @Override @@ -107,8 +99,8 @@ class Elasticsearch6RestClientTest extends AgentTestRunner { spanKind INTERNAL parent() tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_PORT" httpPort + "$MoreTags.NET_PEER_NAME" httpTransportAddress.address + "$MoreTags.NET_PEER_PORT" httpTransportAddress.port "$Tags.HTTP_URL" "_cluster/health" "$Tags.HTTP_METHOD" "GET" "$Tags.DB_TYPE" "elasticsearch" diff --git a/instrumentation/elasticsearch/elasticsearch-rest-5.0/src/test/groovy/Elasticsearch5RestClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-rest-5.0/src/test/groovy/Elasticsearch5RestClientTest.groovy index ebaecbf740..16be3f05e1 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-5.0/src/test/groovy/Elasticsearch5RestClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-rest-5.0/src/test/groovy/Elasticsearch5RestClientTest.groovy @@ -18,7 +18,6 @@ import io.opentelemetry.auto.bootstrap.instrumentation.decorator.HttpClientDecor import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.apache.http.HttpHost import org.apache.http.client.config.RequestConfig import org.apache.http.util.EntityUtils @@ -27,7 +26,9 @@ import org.elasticsearch.client.RestClient import org.elasticsearch.client.RestClientBuilder import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings +import org.elasticsearch.common.transport.TransportAddress import org.elasticsearch.env.Environment +import org.elasticsearch.http.HttpServerTransport import org.elasticsearch.node.Node import org.elasticsearch.node.internal.InternalSettingsPreparer import org.elasticsearch.transport.Netty3Plugin @@ -39,26 +40,18 @@ import static org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING class Elasticsearch5RestClientTest extends AgentTestRunner { @Shared - int httpPort - @Shared - int tcpPort + TransportAddress httpTransportAddress @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared static RestClient client def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -66,16 +59,15 @@ class Elasticsearch5RestClientTest extends AgentTestRunner { def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .put("transport.type", "netty3") .put("http.type", "netty3") - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() testNode = new Node(new Environment(InternalSettingsPreparer.prepareSettings(settings)), [Netty3Plugin]) testNode.start() + httpTransportAddress = testNode.injector().getInstance(HttpServerTransport).boundAddress().publishAddress() - client = RestClient.builder(new HttpHost("localhost", httpPort)) + client = RestClient.builder(new HttpHost(httpTransportAddress.address, httpTransportAddress.port)) .setMaxRetryTimeoutMillis(Integer.MAX_VALUE) .setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { @Override @@ -111,8 +103,8 @@ class Elasticsearch5RestClientTest extends AgentTestRunner { spanKind INTERNAL parent() tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_PORT" httpPort + "$MoreTags.NET_PEER_NAME" httpTransportAddress.address + "$MoreTags.NET_PEER_PORT" httpTransportAddress.port "$Tags.HTTP_URL" "_cluster/health" "$Tags.HTTP_METHOD" "GET" "$Tags.DB_TYPE" "elasticsearch" diff --git a/instrumentation/elasticsearch/elasticsearch-rest-6.4/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-rest-6.4/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy index ba4f2fc22b..6b5d5309c2 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-6.4/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-rest-6.4/src/latestDepTest/groovy/Elasticsearch6RestClientTest.groovy @@ -18,7 +18,6 @@ import io.opentelemetry.auto.bootstrap.instrumentation.decorator.HttpClientDecor import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.apache.http.HttpHost import org.apache.http.client.config.RequestConfig import org.apache.http.util.EntityUtils @@ -28,7 +27,9 @@ import org.elasticsearch.client.RestClient import org.elasticsearch.client.RestClientBuilder import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings +import org.elasticsearch.common.transport.TransportAddress import org.elasticsearch.env.Environment +import org.elasticsearch.http.HttpServerTransport import org.elasticsearch.node.InternalSettingsPreparer import org.elasticsearch.node.Node import org.elasticsearch.plugins.Plugin @@ -39,10 +40,9 @@ import static io.opentelemetry.trace.Span.Kind.CLIENT import static io.opentelemetry.trace.Span.Kind.INTERNAL class Elasticsearch6RestClientTest extends AgentTestRunner { + @Shared - int httpPort - @Shared - int tcpPort + TransportAddress httpTransportAddress @Shared Node testNode @Shared @@ -50,16 +50,10 @@ class Elasticsearch6RestClientTest extends AgentTestRunner { @Shared RestClient client + @Shared + String clusterName = UUID.randomUUID().toString() def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -67,14 +61,13 @@ class Elasticsearch6RestClientTest extends AgentTestRunner { def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) - .put("cluster.name", "test-cluster") + .put("cluster.name", clusterName) .build() testNode = new TestNode(InternalSettingsPreparer.prepareEnvironment(settings, null), [Netty4Plugin]) testNode.start() + httpTransportAddress = testNode.injector().getInstance(HttpServerTransport).boundAddress().publishAddress() - client = RestClient.builder(new HttpHost("localhost", httpPort)) + client = RestClient.builder(new HttpHost(httpTransportAddress.address, httpTransportAddress.port)) .setMaxRetryTimeoutMillis(Integer.MAX_VALUE) .setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { @Override @@ -111,8 +104,8 @@ class Elasticsearch6RestClientTest extends AgentTestRunner { spanKind INTERNAL parent() tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_PORT" httpPort + "$MoreTags.NET_PEER_NAME" httpTransportAddress.address + "$MoreTags.NET_PEER_PORT" httpTransportAddress.port "$Tags.HTTP_URL" "_cluster/health" "$Tags.HTTP_METHOD" "GET" "$Tags.DB_TYPE" "elasticsearch" diff --git a/instrumentation/elasticsearch/elasticsearch-rest-6.4/src/test/groovy/Elasticsearch6RestClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-rest-6.4/src/test/groovy/Elasticsearch6RestClientTest.groovy index e9009e8c0e..15713fad72 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-6.4/src/test/groovy/Elasticsearch6RestClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-rest-6.4/src/test/groovy/Elasticsearch6RestClientTest.groovy @@ -18,7 +18,6 @@ import io.opentelemetry.auto.bootstrap.instrumentation.decorator.HttpClientDecor import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.apache.http.HttpHost import org.apache.http.client.config.RequestConfig import org.apache.http.util.EntityUtils @@ -27,6 +26,8 @@ import org.elasticsearch.client.RestClient import org.elasticsearch.client.RestClientBuilder import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings +import org.elasticsearch.common.transport.TransportAddress +import org.elasticsearch.http.HttpServerTransport import org.elasticsearch.node.InternalSettingsPreparer import org.elasticsearch.node.Node import org.elasticsearch.transport.Netty4Plugin @@ -37,26 +38,18 @@ import static io.opentelemetry.trace.Span.Kind.INTERNAL class Elasticsearch6RestClientTest extends AgentTestRunner { @Shared - int httpPort - @Shared - int tcpPort + TransportAddress httpTransportAddress @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared RestClient client def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -64,14 +57,13 @@ class Elasticsearch6RestClientTest extends AgentTestRunner { def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) - .put("cluster.name", "test-cluster") + .put("cluster.name", clusterName) .build() testNode = new Node(InternalSettingsPreparer.prepareEnvironment(settings, null), [Netty4Plugin]) testNode.start() + httpTransportAddress = testNode.injector().getInstance(HttpServerTransport).boundAddress().publishAddress() - client = RestClient.builder(new HttpHost("localhost", httpPort)) + client = RestClient.builder(new HttpHost(httpTransportAddress.address, httpTransportAddress.port)) .setMaxRetryTimeoutMillis(Integer.MAX_VALUE) .setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { @Override @@ -107,8 +99,8 @@ class Elasticsearch6RestClientTest extends AgentTestRunner { spanKind INTERNAL parent() tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_PORT" httpPort + "$MoreTags.NET_PEER_NAME" httpTransportAddress.address + "$MoreTags.NET_PEER_PORT" httpTransportAddress.port "$Tags.HTTP_URL" "_cluster/health" "$Tags.HTTP_METHOD" "GET" "$Tags.DB_TYPE" "elasticsearch" diff --git a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/Elasticsearch2NodeClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/Elasticsearch2NodeClientTest.groovy index 01f9aea48d..9dd0d32c46 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/Elasticsearch2NodeClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/Elasticsearch2NodeClientTest.groovy @@ -15,13 +15,14 @@ */ import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings +import org.elasticsearch.common.transport.TransportAddress import org.elasticsearch.index.IndexNotFoundException import org.elasticsearch.node.Node import org.elasticsearch.node.NodeBuilder +import org.elasticsearch.transport.TransportService import spock.lang.Shared import static io.opentelemetry.auto.test.utils.TraceUtils.runUnderTrace @@ -31,25 +32,17 @@ class Elasticsearch2NodeClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds @Shared - int httpPort - @Shared - int tcpPort + TransportAddress tcpPublishAddress @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() def client = testNode.client() def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -59,11 +52,10 @@ class Elasticsearch2NodeClientTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("threadpool.listener.size", 1) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .build() - testNode = NodeBuilder.newInstance().local(true).clusterName("test-cluster").settings(settings).build() + testNode = NodeBuilder.newInstance().local(true).clusterName(clusterName).settings(settings).build() testNode.start() + tcpPublishAddress = testNode.injector().getInstance(TransportService).boundAddress().publishAddress() runUnderTrace("setup") { // this may potentially create multiple requests and therefore multiple spans, so we wrap this call // into a top level trace to get exactly one trace in the result. diff --git a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/Elasticsearch2TransportClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/Elasticsearch2TransportClientTest.groovy index 166abd77b8..5510d9dfe7 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/Elasticsearch2TransportClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/Elasticsearch2TransportClientTest.groovy @@ -16,16 +16,17 @@ import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest +import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest import org.elasticsearch.client.transport.TransportClient import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings -import org.elasticsearch.common.transport.InetSocketTransportAddress +import org.elasticsearch.common.transport.TransportAddress import org.elasticsearch.index.IndexNotFoundException import org.elasticsearch.node.Node import org.elasticsearch.node.NodeBuilder import org.elasticsearch.transport.RemoteTransportException +import org.elasticsearch.transport.TransportService import spock.lang.Shared import static io.opentelemetry.auto.test.utils.TraceUtils.runUnderTrace @@ -35,26 +36,18 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds @Shared - int httpPort - @Shared - int tcpPort + TransportAddress tcpPublishAddress @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared TransportClient client def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -62,20 +55,20 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .build() - testNode = NodeBuilder.newInstance().clusterName("test-cluster").settings(settings).build() + testNode = NodeBuilder.newInstance().clusterName(clusterName).settings(settings).build() testNode.start() + tcpPublishAddress = testNode.injector().getInstance(TransportService).boundAddress().publishAddress() + client = TransportClient.builder().settings( Settings.builder() // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("threadpool.listener.size", 1) - .put("cluster.name", "test-cluster") + .put("cluster.name", clusterName) .build() ).build() - client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), tcpPort)) + client.addTransportAddress(tcpPublishAddress) runUnderTrace("setup") { // this may potentially create multiple requests and therefore multiple spans, so we wrap this call // into a top level trace to get exactly one trace in the result. @@ -107,9 +100,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "ClusterHealthAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" @@ -119,6 +112,36 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { } } + def "test elasticsearch stats"() { + setup: + def result = client.admin().cluster().clusterStats(new ClusterStatsRequest(new String[0])) + + def status = result.get().status + def failures = result.get().failures() + + expect: + status.name() == "GREEN" + failures == null + + assertTraces(1) { + trace(0, 1) { + span(0) { + operationName "ClusterStatsAction" + spanKind CLIENT + tags { + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port + "$Tags.DB_TYPE" "elasticsearch" + "elasticsearch.action" "ClusterStatsAction" + "elasticsearch.request" "ClusterStatsRequest" + "elasticsearch.node.cluster.name" clusterName + } + } + } + } + } + def "test elasticsearch error"() { when: client.prepareGet(indexName, indexType, id).get() @@ -202,9 +225,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "CreateIndexAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "CreateIndexAction" "elasticsearch.request" "CreateIndexRequest" @@ -217,9 +240,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "ClusterHealthAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" @@ -231,9 +254,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "GetAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" @@ -261,9 +284,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "IndexAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "IndexAction" "elasticsearch.request" "IndexRequest" @@ -277,9 +300,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "GetAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" diff --git a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/springdata/Elasticsearch2SpringTemplateTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/springdata/Elasticsearch2SpringTemplateTest.groovy index d0de3aa5f6..c55bd8147d 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/springdata/Elasticsearch2SpringTemplateTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/latestDepTest/groovy/springdata/Elasticsearch2SpringTemplateTest.groovy @@ -17,7 +17,6 @@ package springdata import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.search.SearchResponse import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings @@ -40,27 +39,17 @@ import static io.opentelemetry.trace.Span.Kind.CLIENT class Elasticsearch2SpringTemplateTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds - @Shared - int httpPort - @Shared - int tcpPort @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared ElasticsearchTemplate template def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -70,10 +59,8 @@ class Elasticsearch2SpringTemplateTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("threadpool.listener.size", 1) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .build() - testNode = NodeBuilder.newInstance().local(true).clusterName("test-cluster").settings(settings).build() + testNode = NodeBuilder.newInstance().local(true).clusterName(clusterName).settings(settings).build() testNode.start() template = new ElasticsearchTemplate(testNode.client()) diff --git a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/Elasticsearch2NodeClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/Elasticsearch2NodeClientTest.groovy index 1206b6facd..937ba2f07c 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/Elasticsearch2NodeClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/Elasticsearch2NodeClientTest.groovy @@ -16,7 +16,6 @@ import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings @@ -31,26 +30,16 @@ import static io.opentelemetry.trace.Span.Kind.CLIENT class Elasticsearch2NodeClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds - @Shared - int httpPort - @Shared - int tcpPort @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() def client = testNode.client() def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -60,10 +49,8 @@ class Elasticsearch2NodeClientTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("threadpool.listener.size", 1) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .build() - testNode = NodeBuilder.newInstance().local(true).clusterName("test-cluster").settings(settings).build() + testNode = NodeBuilder.newInstance().local(true).clusterName(clusterName).settings(settings).build() testNode.start() runUnderTrace("setup") { // this may potentially create multiple requests and therefore multiple spans, so we wrap this call diff --git a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/Elasticsearch2TransportClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/Elasticsearch2TransportClientTest.groovy index 84c64abac8..a8bbe418c3 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/Elasticsearch2TransportClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/Elasticsearch2TransportClientTest.groovy @@ -16,17 +16,17 @@ import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest import org.elasticsearch.action.admin.cluster.stats.ClusterStatsRequest import org.elasticsearch.client.transport.TransportClient import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings -import org.elasticsearch.common.transport.InetSocketTransportAddress +import org.elasticsearch.common.transport.TransportAddress import org.elasticsearch.index.IndexNotFoundException import org.elasticsearch.node.Node import org.elasticsearch.node.NodeBuilder import org.elasticsearch.transport.RemoteTransportException +import org.elasticsearch.transport.TransportService import spock.lang.Shared import static io.opentelemetry.auto.test.utils.TraceUtils.runUnderTrace @@ -36,26 +36,18 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds @Shared - int httpPort - @Shared - int tcpPort + TransportAddress tcpPublishAddress @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared TransportClient client def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -63,20 +55,19 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .build() - testNode = NodeBuilder.newInstance().clusterName("test-cluster").settings(settings).build() + testNode = NodeBuilder.newInstance().clusterName(clusterName).settings(settings).build() testNode.start() + tcpPublishAddress = testNode.injector().getInstance(TransportService).boundAddress().publishAddress() client = TransportClient.builder().settings( Settings.builder() // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("threadpool.listener.size", 1) - .put("cluster.name", "test-cluster") + .put("cluster.name", clusterName) .build() ).build() - client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), tcpPort)) + client.addTransportAddress(tcpPublishAddress) runUnderTrace("setup") { // this may potentially create multiple requests and therefore multiple spans, so we wrap this call // into a top level trace to get exactly one trace in the result. @@ -108,9 +99,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "ClusterHealthAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "127.0.0.1" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" @@ -136,13 +127,13 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { span(0) { operationName "ClusterStatsAction" tags { - "$MoreTags.NET_PEER_NAME" "127.0.0.1" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "ClusterStatsAction" "elasticsearch.request" "ClusterStatsRequest" - "elasticsearch.node.cluster.name" "test-cluster" + "elasticsearch.node.cluster.name" clusterName } } } @@ -232,9 +223,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "CreateIndexAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "127.0.0.1" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "CreateIndexAction" "elasticsearch.request" "CreateIndexRequest" @@ -247,9 +238,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "ClusterHealthAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "127.0.0.1" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" @@ -261,9 +252,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "GetAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "127.0.0.1" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" @@ -291,9 +282,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "IndexAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "127.0.0.1" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "IndexAction" "elasticsearch.request" "IndexRequest" @@ -307,9 +298,9 @@ class Elasticsearch2TransportClientTest extends AgentTestRunner { operationName "GetAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "127.0.0.1" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" diff --git a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/springdata/Elasticsearch2SpringTemplateTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/springdata/Elasticsearch2SpringTemplateTest.groovy index b08e836096..c245559c51 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/springdata/Elasticsearch2SpringTemplateTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-2.0/src/test/groovy/springdata/Elasticsearch2SpringTemplateTest.groovy @@ -18,7 +18,6 @@ package springdata import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.search.SearchResponse import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings @@ -41,27 +40,17 @@ import static io.opentelemetry.trace.Span.Kind.CLIENT class Elasticsearch2SpringTemplateTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds - @Shared - int httpPort - @Shared - int tcpPort @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared ElasticsearchTemplate template def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -71,10 +60,8 @@ class Elasticsearch2SpringTemplateTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("threadpool.listener.size", 1) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .build() - testNode = NodeBuilder.newInstance().local(true).clusterName("test-cluster").settings(settings).build() + testNode = NodeBuilder.newInstance().local(true).clusterName(clusterName).settings(settings).build() testNode.start() template = new ElasticsearchTemplate(testNode.client()) diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.0/src/test/groovy/Elasticsearch5NodeClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-5.0/src/test/groovy/Elasticsearch5NodeClientTest.groovy index c53b853cf5..3cf16bd6e3 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.0/src/test/groovy/Elasticsearch5NodeClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.0/src/test/groovy/Elasticsearch5NodeClientTest.groovy @@ -15,7 +15,6 @@ */ import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings @@ -33,26 +32,16 @@ import static org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING class Elasticsearch5NodeClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds - @Shared - int httpPort - @Shared - int tcpPort @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() def client = testNode.client() def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -62,11 +51,9 @@ class Elasticsearch5NodeClientTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .put("transport.type", "netty3") .put("http.type", "netty3") - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() testNode = new Node(new Environment(InternalSettingsPreparer.prepareSettings(settings)), [Netty3Plugin]) testNode.start() diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.0/src/test/groovy/Elasticsearch5TransportClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-5.0/src/test/groovy/Elasticsearch5TransportClientTest.groovy index 1e9175910d..63db8ebb8a 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.0/src/test/groovy/Elasticsearch5TransportClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.0/src/test/groovy/Elasticsearch5TransportClientTest.groovy @@ -16,18 +16,18 @@ import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest import org.elasticsearch.client.transport.TransportClient import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings -import org.elasticsearch.common.transport.InetSocketTransportAddress +import org.elasticsearch.common.transport.TransportAddress import org.elasticsearch.env.Environment import org.elasticsearch.index.IndexNotFoundException import org.elasticsearch.node.Node import org.elasticsearch.node.internal.InternalSettingsPreparer import org.elasticsearch.transport.Netty3Plugin import org.elasticsearch.transport.RemoteTransportException +import org.elasticsearch.transport.TransportService import org.elasticsearch.transport.client.PreBuiltTransportClient import spock.lang.Shared @@ -39,26 +39,18 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds @Shared - int httpPort - @Shared - int tcpPort + TransportAddress tcpPublishAddress @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared TransportClient client def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -66,23 +58,22 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .put("transport.type", "netty3") .put("http.type", "netty3") - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() testNode = new Node(new Environment(InternalSettingsPreparer.prepareSettings(settings)), [Netty3Plugin]) testNode.start() + tcpPublishAddress = testNode.injector().getInstance(TransportService).boundAddress().publishAddress() client = new PreBuiltTransportClient( Settings.builder() // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() ) - client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), tcpPort)) + client.addTransportAddress(tcpPublishAddress) runUnderTrace("setup") { // this may potentially create multiple requests and therefore multiple spans, so we wrap this call // into a top level trace to get exactly one trace in the result. @@ -114,9 +105,9 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { operationName "ClusterHealthAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" String - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" @@ -209,9 +200,9 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { operationName "CreateIndexAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" String - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "CreateIndexAction" "elasticsearch.request" "CreateIndexRequest" @@ -224,9 +215,9 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { operationName "GetAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" String - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" @@ -253,9 +244,9 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { operationName "IndexAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" String - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "IndexAction" "elasticsearch.request" "IndexRequest" @@ -273,9 +264,9 @@ class Elasticsearch5TransportClientTest extends AgentTestRunner { operationName "GetAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" String - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/Elasticsearch53NodeClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/Elasticsearch53NodeClientTest.groovy index 4d68341a44..84b35d927e 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/Elasticsearch53NodeClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/Elasticsearch53NodeClientTest.groovy @@ -15,7 +15,6 @@ */ import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings @@ -33,26 +32,16 @@ import static org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING class Elasticsearch53NodeClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds - @Shared - int httpPort - @Shared - int tcpPort @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() def client = testNode.client() def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -62,11 +51,9 @@ class Elasticsearch53NodeClientTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .put("transport.type", "netty3") .put("http.type", "netty3") - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() testNode = new Node(new Environment(InternalSettingsPreparer.prepareSettings(settings)), [Netty3Plugin]) testNode.start() diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/Elasticsearch53TransportClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/Elasticsearch53TransportClientTest.groovy index 0bb8645556..b1546f946f 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/Elasticsearch53TransportClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/Elasticsearch53TransportClientTest.groovy @@ -16,18 +16,18 @@ import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest import org.elasticsearch.client.transport.TransportClient import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings -import org.elasticsearch.common.transport.InetSocketTransportAddress +import org.elasticsearch.common.transport.TransportAddress import org.elasticsearch.env.Environment import org.elasticsearch.index.IndexNotFoundException import org.elasticsearch.node.InternalSettingsPreparer import org.elasticsearch.node.Node import org.elasticsearch.transport.Netty3Plugin import org.elasticsearch.transport.RemoteTransportException +import org.elasticsearch.transport.TransportService import org.elasticsearch.transport.client.PreBuiltTransportClient import spock.lang.Shared @@ -39,9 +39,8 @@ class Elasticsearch53TransportClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds @Shared - int httpPort - @Shared - int tcpPort + TransportAddress tcpPublishAddress + @Shared Node testNode @Shared @@ -49,16 +48,10 @@ class Elasticsearch53TransportClientTest extends AgentTestRunner { @Shared TransportClient client + @Shared + String clusterName = UUID.randomUUID().toString() def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -66,23 +59,22 @@ class Elasticsearch53TransportClientTest extends AgentTestRunner { def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .put("transport.type", "netty3") .put("http.type", "netty3") - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() testNode = new Node(new Environment(InternalSettingsPreparer.prepareSettings(settings)), [Netty3Plugin]) testNode.start() + tcpPublishAddress = testNode.injector().getInstance(TransportService).boundAddress().publishAddress() client = new PreBuiltTransportClient( Settings.builder() // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() ) - client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), tcpPort)) + client.addTransportAddress(tcpPublishAddress) runUnderTrace("setup") { // this may potentially create multiple requests and therefore multiple spans, so we wrap this call // into a top level trace to get exactly one trace in the result. @@ -114,9 +106,9 @@ class Elasticsearch53TransportClientTest extends AgentTestRunner { operationName "ClusterHealthAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" @@ -209,9 +201,9 @@ class Elasticsearch53TransportClientTest extends AgentTestRunner { operationName "CreateIndexAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "CreateIndexAction" "elasticsearch.request" "CreateIndexRequest" @@ -224,9 +216,9 @@ class Elasticsearch53TransportClientTest extends AgentTestRunner { operationName "GetAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" @@ -253,9 +245,9 @@ class Elasticsearch53TransportClientTest extends AgentTestRunner { operationName "IndexAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "IndexAction" "elasticsearch.request" "IndexRequest" @@ -274,9 +266,9 @@ class Elasticsearch53TransportClientTest extends AgentTestRunner { operationName "GetAction" spanKind CLIENT tags { - "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_NAME" tcpPublishAddress.host + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/springdata/Elasticsearch53SpringTemplateTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/springdata/Elasticsearch53SpringTemplateTest.groovy index f0cad53032..451a61b921 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/springdata/Elasticsearch53SpringTemplateTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.3/src/test/groovy/springdata/Elasticsearch53SpringTemplateTest.groovy @@ -18,7 +18,6 @@ package springdata import com.google.common.collect.ImmutableSet import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.search.SearchResponse import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings @@ -50,27 +49,17 @@ class Elasticsearch53SpringTemplateTest extends AgentTestRunner { // TODO: check if other ES tests need this protection and potentially pull this into global class public static final Set IGNORED_ACTIONS = ImmutableSet.of("NodesStatsAction", "IndicesStatsAction") - @Shared - int httpPort - @Shared - int tcpPort @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared ElasticsearchTemplate template def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -80,11 +69,9 @@ class Elasticsearch53SpringTemplateTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) .put("transport.type", "netty3") .put("http.type", "netty3") - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() testNode = new Node(new Environment(InternalSettingsPreparer.prepareSettings(settings)), [Netty3Plugin]) testNode.start() diff --git a/instrumentation/elasticsearch/elasticsearch-transport-6.0/src/test/groovy/Elasticsearch6NodeClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-6.0/src/test/groovy/Elasticsearch6NodeClientTest.groovy index ffcb222c1f..f7d29a0ed4 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-6.0/src/test/groovy/Elasticsearch6NodeClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-6.0/src/test/groovy/Elasticsearch6NodeClientTest.groovy @@ -15,7 +15,6 @@ */ import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest import org.elasticsearch.common.io.FileSystemUtils import org.elasticsearch.common.settings.Settings @@ -32,26 +31,16 @@ import static org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING class Elasticsearch6NodeClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds - @Shared - int httpPort - @Shared - int tcpPort @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() def client = testNode.client() def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() @@ -61,9 +50,7 @@ class Elasticsearch6NodeClientTest extends AgentTestRunner { .put("path.home", esWorkingDir.path) // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() testNode = new Node(InternalSettingsPreparer.prepareEnvironment(settings, null), [Netty4Plugin]) testNode.start() diff --git a/instrumentation/elasticsearch/elasticsearch-transport-6.0/src/test/groovy/Elasticsearch6TransportClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-6.0/src/test/groovy/Elasticsearch6TransportClientTest.groovy index 4845959ee0..70d80a9b6a 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-6.0/src/test/groovy/Elasticsearch6TransportClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-6.0/src/test/groovy/Elasticsearch6TransportClientTest.groovy @@ -16,7 +16,6 @@ import io.opentelemetry.auto.instrumentation.api.MoreTags import io.opentelemetry.auto.instrumentation.api.Tags import io.opentelemetry.auto.test.AgentTestRunner -import io.opentelemetry.auto.test.utils.PortUtils import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest import org.elasticsearch.client.transport.TransportClient import org.elasticsearch.common.io.FileSystemUtils @@ -27,6 +26,7 @@ import org.elasticsearch.node.InternalSettingsPreparer import org.elasticsearch.node.Node import org.elasticsearch.transport.Netty4Plugin import org.elasticsearch.transport.RemoteTransportException +import org.elasticsearch.transport.TransportService import org.elasticsearch.transport.client.PreBuiltTransportClient import spock.lang.Shared @@ -38,48 +38,38 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { public static final long TIMEOUT = 10000; // 10 seconds @Shared - int httpPort - @Shared - int tcpPort + TransportAddress tcpPublishAddress @Shared Node testNode @Shared File esWorkingDir + @Shared + String clusterName = UUID.randomUUID().toString() @Shared TransportClient client def setupSpec() { - withRetryOnBindException({ - setupSpecUnderRetry() - }) - } - - def setupSpecUnderRetry() { - httpPort = PortUtils.randomOpenPort() - tcpPort = PortUtils.randomOpenPort() - esWorkingDir = File.createTempDir("test-es-working-dir-", "") esWorkingDir.deleteOnExit() println "ES work dir: $esWorkingDir" def settings = Settings.builder() .put("path.home", esWorkingDir.path) - .put("http.port", httpPort) - .put("transport.tcp.port", tcpPort) - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() testNode = new Node(InternalSettingsPreparer.prepareEnvironment(settings, null), [Netty4Plugin]) testNode.start() + tcpPublishAddress = testNode.injector().getInstance(TransportService).boundAddress().publishAddress() client = new PreBuiltTransportClient( Settings.builder() // Since we use listeners to close spans this should make our span closing deterministic which is good for tests .put("thread_pool.listener.size", 1) - .put(CLUSTER_NAME_SETTING.getKey(), "test-cluster") + .put(CLUSTER_NAME_SETTING.getKey(), clusterName) .build() ) - client.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), tcpPort)) + client.addTransportAddress(tcpPublishAddress) runUnderTrace("setup") { // this may potentially create multiple requests and therefore multiple spans, so we wrap this call // into a top level trace to get exactly one trace in the result. @@ -112,8 +102,8 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { spanKind CLIENT tags { "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "ClusterHealthAction" "elasticsearch.request" "ClusterHealthRequest" @@ -207,8 +197,8 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { spanKind CLIENT tags { "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "CreateIndexAction" "elasticsearch.request" "CreateIndexRequest" @@ -222,8 +212,8 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { spanKind CLIENT tags { "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest" @@ -251,8 +241,8 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { spanKind CLIENT tags { "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "IndexAction" "elasticsearch.request" "IndexRequest" @@ -272,8 +262,8 @@ class Elasticsearch6TransportClientTest extends AgentTestRunner { spanKind CLIENT tags { "$MoreTags.NET_PEER_NAME" "localhost" - "$MoreTags.NET_PEER_IP" "127.0.0.1" - "$MoreTags.NET_PEER_PORT" tcpPort + "$MoreTags.NET_PEER_IP" tcpPublishAddress.address + "$MoreTags.NET_PEER_PORT" tcpPublishAddress.port "$Tags.DB_TYPE" "elasticsearch" "elasticsearch.action" "GetAction" "elasticsearch.request" "GetRequest"