[elasticsearch] remove auto instrumentation; will be added later
MODIFY
dd-java-agent-ittests/dd-java-agent-ittests.gradle
dd-java-agent-ittests/dd-java-agent-ittests.gradle
@@ -21,13 +21,10 @@ dependencies {
}
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
testCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
- testCompile(group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.2.0') {
- exclude(module: 'netty-handler')
- }
+ testCompile(group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.2.0')
testCompile(group: 'org.cassandraunit', name: 'cassandra-unit', version: '3.1.3.2') {
exclude(module: 'netty-handler')
}
- testCompile group: 'org.elasticsearch.client', name: 'transport', version: '5.4.1'
testCompile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.8.2'
testCompile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.8.2'
testCompile group: 'javax.jms', name: 'javax.jms-api', version: '2.0.1'

DELETE
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/agent/integration/ElasticsearchIntegrationTest.java
-package com.datadoghq.trace.agent.integration;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-
-import com.datadoghq.trace.DDTracer;
-import com.datadoghq.trace.writer.ListWriter;
-import io.opentracing.util.GlobalTracer;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.net.Inet4Address;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import org.elasticsearch.action.index.IndexResponse;
-import org.elasticsearch.client.transport.TransportClient;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.transport.InetSocketTransportAddress;
-import org.elasticsearch.node.InternalSettingsPreparer;
-import org.elasticsearch.node.Node;
-import org.elasticsearch.node.NodeValidationException;
-import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.transport.Netty4Plugin;
-import org.elasticsearch.transport.client.PreBuiltTransportClient;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-@Ignore
-public class ElasticsearchIntegrationTest {
-
- private static final int HTTP_PORT = 9205;
- private static final String HTTP_TRANSPORT_PORT = "9300";
- private static final String ES_WORKING_DIR = "build/es";
- private static String clusterName = "elasticsearch";
- private static Node node;
- private final ListWriter writer = new ListWriter();
- private final DDTracer tracer = new DDTracer(writer);
-
- @AfterClass
- public static void stopElasticsearch() throws Exception {
- node.close();
- }
-
- @BeforeClass
- public static void warmup() throws NodeValidationException {
-
- //GlobalTracer.register(tracer);
- System.setProperty("es.set.netty.runtime.available.processors", "false");
- Settings settings =
- Settings.builder()
- .put("path.home", ES_WORKING_DIR)
- .put("path.data", ES_WORKING_DIR + "/data")
- .put("path.logs", ES_WORKING_DIR + "/logs")
- .put("transport.type", "netty4")
- .put("http.type", "netty4")
- .put("cluster.name", clusterName)
- .put("http.port", HTTP_PORT)
- .put("transport.tcp.port", HTTP_TRANSPORT_PORT)
- .put("network.host", "0.0.0.0")
- .build();
- Collection plugins = Collections.singletonList(Netty4Plugin.class);
- node = new PluginConfigurableNode(settings, plugins);
- node.start();
- }
-
- @Before
- public void beforeTest() throws Exception {
- try {
- GlobalTracer.register(tracer);
- } catch (final Exception e) {
- // Force it anyway using reflexion
- final Field field = GlobalTracer.class.getDeclaredField("tracer");
- field.setAccessible(true);
- field.set(null, tracer);
- }
- writer.start();
- }
-
- @Test
- public void testTransportClient() throws IOException {
-
- Settings settings = Settings.builder().put("cluster.name", clusterName).build();
-
- TransportClient client =
- new PreBuiltTransportClient(settings)
- .addTransportAddress(
- new InetSocketTransportAddress(
- Inet4Address.getByName("localhost"), Integer.parseInt(HTTP_TRANSPORT_PORT)));
-
- IndexResponse response =
- client
- .prepareIndex("twitter", "tweet", "1")
- .setSource(
- jsonBuilder()
- .startObject()
- .field("user", "kimchy")
- .field("postDate", new Date())
- .field("message", "trying out Elasticsearch")
- .endObject())
- .setTimeout("5s")
- .get();
-
- assertThat(writer.getList().size()).isEqualTo(1);
- }
-
- private static class PluginConfigurableNode extends Node {
-
- public PluginConfigurableNode(
- Settings settings, Collection<Class<? extends Plugin>> classpathPlugins) {
- super(InternalSettingsPreparer.prepareEnvironment(settings, null), classpathPlugins);
- }
- }
-}

MODIFY
dd-java-agent/dd-java-agent.gradle
dd-java-agent/dd-java-agent.gradle
@@ -48,9 +48,6 @@ dependencies {
compile(group: 'io.opentracing.contrib', name: 'opentracing-cassandra-driver', version: '0.0.2') {
exclude(group: 'com.datastax.cassandra', module: 'cassandra-driver-core')
}
- compile(group: 'io.opentracing.contrib', name: 'opentracing-elasticsearch-client', version: '0.0.2') {
- exclude(group: 'org.elasticsearch.client', module: 'transport')
- }
compile(group: 'io.opentracing.contrib', name: 'opentracing-apache-httpclient', version: '0.0.2') {
exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
}
@@ -69,7 +66,6 @@ dependencies {
compileOnly group: 'javax.jms', name: 'javax.jms-api', version: '2.0.1'
compileOnly group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.119'
compileOnly group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.2.0'
- compileOnly group: 'org.elasticsearch.client', name: 'transport', version: '5.4.1'
compileOnly group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
}

DELETE
dd-java-agent/src/main/java/com/datadoghq/trace/agent/integration/ElasticsearchHelper.java
-package com.datadoghq.trace.agent.integration;
-
-import io.opentracing.ActiveSpan;
-import io.opentracing.Span;
-import io.opentracing.Tracer;
-import io.opentracing.contrib.elasticsearch.TracingResponseListener;
-import io.opentracing.tag.Tags;
-import java.lang.reflect.Method;
-import org.elasticsearch.action.ActionListener;
-import org.jboss.byteman.rule.Rule;
-
-/**
- * Instrument all Elasticsearch queries. We have not found a way to inject the opentracing
- * contribution, so this integration is the integration. FIXME find a better to way to inject the OT
- * contrib
- */
-public class ElasticsearchHelper extends DDAgentTracingHelper<ActionListener> {
-
- public ElasticsearchHelper(Rule rule) {
- super(rule);
- }
-
- private Object request;
-
- /**
- * This method is used to register/save some object that will be used for the integration.
- * Currently, we need to keep a reference of the request called
- *
- * @param request The request used for the query
- */
- public void registerArgs(Object request) {
- this.request = request;
- }
-
- @Override
- public ActionListener patch(ActionListener listener) {
- return super.patch(listener);
- }
-
- /**
- * Strategy: When a query is executed, if start the integration and a new Span. We override the
- * default FutureAction by using the one provided in the opentracing contribution.
- *
- * @param listener default listener
- * @return The tracing listener, the default listener is wrapped in this one.
- * @throws Exception
- */
- protected ActionListener doPatch(ActionListener listener) throws Exception {
-
- if (listener instanceof TracingResponseListener) {
- return listener;
- }
-
- Tracer.SpanBuilder spanBuilder =
- tracer
- .buildSpan(request.getClass().getSimpleName())
- .ignoreActiveSpan()
- .withTag(Tags.SPAN_KIND.getKey(), "client");
- ActiveSpan parentSpan = tracer.activeSpan();
- if (parentSpan != null) {
- spanBuilder.asChildOf(parentSpan.context());
- }
-
- Span span = spanBuilder.startManual();
-
- Class<?> clazz = Class.forName("io.opentracing.contrib.elasticsearch.SpanDecorator");
- Method method = clazz.getDeclaredMethod("onRequest", Span.class);
- method.setAccessible(true);
- method.invoke(null, span);
-
- ActionListener newListener = new TracingResponseListener(listener, span);
- return newListener;
- }
-}

MODIFY
dd-java-agent/src/main/resources/dd-trace-supported-framework.yaml
dd-java-agent/src/main/resources/dd-trace-supported-framework.yaml
@@ -19,11 +19,6 @@ opentracing-aws-sdk:
artifact: aws-java-sdk
supported_version: 1\.11\..*
-opentracing-elasticsearch-client:
- - check:
- artifact: transport
- supported_version: 5\.4\..*
-
opentracing-cassandra-driver:
- check:
artifact: cassandra-driver-core
@@ -58,13 +53,3 @@ opentracing-mongo-driver:
- check:
artifact: mongodb-driver-async
supported_version: 3\..*
-
-# TODO, remove me, Issue NPE with the OT contrib v0.0.2, so disabling at this time
-#org.elasticsearch.client:
-# - check:
-# artifact: transport
-# supported_version: none
-## supported_version: 5\.4\..*
-
-
-

MODIFY
dd-java-agent/src/main/resources/otarules.btm
dd-java-agent/src/main/resources/otarules.btm
@@ -58,20 +58,6 @@ DO
ENDRULE
-## Instrument Elasticsearch Transport Client
-## ==========================================
-#RULE opentracing-elasticsearch-client
-#INTERFACE org.elasticsearch.client.ElasticsearchClient
-#METHOD execute(org.elasticsearch.action.Action,org.elasticsearch.action.ActionRequest,org.elasticsearch.action.ActionListener)
-#HELPER com.datadoghq.trace.agent.integration.ElasticsearchHelper
-#AT ENTRY
-#IF $# == 3 AND NOT $3.getClass().getCanonicalName().equals("io.opentracing.contrib.elasticsearch.TracingResponseListener")
-#DO
-# registerArgs($1);
-# $3 = patch($3);
-#ENDRULE
-
-
# Instrument Cassandra client
# ===========================
RULE opentracing-cassandra-driver

[elasticsearch] remove auto instrumentation; will be added later