diff --git a/skywalking-sniffer/skywalking-agent/pom.xml b/skywalking-sniffer/skywalking-agent/pom.xml
index 63f5e27e6..c96971753 100644
--- a/skywalking-sniffer/skywalking-agent/pom.xml
+++ b/skywalking-sniffer/skywalking-agent/pom.xml
@@ -19,7 +19,7 @@
com.a.eye.skywalking.api.dependencies
com.a.eye.skywalking.agent.SkyWalkingAgent
net.bytebuddy
- ${shade.package}.${shade.net.bytebuddy.source}}
+ ${shade.package}.${shade.net.bytebuddy.source}
com.lmax.disruptor
${shade.package}.${shade.com.lmax.disruptor.source}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/client/Agent2RoutingClient.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/client/Agent2RoutingClient.java
index 53704dad2..a96af9931 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/client/Agent2RoutingClient.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/client/Agent2RoutingClient.java
@@ -25,13 +25,13 @@ import java.util.concurrent.locks.LockSupport;
public class Agent2RoutingClient extends Thread {
private static ILog logger = LogManager.getLogger(Agent2RoutingClient.class);
- private List addrList;
- private Client client;
+ private List addrList;
+ private Client client;
private SpanStorageClient spanStorageClient;
- private NetworkListener listener;
- private SendRequestSpanEventHandler requestSpanDataSupplier = null;
- private SendAckSpanEventHandler ackSpanDataSupplier = null;
- private volatile boolean connected = false;
+ private NetworkListener listener;
+ private SendRequestSpanEventHandler requestSpanDataSupplier = null;
+ private SendAckSpanEventHandler ackSpanDataSupplier = null;
+ private volatile boolean connected = false;
public static Agent2RoutingClient INSTANCE = new Agent2RoutingClient();
@@ -80,7 +80,7 @@ public class Agent2RoutingClient extends Thread {
public void run() {
while (true) {
try {
- while (connected && !client.isShutdown()) {
+ while (requestSpanDataSupplier != null && ackSpanDataSupplier != null && connected && !client.isShutdown()) {
List requestData = this.requestSpanDataSupplier.getBufferData();
List ackData = this.ackSpanDataSupplier.getBufferData();
@@ -103,7 +103,7 @@ public class Agent2RoutingClient extends Thread {
listener.wait2Confirm();
}
- if(!hasData) {
+ if (!hasData) {
try {
Thread.sleep(10 * 1000L);
} catch (InterruptedException e) {
@@ -150,13 +150,13 @@ public class Agent2RoutingClient extends Thread {
HealthCollector.getCurrentHeathReading("Agent2RoutingClient").updateData(HeathReading.INFO, "batch send data to routing node.");
}
- void wait2Confirm(){
+ void wait2Confirm() {
// wait 20s, most.
int countDown = 100 * 20;
while (!listener.isBatchFinished()) {
try {
Thread.sleep(10L);
- if(countDown-- < 0){
+ if (countDown-- < 0) {
batchFinished = true;
}
} catch (InterruptedException e) {
@@ -169,7 +169,7 @@ public class Agent2RoutingClient extends Thread {
class ServerAddr {
- String ip;
+ String ip;
Integer port;
public ServerAddr(String ip, String port) {
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/disruptor/ack/SendAckSpanEventHandler.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/disruptor/ack/SendAckSpanEventHandler.java
index a4efc0cb0..fe9d4d023 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/disruptor/ack/SendAckSpanEventHandler.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/disruptor/ack/SendAckSpanEventHandler.java
@@ -6,7 +6,6 @@ import com.a.eye.skywalking.health.report.HeathReading;
import com.a.eye.skywalking.logging.api.ILog;
import com.a.eye.skywalking.logging.api.LogManager;
import com.a.eye.skywalking.network.grpc.AckSpan;
-import com.a.eye.skywalking.network.grpc.RequestSpan;
import com.lmax.disruptor.EventHandler;
import java.util.ArrayList;
@@ -16,10 +15,10 @@ import java.util.List;
* Created by wusheng on 2016/11/24.
*/
public class SendAckSpanEventHandler implements EventHandler {
- private static ILog logger = LogManager.getLogger(SendAckSpanEventHandler.class);
- private int bufferSize = 100;
- private AckSpan[] buffer = new AckSpan[bufferSize];
- private int bufferIdx = 0;
+ private static ILog logger = LogManager.getLogger(SendAckSpanEventHandler.class);
+ private int bufferSize = 100;
+ private AckSpan[] buffer = new AckSpan[bufferSize];
+ private int bufferIdx = 0;
public SendAckSpanEventHandler() {
Agent2RoutingClient.INSTANCE.setAckSpanDataSupplier(this);
@@ -27,7 +26,7 @@ public class SendAckSpanEventHandler implements EventHandler {
@Override
public void onEvent(AckSpanHolder event, long sequence, boolean endOfBatch) throws Exception {
- if(buffer[bufferIdx] != null){
+ if (buffer[bufferIdx] != null) {
return;
}
@@ -43,11 +42,13 @@ public class SendAckSpanEventHandler implements EventHandler {
}
}
- public List getBufferData(){
+ public List getBufferData() {
List data = new ArrayList(bufferSize);
for (int i = 0; i < buffer.length; i++) {
- data.add(buffer[i]);
- buffer[i] = null;
+ if (buffer[i] != null) {
+ data.add(buffer[i]);
+ buffer[i] = null;
+ }
}
return data;
}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/disruptor/request/SendRequestSpanEventHandler.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/disruptor/request/SendRequestSpanEventHandler.java
index 1b77b03c1..f35f7fc5a 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/disruptor/request/SendRequestSpanEventHandler.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/disruptor/request/SendRequestSpanEventHandler.java
@@ -15,10 +15,10 @@ import java.util.List;
* Created by wusheng on 2016/11/24.
*/
public class SendRequestSpanEventHandler implements EventHandler {
- private static ILog logger = LogManager.getLogger(SendRequestSpanEventHandler.class);
- private static final int bufferSize = 100;
- private RequestSpan[] buffer = new RequestSpan[bufferSize];
- private int bufferIdx = 0;
+ private static ILog logger = LogManager.getLogger(SendRequestSpanEventHandler.class);
+ private static final int bufferSize = 100;
+ private RequestSpan[] buffer = new RequestSpan[bufferSize];
+ private int bufferIdx = 0;
public SendRequestSpanEventHandler() {
Agent2RoutingClient.INSTANCE.setRequestSpanDataSupplier(this);
@@ -26,14 +26,14 @@ public class SendRequestSpanEventHandler implements EventHandler getBufferData(){
+ public List getBufferData() {
List data = new ArrayList(bufferSize);
for (int i = 0; i < buffer.length; i++) {
- data.add(buffer[i]);
- buffer[i] = null;
+ if (buffer[i] != null) {
+ data.add(buffer[i]);
+ buffer[i] = null;
+ }
}
return data;
}
diff --git a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/invoke/monitor/BaseInvokeMonitor.java b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/invoke/monitor/BaseInvokeMonitor.java
index ce3144cd7..4922043d4 100644
--- a/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/invoke/monitor/BaseInvokeMonitor.java
+++ b/skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/invoke/monitor/BaseInvokeMonitor.java
@@ -43,19 +43,21 @@ public abstract class BaseInvokeMonitor {
return new ContextData(spanData);
}
- protected void sendRequestSpan(Span span, Identification id){
+ protected void sendRequestSpan(Span span, Identification id) {
RequestSpan.Builder requestSpanBuilder = span.buildRequestSpan(RequestSpan.newBuilder());
+ if (id.getBusinessKey() != null && id.getBusinessKey().length() > 0) {
+ requestSpanBuilder = requestSpanBuilder.setBusinessKey(id.getBusinessKey());
+ }
RequestSpan requestSpan = requestSpanBuilder
.setViewPointId(id.getViewPoint())
.setSpanTypeDesc(id.getSpanTypeDesc())
- .setBusinessKey(id.getBusinessKey())
.setCallType(id.getCallType()).setProcessNo(BuriedPointMachineUtil.getProcessNo())
.setAddress(BuriedPointMachineUtil.getHostDesc()).build();
RequestSpanDisruptor.INSTANCE.ready2Send(requestSpan);
}
- protected void sendAckSpan(Span span){
+ protected void sendAckSpan(Span span) {
AckSpan ackSpan = span.buildAckSpan(AckSpan.newBuilder()).build();
AckSpanDisruptor.INSTANCE.ready2Send(ackSpan);
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/test/com/ai/skywalking/plugin/tomcat78x/EmbedTomcat.java b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/test/com/ai/skywalking/plugin/tomcat78x/EmbedTomcat.java
deleted file mode 100644
index f327fb3cf..000000000
--- a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/test/com/ai/skywalking/plugin/tomcat78x/EmbedTomcat.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package test.com.ai.skywalking.plugin.tomcat78x;
-
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.WebResourceRoot;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.startup.Tomcat;
-import org.apache.catalina.webresources.DirResourceSet;
-import org.apache.catalina.webresources.StandardRoot;
-import org.junit.Test;
-
-import javax.servlet.ServletException;
-import java.io.File;
-
-public class EmbedTomcat {
-
- @Test
- public void testGetResourcePath(){
- System.out.println(EmbedTomcat.class.getResource("/").getPath());
- }
-
- @Test
- public void testStartTomcat() throws ServletException, LifecycleException {
- start();
- }
-
- public static void start() throws ServletException, LifecycleException {
- String webappDirLocation = EmbedTomcat.class.getResource("/").getPath() + "webapp/";
- Tomcat tomcat = new Tomcat();
- tomcat.setPort(8080);
-
- StandardContext standardContext = (StandardContext) tomcat.addWebapp("/",new File(webappDirLocation).getAbsolutePath());
- File additionWebInfClasses = new File(EmbedTomcat.class.getResource("/").getPath());
- WebResourceRoot resourceRoot = new StandardRoot(standardContext);
- resourceRoot.addPreResources(new DirResourceSet(resourceRoot,"/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
- standardContext.setResources(resourceRoot);
-
- tomcat.start();
- }
-}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/test/com/ai/skywalking/plugin/tomcat78x/TomcatPluginTest.java b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/test/com/ai/skywalking/plugin/tomcat78x/TomcatPluginTest.java
deleted file mode 100644
index 52ddf6b24..000000000
--- a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/test/com/ai/skywalking/plugin/tomcat78x/TomcatPluginTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package test.com.ai.skywalking.plugin.tomcat78x;
-
-import com.a.eye.skywalking.plugin.PluginException;
-import com.a.eye.skywalking.plugin.TracingBootstrap;
-import com.a.eye.skywalking.testframework.api.RequestSpanAssert;
-import org.apache.catalina.LifecycleException;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
-import org.junit.Test;
-
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-public class TomcatPluginTest {
-
- @Test
- public void test() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, PluginException {
- TracingBootstrap.main(new String[] {TomcatPluginTest.class.getName()});
- }
-
- public static void main(String[] args) throws ServletException, LifecycleException, IOException, InterruptedException {
- // start tomcat
- EmbedTomcat.start();
- // curl httpclient
- visitURL("http://127.0.0.1:8080/hello");
- // assert client
- RequestSpanAssert.assertEquals(new String[][] {{"0", "http://127.0.0.1:8080/hello", ""}});
- }
-
- public static void visitURL(String url) throws IOException {
- CloseableHttpClient httpclient = HttpClients.createDefault();
- try {
- HttpGet httpget = new HttpGet(url);
- ResponseHandler responseHandler = new ResponseHandler() {
- @Override
- public String handleResponse(final HttpResponse response) throws ClientProtocolException, IOException {
- int status = response.getStatusLine().getStatusCode();
- if (status >= 200 && status < 300) {
- HttpEntity entity = response.getEntity();
- return entity != null ? EntityUtils.toString(entity) : null;
- } else {
- throw new ClientProtocolException("Unexpected response status: " + status);
- }
- }
-
- };
- String responseBody = httpclient.execute(httpget, responseHandler);
- } finally {
- httpclient.close();
- }
- }
-}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/test/com/ai/skywalking/plugin/tomcat78x/servlet/HelloServlet.java b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/test/com/ai/skywalking/plugin/tomcat78x/servlet/HelloServlet.java
deleted file mode 100644
index b9550f05c..000000000
--- a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/test/com/ai/skywalking/plugin/tomcat78x/servlet/HelloServlet.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package test.com.ai.skywalking.plugin.tomcat78x.servlet;
-
-import javax.servlet.ServletException;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * Created by xin on 16/7/22.
- */
-@WebServlet(
- name="myServlet",
- urlPatterns = {"/hello"}
-)
-public class HelloServlet extends HttpServlet{
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- System.out.println("Hello World");
- }
-}
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/resources/sky-walking.auth b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/resources/sky-walking.auth
deleted file mode 100644
index ff0b6dcf1..000000000
--- a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/resources/sky-walking.auth
+++ /dev/null
@@ -1,45 +0,0 @@
-#skyWalking用户ID
-skywalking.user_id=123
-#skyWalking应用编码
-skywalking.application_code=test
-#skywalking auth的环境变量名字
-skywalking.auth_system_env_name=SKYWALKING_RUN
-#skywalking数据编码
-skywalking.charset=UTF-8
-skywalking.auth_override=true
-
-#是否打印数据
-buriedpoint.printf=true
-#埋点异常的最大长度
-buriedpoint.max_exception_stack_length=4000
-#业务字段的最大长度
-buriedpoint.businesskey_max_length=300
-#过滤异常
-buriedpoint.exclusive_exceptions=java.lang.RuntimeException
-
-#最大发送者的连接数阀比例
-sender.connect_percent=100
-#发送服务端配置
-sender.servers_addr=127.0.0.1:34000
-#最大发送的副本数量
-sender.max_copy_num=2
-#发送的最大长度
-sender.max_send_length=20000
-#当没有Sender时,尝试获取sender的等待周期
-sender.retry_get_sender_wait_interval=2000
-
-#最大消费线程数
-consumer.max_consumer=0
-#消费者最大等待时间
-consumer.max_wait_time=5
-#发送失败等待时间
-consumer.consumer_fail_retry_wait_interval=50
-
-#每个Buffer的最大个数
-buffer.buffer_max_size=18000
-#Buffer池的最大长度
-buffer.pool_size=5
-
-#发送检查线程检查周期
-senderchecker.check_polling_time=200
-
diff --git a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/resources/webapp/HelloWorld.jsp b/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/resources/webapp/HelloWorld.jsp
deleted file mode 100644
index 7874157ad..000000000
--- a/skywalking-sniffer/skywalking-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/resources/webapp/HelloWorld.jsp
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-Hello World
-
-
\ No newline at end of file