first review for
MODIFY
dd-java-agent-ittests/pom.xml
dd-java-agent-ittests/pom.xml
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<scope>test</scope>
</dependency>
-
<!-- Cassandra BD -->
- <!--<dependency>-->
- <!--<groupId>com.datastax.cassandra</groupId>-->
- <!--<artifactId>cassandra-driver-core</artifactId>-->
- <!--<version>3.2.0</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.cassandraunit</groupId>-->
- <!--<artifactId>cassandra-unit</artifactId>-->
- <!--<version>3.1.3.2</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
+ <dependency>
+ <groupId>com.datastax.cassandra</groupId>
+ <artifactId>cassandra-driver-core</artifactId>
+ <version>3.2.0</version>
+ <exclusions>
+ <!--Provided by ES-->
+ <exclusion>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-handler</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.cassandraunit</groupId>
+ <artifactId>cassandra-unit</artifactId>
+ <version>3.1.3.2</version>
+ <scope>test</scope>
+ <exclusions>
+ <!--Provided by ES-->
+ <exclusion>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-handler</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Elasticsearch -->
+ <dependency>
+ <groupId>org.elasticsearch.client</groupId>
+ <artifactId>transport</artifactId>
+ <version>5.4.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>2.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>2.8.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<!-- <forkCount>1</forkCount> -->
<!-- <reuseForks>false</reuseForks> -->
<argLine>
- -javaagent:${M2_REPO}/com/datadoghq/dd-java-agent/${project.version}/dd-java-agent-${project.version}.jar -Dorg.jboss.byteman.verbose
+ -javaagent:${M2_REPO}/com/datadoghq/dd-java-agent/${project.version}/dd-java-agent-${project.version}.jar
+ -Dorg.jboss.byteman.verbose
</argLine>
<!-- <workingDirectory>target/FORK_DIRECTORY_${surefire.forkNumber}</workingDirectory> -->
</configuration>
</excludes>
</artifactSet>
<transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>otarules.btm</resource>
</transformer>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Agent-Class>io.opentracing.contrib.agent.AnnotationsTracingAgent</Agent-Class>
<Premain-Class>io.opentracing.contrib.agent.AnnotationsTracingAgent

MODIFY
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/instrument/ApacheHTTPClientTest.java
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/instrument/ApacheHTTPClientTest.java
package com.datadoghq.trace.instrument;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
+import io.opentracing.contrib.apache.http.client.TracingHttpClientBuilder;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.Test;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
public class ApacheHTTPClientTest extends AAgentIntegration {
@Test
public void test() throws Exception {
- HttpClient client = HttpClientBuilder.create().build();
+
+ HttpClientBuilder builder = HttpClientBuilder.create();
+ assertThat(builder).isInstanceOf(TracingHttpClientBuilder.class);
+
+ HttpClient client = builder.build();
HttpGet request = new HttpGet("http://apache.org");
// add request header

MODIFY
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/instrument/CassandraIntegrationTest.java
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/instrument/CassandraIntegrationTest.java
-//package com.datadoghq.trace.instrument;
-//
-//import com.datastax.driver.core.Cluster;
-//import com.datastax.driver.core.Session;
-//import org.apache.cassandra.exceptions.ConfigurationException;
-//import org.apache.thrift.transport.TTransportException;
-//import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
-//import org.junit.After;
-//import org.junit.Before;
-//import org.junit.Test;
-//
-//import java.io.IOException;
-//import java.util.concurrent.ExecutionException;
-//
-//import static org.assertj.core.api.Assertions.assertThat;
-//
-///**
-// * Created by gpolaert on 6/2/17.
-// */
-//public class CassandraIntegrationTest {
-//
-//
-// @Before
-// public void start() throws InterruptedException, TTransportException, ConfigurationException, IOException {
-// EmbeddedCassandraServerHelper.startEmbeddedCassandra(20000L);
-// }
-//
-// @After
-// public void stop() {
-// EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
-// }
-//
-//
-// @Test
-// public void testNewSessionSync() throws ClassNotFoundException {
-// Cluster cluster = EmbeddedCassandraServerHelper.getCluster();
-// Session session = cluster.newSession();
-// assertThat(session).isInstanceOf(Class.forName("io.opentracing.contrib.cassandra.TracingSession"));
-//
-//
-// }
-//
-// @Test
-// public void testNewSessionAsync() throws ClassNotFoundException, ExecutionException, InterruptedException {
-// Cluster cluster = EmbeddedCassandraServerHelper.getCluster();
-// Session session = cluster.connectAsync().get();
-// assertThat(session).isInstanceOf(Class.forName("io.opentracing.contrib.cassandra.TracingSession"));
-//
-//
-// }
-//}
+package com.datadoghq.trace.instrument;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.thrift.transport.TTransportException;
+import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Created by gpolaert on 6/2/17.
+ */
+public class CassandraIntegrationTest {
+
+
+ @Before
+ public void start() throws InterruptedException, TTransportException, ConfigurationException, IOException {
+ EmbeddedCassandraServerHelper.startEmbeddedCassandra(20000L);
+ }
+
+ @After
+ public void stop() {
+ EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
+ }
+
+
+ @Test
+ public void testNewSessionSync() throws ClassNotFoundException {
+ Cluster cluster = EmbeddedCassandraServerHelper.getCluster();
+ Session session = cluster.newSession();
+ assertThat(session).isInstanceOf(Class.forName("io.opentracing.contrib.cassandra.TracingSession"));
+
+
+ }
+
+ @Test
+ public void testNewSessionAsync() throws ClassNotFoundException, ExecutionException, InterruptedException {
+ Cluster cluster = EmbeddedCassandraServerHelper.getCluster();
+ Session session = cluster.connectAsync().get();
+ assertThat(session).isInstanceOf(Class.forName("io.opentracing.contrib.cassandra.TracingSession"));
+
+
+ }
+}

ADD
dd-java-agent-ittests/src/test/java/com/datadoghq/trace/instrument/ElasticsearchIntegrationTest.java
+package com.datadoghq.trace.instrument;
+
+import io.opentracing.contrib.elasticsearch.TracingPreBuiltTransportClient;
+import org.elasticsearch.client.transport.TransportClient;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.transport.client.PreBuiltTransportClient;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class ElasticsearchIntegrationTest {
+
+
+ @Test
+ public void test() {
+
+
+ TransportClient builder = new PreBuiltTransportClient(Settings.EMPTY);
+ assertThat(builder).isInstanceOf(TracingPreBuiltTransportClient.class);
+ }
+
+}

MODIFY
dd-java-agent-ittests/src/test/resources/dd-trace.yaml
dd-java-agent-ittests/src/test/resources/dd-trace.yaml
@@ -23,7 +23,7 @@ sampler:
# skipTagsPatterns: {"http.url": ".*/demo/add.*"}
# Enable custom annotation tracing over a selected set of packages
-enableCustomAnnotationTracingOver: ["io.opentracing.contrib.agent"]
+#enableCustomAnnotationTracingOver: ["io.opentracing.contrib.agent"]
# Disable some instrumentations
# disabledInstrumentations: ["apache http", "mongo", "jetty", "tomcat", ...]
\ No newline at end of file

ADD
dd-java-agent-ittests/src/test/resources/log4j2.properties
+
+appender.console.type = Console
+appender.console.name = console
+appender.console.layout.type = PatternLayout
+
+rootLogger.level = debug
+rootLogger.appenderRef.console.ref = console
\ No newline at end of file

MODIFY
dd-java-agent/pom.xml
dd-java-agent/pom.xml
<ot.contrib.aws.version>0.0.2</ot.contrib.aws.version>
<ot.contrib.httpclient.version>0.0.2</ot.contrib.httpclient.version>
<ot.contrib.cassandra.version>0.0.2</ot.contrib.cassandra.version>
+ <ot.contrib.elasticsearch.version>0.0.2</ot.contrib.elasticsearch.version>
<!-- Others versions -->
<java.version>1.7</java.version>
</properties>
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongo-java-driver</artifactId>
+ <version>3.4.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mongodb</groupId>
+ <artifactId>mongodb-driver-async</artifactId>
+ <version>3.4.2</version>
+ <scope>provided</scope>
+ </dependency>
<!-- Opentracing JDBC contribution -->
<dependency>
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.amazonaws</groupId>
+ <artifactId>aws-java-sdk</artifactId>
+ <version>1.11.119</version>
+ <scope>provided</scope>
+ </dependency>
<!-- Cassandra instrumentation -->
<dependency>
<scope>provided</scope>
</dependency>
+ <!-- Elasticsearch instrumentation -->
+ <dependency>
+ <groupId>io.opentracing.contrib</groupId>
+ <artifactId>opentracing-elasticsearch-client</artifactId>
+ <version>${ot.contrib.elasticsearch.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.elasticsearch.client</groupId>
+ <artifactId>transport</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.elasticsearch.client</groupId>
+ <artifactId>transport</artifactId>
+ <version>5.4.1</version>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Apache HTTP instrumentation -->
<dependency>
<groupId>io.opentracing.contrib</groupId>
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.3</version>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
<build>

ADD
dd-java-agent/src/main/java/io/opentracing/contrib/agent/helper/AWSClientHelper.java
+package io.opentracing.contrib.agent.helper;
+
+import com.amazonaws.client.builder.AwsClientBuilder;
+import com.amazonaws.handlers.RequestHandler2;
+import io.opentracing.contrib.aws.TracingRequestHandler;
+import org.jboss.byteman.rule.Rule;
+
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.List;
+
+
+public class AWSClientHelper extends DDTracingHelper<com.amazonaws.client.builder.AwsClientBuilder> {
+
+
+ private static final String HANDLERS_FIELD_NAME = "requestHandlers";
+
+ public AWSClientHelper(Rule rule) {
+ super(rule);
+ }
+
+
+ public AwsClientBuilder patch(AwsClientBuilder client) {
+ return super.patch(client);
+ }
+
+
+ @Override
+ protected AwsClientBuilder doPatch(AwsClientBuilder client) throws Exception {
+
+ RequestHandler2 handler = new TracingRequestHandler(tracer);
+
+ Field field = client.getClass().getDeclaredField(HANDLERS_FIELD_NAME);
+ field.setAccessible(true);
+ List<RequestHandler2> handlers = (List<RequestHandler2>) field.get(client);
+
+ if (handlers == null || handlers.isEmpty()) {
+ handlers = Arrays.asList(handler);
+ } else {
+ // Check if we already added the handler
+ if (!(handlers.get(0) instanceof TracingRequestHandler)) {
+ handlers.add(0, handler);
+ }
+ }
+
+ return client;
+ }
+
+}
\ No newline at end of file

ADD
dd-java-agent/src/main/java/io/opentracing/contrib/agent/helper/ApacheHTTPClientHelper.java
+package io.opentracing.contrib.agent.helper;
+
+import io.opentracing.contrib.apache.http.client.TracingHttpClientBuilder;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.jboss.byteman.rule.Rule;
+
+
+public class ApacheHTTPClientHelper extends DDTracingHelper<HttpClientBuilder> {
+
+
+
+ public ApacheHTTPClientHelper(Rule rule) {
+ super(rule);
+ }
+
+
+ public HttpClientBuilder patch(HttpClientBuilder builder) {
+ return super.patch(builder);
+ }
+
+
+ @Override
+ protected HttpClientBuilder doPatch(HttpClientBuilder builder) throws Exception {
+
+ return new TracingHttpClientBuilder();
+
+ }
+
+}
\ No newline at end of file

MODIFY
dd-java-agent/src/main/java/io/opentracing/contrib/agent/helper/CassandraHelper.java
dd-java-agent/src/main/java/io/opentracing/contrib/agent/helper/CassandraHelper.java
@@ -2,45 +2,33 @@ package io.opentracing.contrib.agent.helper;
import com.datastax.driver.core.Session;
import io.opentracing.Tracer;
-import io.opentracing.contrib.agent.OpenTracingHelper;
import org.jboss.byteman.rule.Rule;
import java.lang.reflect.Constructor;
-public class CassandraHelper extends OpenTracingHelper {
+public class CassandraHelper extends DDTracingHelper<Session> {
- private static final String LOG_PREFIX = "OTARULES - Cassandra contrib - ";
protected CassandraHelper(Rule rule) {
super(rule);
}
- /**
- * @param session The session to be patched
- */
- public Session patch(Session session) {
+ public Session patch(Session session) {
+ return super.patch(session);
+ }
- debug(LOG_PREFIX + "Try to patch the session");
+ @Override
+ protected Session doPatch(Session session) throws Exception {
- try {
- Tracer tracer = getTracer();
Class<?> clazz = Class.forName("io.opentracing.contrib.cassandra.TracingSession");
Constructor<?> constructor = clazz.getDeclaredConstructor(Session.class, Tracer.class);
constructor.setAccessible(true);
- Object newSession = constructor.newInstance(session, tracer);
- debug(LOG_PREFIX + "Session patched");
- return (Session) newSession;
-
- } catch (Exception e) {
- err(LOG_PREFIX + "Session not patched, " + e.getMessage());
- errTraceException(e);
- }
-
- return session;
+ Session newSession = (Session) constructor.newInstance(session, tracer);
+ return newSession;
}

ADD
dd-java-agent/src/main/java/io/opentracing/contrib/agent/helper/DDTracingHelper.java
+package io.opentracing.contrib.agent.helper;
+
+import io.opentracing.NoopTracerFactory;
+import io.opentracing.Tracer;
+import io.opentracing.contrib.agent.OpenTracingHelper;
+import org.jboss.byteman.rule.Rule;
+
+import java.lang.reflect.InvocationTargetException;
+
+
+public abstract class DDTracingHelper<E> extends OpenTracingHelper {
+
+
+ protected final Tracer tracer;
+ private final static String LOG_PREFIX = "[DD-JAVA-AGENT]";
+
+
+ public DDTracingHelper(Rule rule) {
+ super(rule);
+ Tracer activeTracer;
+ try {
+ activeTracer = getTracer();
+ } catch (Exception e) {
+ activeTracer = NoopTracerFactory.create();
+ error("Failed to retrieve the tracer, using a NoopTracer: " + e.getMessage());
+ errTraceException(e);
+ }
+ tracer = activeTracer;
+ }
+
+
+ public boolean debug(String message) {
+ return super.debug(String.format("%s - %s - %s", LOG_PREFIX, getClass().getCanonicalName(), message));
+ }
+
+ public boolean error(String message) {
+ return OpenTracingHelper.err(String.format("%s - %s - %s", LOG_PREFIX, getClass().getCanonicalName(), message));
+ }
+
+ public E patch(E args) {
+
+ debug("Try to patch " + args.getClass().getName());
+ E patched;
+ try {
+ patched = doPatch(args);
+ debug(args.getClass().getName() + " patched");
+ } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
+ error("Your " + args.getClass().getName() + "seems to be not compatible with the current integration, integration disabled, reason: " + e.getMessage());
+ errTraceException(e);
+ patched = args;
+ } catch (Exception e) {
+ error("Failed to patch" + args.getClass().getName() + ", reason: " + e.getMessage());
+ errTraceException(e);
+ patched = args;
+ }
+ return patched;
+
+ }
+
+ abstract protected E doPatch(E input) throws Exception;
+
+}

ADD
dd-java-agent/src/main/java/io/opentracing/contrib/agent/helper/ElasticsearchHelper.java
+package io.opentracing.contrib.agent.helper;
+
+import org.elasticsearch.transport.client.PreBuiltTransportClient;
+import org.jboss.byteman.rule.Rule;
+
+
+public class ElasticsearchHelper extends DDTracingHelper<PreBuiltTransportClient> {
+
+
+ public ElasticsearchHelper(Rule rule) {
+ super(rule);
+ }
+
+
+ public PreBuiltTransportClient patch(PreBuiltTransportClient client) {
+ return super.patch(client);
+ }
+
+
+ @Override
+ protected PreBuiltTransportClient doPatch(PreBuiltTransportClient client) throws Exception {
+
+ return client;
+ }
+
+}
\ No newline at end of file

ADD
dd-java-agent/src/main/java/io/opentracing/contrib/agent/helper/MongoHelper.java
+package io.opentracing.contrib.agent.helper;
+
+import com.mongodb.MongoClientOptions;
+import io.opentracing.contrib.mongo.TracingCommandListener;
+import org.jboss.byteman.rule.Rule;
+
+
+public class MongoHelper extends DDTracingHelper<MongoClientOptions.Builder> {
+
+
+ public MongoHelper(Rule rule) {
+ super(rule);
+ }
+
+ public MongoClientOptions.Builder patch(MongoClientOptions.Builder builder) {
+ return super.patch(builder);
+ }
+
+ @Override
+ protected MongoClientOptions.Builder doPatch(MongoClientOptions.Builder builder) throws Exception {
+
+
+ TracingCommandListener listener = new TracingCommandListener(tracer);
+ builder.addCommandListener(listener);
+
+ return builder;
+
+ }
+}

MODIFY
dd-java-agent/src/main/resources/otarules.btm
dd-java-agent/src/main/resources/otarules.btm
- # --------------------------------------------------------
-# Instrument mongo client
-RULE Mongo Client instrumentation
+# Instrument Mongo client
+# ========================
+RULE mongo
CLASS com.mongodb.MongoClientOptions$Builder
-METHOD build()
-HELPER io.opentracing.contrib.agent.OpenTracingHelper
-BIND
- listener:io.opentracing.contrib.mongo.TracingCommandListener =
- new io.opentracing.contrib.mongo.TracingCommandListener(getTracer());
+METHOD build
+HELPER io.opentracing.contrib.agent.helper.MongoHelper
AT ENTRY
IF TRUE
DO
- $this.addCommandListener(listener);
+ patch($this);
ENDRULE
-# --------------------------------------------------------
-# Instrument AWS client
-RULE AWS SDK Client instrumentation 1
-CLASS ^com.amazonaws.client.builder.AwsClientBuilder
-METHOD build()
-HELPER io.opentracing.contrib.agent.OpenTracingHelper
-BIND
- requestTracerHandler:io.opentracing.contrib.aws.TracingRequestHandler = new io.opentracing.contrib.aws.TracingRequestHandler(getTracer());
- requests:java.util.List = new java.util.ArrayList();
-AT ENTRY
-IF $this.requestHandlers == null
-DO
- requests.add(requestTracerHandler);
- $this.requestHandlers = requests;
-ENDRULE
-RULE AWS SDK Client instrumentation 2
+# Instrument AWS SDK client
+# ==========================
+RULE awsclient
CLASS ^com.amazonaws.client.builder.AwsClientBuilder
METHOD build()
-HELPER io.opentracing.contrib.agent.OpenTracingHelper
-BIND
- requestTracerHandler:io.opentracing.contrib.aws.TracingRequestHandler = new io.opentracing.contrib.aws.TracingRequestHandler(getTracer());
+HELPER io.opentracing.contrib.agent.helper.AWSClientHelper
AT ENTRY
-IF $this.requestHandlers != null AND $this.requestHandlers.get(0).getClass().getCanonicalName() != "io.opentracing.contrib.aws.TracingRequestHandler"
+IF TRUE
DO
- $this.requestHandlers.add(0, requestTracerHandler);
+ patch($this);
ENDRULE
-# --------------------------------------------------------
# Instrument Apache HTTP Client
+# =============================
RULE Apache HTTP Client instrumentation
CLASS org.apache.http.impl.client.HttpClientBuilder
-METHOD decorateProtocolExec(org.apache.http.impl.execchain.ClientExecChain)
-HELPER io.opentracing.contrib.agent.OpenTracingHelper
-BIND
- redirectStrategy: org.apache.http.client.RedirectStrategy = $this.redirectStrategy==null?org.apache.http.impl.client.DefaultRedirectStrategy.INSTANCE:$this.redirectStrategy;
- decorators: java.util.List = java.util.Collections.singletonList(new io.opentracing.contrib.apache.http.client.ApacheClientSpanDecorator$StandardTags());
- tracingClientExec:io.opentracing.contrib.apache.http.client.TracingClientExec
- = new io.opentracing.contrib.apache.http.client.TracingClientExec($1,redirectStrategy,$this.redirectHandlingDisabled,getTracer(),decorators);
+METHOD create()
+HELPER io.opentracing.contrib.agent.helper.ApacheHTTPClientHelper
+AT EXIT
+IF TRUE
+DO
+ $! = patch($!);
+ENDRULE
+
+# Instrument Elasticsearch Transport Client
+# ==========================================
+RULE elasticsearch
+CLASS ^org.elasticsearch.transport.client.PreBuiltTransportClient
+METHOD <init>
+#METHOD <init>(Settings, Collections, HostFailureListener)
+HELPER io.opentracing.contrib.agent.helper.ApacheHTTPClientHelper
AT ENTRY
IF TRUE
DO
- return tracingClientExec;
+ patch(null);
ENDRULE
+#PreBuiltTransportClient(Settings settings, Collection<Class<? extends Plugin>> plugins, HostFailureListener hostFailureListener)
+
-# --------------------------------------------------------
-# Cassandra
-RULE Cassandra
+# Instrument Cassandra client
+# ===========================
+RULE cassandra
CLASS com.datastax.driver.core.Cluster$Manager
METHOD newSession()
HELPER io.opentracing.contrib.agent.helper.CassandraHelper
-#BIND
AT EXIT
IF TRUE
DO

first review for @renaud