Skip to content

Commit 4605b8b

Browse files
author
Guillaume Polaert
authored
Merge pull request #17 from DataDog/dev
Sync dev and master
2 parents 6a0e8d9 + 947b900 commit 4605b8b

File tree

31 files changed

+1020
-388
lines changed

31 files changed

+1020
-388
lines changed

dd-java-agent-ittests/pom.xml

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.datadoghq</groupId>
66
<artifactId>dd-trace-java</artifactId>
7-
<version>0.0.8-SNAPSHOT</version>
7+
<version>0.1.2-SNAPSHOT</version>
88
</parent>
99

1010
<artifactId>dd-java-agent-ittests</artifactId>
@@ -15,7 +15,7 @@
1515

1616

1717
<properties>
18-
<dd-trace.version>0.0.8-SNAPSHOT</dd-trace.version>
18+
<dd-trace.version>0.1.2-SNAPSHOT</dd-trace.version>
1919
</properties>
2020

2121
<dependencies>
@@ -120,21 +120,54 @@
120120
<scope>test</scope>
121121
</dependency>
122122

123-
124123
<!-- Cassandra BD -->
125-
<!--<dependency>-->
126-
<!--<groupId>com.datastax.cassandra</groupId>-->
127-
<!--<artifactId>cassandra-driver-core</artifactId>-->
128-
<!--<version>3.2.0</version>-->
129-
<!--<scope>test</scope>-->
130-
<!--</dependency>-->
131-
<!--<dependency>-->
132-
<!--<groupId>org.cassandraunit</groupId>-->
133-
<!--<artifactId>cassandra-unit</artifactId>-->
134-
<!--<version>3.1.3.2</version>-->
135-
<!--<scope>test</scope>-->
136-
<!--</dependency>-->
124+
<dependency>
125+
<groupId>com.datastax.cassandra</groupId>
126+
<artifactId>cassandra-driver-core</artifactId>
127+
<version>3.2.0</version>
128+
<exclusions>
129+
<!--Provided by ES-->
130+
<exclusion>
131+
<groupId>io.netty</groupId>
132+
<artifactId>netty-handler</artifactId>
133+
</exclusion>
134+
</exclusions>
135+
<scope>test</scope>
137136

137+
</dependency>
138+
<dependency>
139+
<groupId>org.cassandraunit</groupId>
140+
<artifactId>cassandra-unit</artifactId>
141+
<version>3.1.3.2</version>
142+
<scope>test</scope>
143+
<exclusions>
144+
<!--Provided by ES-->
145+
<exclusion>
146+
<groupId>io.netty</groupId>
147+
<artifactId>netty-handler</artifactId>
148+
</exclusion>
149+
</exclusions>
150+
</dependency>
151+
152+
<!-- Elasticsearch -->
153+
<dependency>
154+
<groupId>org.elasticsearch.client</groupId>
155+
<artifactId>transport</artifactId>
156+
<version>5.4.1</version>
157+
<scope>test</scope>
158+
</dependency>
159+
<dependency>
160+
<groupId>org.apache.logging.log4j</groupId>
161+
<artifactId>log4j-api</artifactId>
162+
<version>2.8.2</version>
163+
<scope>test</scope>
164+
</dependency>
165+
<dependency>
166+
<groupId>org.apache.logging.log4j</groupId>
167+
<artifactId>log4j-core</artifactId>
168+
<version>2.8.2</version>
169+
<scope>test</scope>
170+
</dependency>
138171

139172
</dependencies>
140173
<build>
@@ -157,18 +190,19 @@
157190
<artifactId>maven-surefire-plugin</artifactId>
158191
<version>2.19</version>
159192
<configuration>
160-
<!--<includes>-->
193+
<includes>
161194
<!--<include>*Test.java</include>-->
162-
<!--</includes>-->
195+
</includes>
163196
<excludes>
164197
<exclude>*Test.java</exclude>
165198
</excludes>
166-
<!-- <forkCount>1</forkCount> -->
167-
<!-- <reuseForks>false</reuseForks> -->
199+
<!--<forkCount>3</forkCount>-->
200+
<!--<reuseForks>false</reuseForks>-->
168201
<argLine>
169-
-javaagent:${M2_REPO}/com/datadoghq/dd-java-agent/${project.version}/dd-java-agent-${project.version}.jar -Dorg.jboss.byteman.verbose
202+
-javaagent:${M2_REPO}/com/datadoghq/dd-java-agent/${project.version}/dd-java-agent-${project.version}.jar
203+
-Dorg.jboss.byteman.verbose=true
170204
</argLine>
171-
<!-- <workingDirectory>target/FORK_DIRECTORY_${surefire.forkNumber}</workingDirectory> -->
205+
<!--<workingDirectory>target/FORK_DIRECTORY_${surefire.forkNumber}</workingDirectory>-->
172206
</configuration>
173207
</plugin>
174208
<plugin>
Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,44 @@
11
package com.datadoghq.trace.instrument;
22

3-
import static org.assertj.core.api.Assertions.assertThat;
4-
5-
import java.io.BufferedReader;
6-
import java.io.InputStreamReader;
7-
3+
import io.opentracing.contrib.apache.http.client.TracingHttpClientBuilder;
84
import org.apache.http.HttpResponse;
95
import org.apache.http.client.HttpClient;
106
import org.apache.http.client.methods.HttpGet;
117
import org.apache.http.impl.client.HttpClientBuilder;
128
import org.junit.Test;
139

14-
public class ApacheHTTPClientTest extends AAgentIntegration{
15-
10+
import java.io.BufferedReader;
11+
import java.io.InputStreamReader;
12+
13+
import static org.assertj.core.api.Assertions.assertThat;
14+
15+
public class ApacheHTTPClientTest extends AAgentIntegration {
16+
1617
@Test
17-
public void test() throws Exception{
18-
HttpClient client = HttpClientBuilder.create().build();
19-
HttpGet request = new HttpGet("http://apache.org");
20-
21-
// add request header
22-
HttpResponse response = client.execute(request);
23-
24-
System.out.println("Response Code : "
25-
+ response.getStatusLine().getStatusCode());
26-
27-
BufferedReader rd = new BufferedReader(
28-
new InputStreamReader(response.getEntity().getContent()));
29-
30-
StringBuffer result = new StringBuffer();
31-
String line = "";
32-
while ((line = rd.readLine()) != null) {
33-
result.append(line);
34-
}
35-
36-
assertThat(writer.firstTrace().size()).isEqualTo(2);
18+
public void test() throws Exception {
19+
20+
HttpClientBuilder builder = HttpClientBuilder.create();
21+
assertThat(builder).isInstanceOf(TracingHttpClientBuilder.class);
22+
23+
// HttpClient client = builder.build();
24+
// HttpGet request = new HttpGet("http://apache.org");
25+
//
26+
// // add request header
27+
// HttpResponse response = client.execute(request);
28+
//
29+
// System.out.println("Response Code : "
30+
// + response.getStatusLine().getStatusCode());
31+
//
32+
// BufferedReader rd = new BufferedReader(
33+
// new InputStreamReader(response.getEntity().getContent()));
34+
//
35+
// StringBuffer result = new StringBuffer();
36+
// String line = "";
37+
// while ((line = rd.readLine()) != null) {
38+
// result.append(line);
39+
// }
40+
41+
// assertThat(writer.firstTrace().size()).isEqualTo(2);
3742
}
3843

3944
}
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
//package com.datadoghq.trace.instrument;
2-
//
3-
//import com.datastax.driver.core.Cluster;
4-
//import com.datastax.driver.core.Session;
5-
//import org.apache.cassandra.exceptions.ConfigurationException;
6-
//import org.apache.thrift.transport.TTransportException;
7-
//import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
8-
//import org.junit.After;
9-
//import org.junit.Before;
10-
//import org.junit.Test;
11-
//
12-
//import java.io.IOException;
13-
//import java.util.concurrent.ExecutionException;
14-
//
15-
//import static org.assertj.core.api.Assertions.assertThat;
16-
//
17-
///**
18-
// * Created by gpolaert on 6/2/17.
19-
// */
20-
//public class CassandraIntegrationTest {
21-
//
22-
//
23-
// @Before
24-
// public void start() throws InterruptedException, TTransportException, ConfigurationException, IOException {
25-
// EmbeddedCassandraServerHelper.startEmbeddedCassandra(20000L);
26-
// }
27-
//
28-
// @After
29-
// public void stop() {
30-
// EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
31-
// }
32-
//
33-
//
34-
// @Test
35-
// public void testNewSessionSync() throws ClassNotFoundException {
36-
// Cluster cluster = EmbeddedCassandraServerHelper.getCluster();
37-
// Session session = cluster.newSession();
38-
// assertThat(session).isInstanceOf(Class.forName("io.opentracing.contrib.cassandra.TracingSession"));
39-
//
40-
//
41-
// }
42-
//
43-
// @Test
44-
// public void testNewSessionAsync() throws ClassNotFoundException, ExecutionException, InterruptedException {
45-
// Cluster cluster = EmbeddedCassandraServerHelper.getCluster();
46-
// Session session = cluster.connectAsync().get();
47-
// assertThat(session).isInstanceOf(Class.forName("io.opentracing.contrib.cassandra.TracingSession"));
48-
//
49-
//
50-
// }
51-
//}
1+
package com.datadoghq.trace.instrument;
2+
3+
import com.datastax.driver.core.Cluster;
4+
import com.datastax.driver.core.Session;
5+
import org.apache.cassandra.exceptions.ConfigurationException;
6+
import org.apache.thrift.transport.TTransportException;
7+
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
8+
import org.junit.After;
9+
import org.junit.Before;
10+
import org.junit.Test;
11+
12+
import java.io.IOException;
13+
import java.util.concurrent.ExecutionException;
14+
15+
import static org.assertj.core.api.Assertions.assertThat;
16+
17+
/**
18+
* Created by gpolaert on 6/2/17.
19+
*/
20+
public class CassandraIntegrationTest {
21+
22+
23+
@Before
24+
public void start() throws InterruptedException, TTransportException, ConfigurationException, IOException {
25+
EmbeddedCassandraServerHelper.startEmbeddedCassandra(20000L);
26+
}
27+
28+
@After
29+
public void stop() {
30+
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
31+
}
32+
33+
34+
@Test
35+
public void testNewSessionSync() throws ClassNotFoundException {
36+
Cluster cluster = EmbeddedCassandraServerHelper.getCluster();
37+
Session session = cluster.newSession();
38+
assertThat(session).isInstanceOf(Class.forName("io.opentracing.contrib.cassandra.TracingSession"));
39+
40+
41+
}
42+
43+
@Test
44+
public void testNewSessionAsync() throws ClassNotFoundException, ExecutionException, InterruptedException {
45+
Cluster cluster = EmbeddedCassandraServerHelper.getCluster();
46+
Session session = cluster.connectAsync().get();
47+
assertThat(session).isInstanceOf(Class.forName("io.opentracing.contrib.cassandra.TracingSession"));
48+
49+
50+
}
51+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
//package com.datadoghq.trace.instrument;
2+
//
3+
//import com.datadoghq.trace.DDTracer;
4+
//import com.datadoghq.trace.writer.ListWriter;
5+
//import org.elasticsearch.action.index.IndexResponse;
6+
//import org.elasticsearch.client.transport.TransportClient;
7+
//import org.elasticsearch.common.settings.Settings;
8+
//import org.elasticsearch.common.transport.InetSocketTransportAddress;
9+
//import org.elasticsearch.node.InternalSettingsPreparer;
10+
//import org.elasticsearch.node.Node;
11+
//import org.elasticsearch.node.NodeValidationException;
12+
//import org.elasticsearch.plugins.Plugin;
13+
//import org.elasticsearch.transport.Netty4Plugin;
14+
//import org.elasticsearch.transport.client.PreBuiltTransportClient;
15+
//import org.junit.AfterClass;
16+
//import org.junit.BeforeClass;
17+
//import org.junit.Test;
18+
//
19+
//import java.io.IOException;
20+
//import java.net.Inet4Address;
21+
//import java.util.Collection;
22+
//import java.util.Collections;
23+
//import java.util.Date;
24+
//
25+
//import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
26+
//
27+
//
28+
//public class ElasticsearchIntegrationTest {
29+
//
30+
//
31+
// private static ListWriter writer = new ListWriter();
32+
// private static DDTracer tracer = new DDTracer(writer);
33+
// private static final int HTTP_PORT = 9205;
34+
// private static final String HTTP_TRANSPORT_PORT = "9300";
35+
// private static final String ES_WORKING_DIR = "target/es";
36+
// private static String clusterName = "elasticsearch";
37+
// private static Node node;
38+
//
39+
//
40+
// @AfterClass
41+
// public static void stopElasticsearch() throws Exception {
42+
// node.close();
43+
// }
44+
//
45+
// @BeforeClass
46+
// public static void warmup() throws NodeValidationException {
47+
//
48+
//
49+
// //GlobalTracer.register(tracer);
50+
//
51+
//
52+
// Settings settings = Settings.builder()
53+
// .put("path.home", ES_WORKING_DIR)
54+
// .put("path.data", ES_WORKING_DIR + "/data")
55+
// .put("path.logs", ES_WORKING_DIR + "/logs")
56+
// .put("transport.type", "netty4")
57+
// .put("http.type", "netty4")
58+
// .put("cluster.name", clusterName)
59+
// .put("http.port", HTTP_PORT)
60+
// .put("transport.tcp.port", HTTP_TRANSPORT_PORT)
61+
// .put("network.host", "0.0.0.0")
62+
// .build();
63+
// Collection plugins = Collections.singletonList(Netty4Plugin.class);
64+
// node = new PluginConfigurableNode(settings, plugins);
65+
// node.start();
66+
// }
67+
//
68+
//
69+
// @Test
70+
// public void testTransportClient() throws IOException {
71+
//
72+
//
73+
// Settings settings = Settings.builder()
74+
// .put("cluster.name", clusterName).build();
75+
//
76+
// TransportClient client = new PreBuiltTransportClient(settings)
77+
// .addTransportAddress(new InetSocketTransportAddress(Inet4Address.getByName("localhost"), Integer.parseInt(HTTP_TRANSPORT_PORT)));
78+
//
79+
// IndexResponse response = client.prepareIndex("twitter", "tweet", "1")
80+
// .setSource(jsonBuilder()
81+
// .startObject()
82+
// .field("user", "kimchy")
83+
// .field("postDate", new Date())
84+
// .field("message", "trying out Elasticsearch")
85+
// .endObject()
86+
// )
87+
// .get();
88+
//
89+
// //fixme works in debug, not in prod
90+
//// assertThat(writer.getList().size()).isEqualTo(1);
91+
//
92+
//
93+
// }
94+
//
95+
//
96+
// private static class PluginConfigurableNode extends Node {
97+
//
98+
// public PluginConfigurableNode(Settings settings,
99+
// Collection<Class<? extends Plugin>> classpathPlugins) {
100+
// super(InternalSettingsPreparer.prepareEnvironment(settings, null), classpathPlugins);
101+
// }
102+
// }
103+
//}

0 commit comments

Comments
 (0)