提交 48dacdb3 编写于 作者: 林嘉琦 Lin Jiaqi 提交者: 彭勇升 pengys

Support multiple service names in segment duration table (#1380)

* support shardingjdbc database storage feature

* dependency and version should be defined in collector root pom.xml

* update the markdown file

* fix errors

* fix checkstyle errors

* add the Logger modifier "static" in pr #1347

* fix the issue #1376
上级 5139fa99
......@@ -19,6 +19,8 @@
package org.apache.skywalking.apm.collector.storage.shardingjdbc.dao;
import java.util.*;
import com.google.gson.Gson;
import org.apache.skywalking.apm.collector.client.shardingjdbc.*;
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO;
......@@ -34,6 +36,8 @@ public class SegmentDurationShardingjdbcPersistenceDAO extends ShardingjdbcDAO i
private static final Logger logger = LoggerFactory.getLogger(SegmentDurationShardingjdbcPersistenceDAO.class);
private final Gson gson = new Gson();
public SegmentDurationShardingjdbcPersistenceDAO(ShardingjdbcClient client) {
super(client);
}
......@@ -49,7 +53,7 @@ public class SegmentDurationShardingjdbcPersistenceDAO extends ShardingjdbcDAO i
target.put(SegmentDurationTable.ID.getName(), data.getId());
target.put(SegmentDurationTable.SEGMENT_ID.getName(), data.getSegmentId());
target.put(SegmentDurationTable.APPLICATION_ID.getName(), data.getApplicationId());
target.put(SegmentDurationTable.SERVICE_NAME.getName(), data.getServiceName());
target.put(SegmentDurationTable.SERVICE_NAME.getName(), gson.toJson(data.getServiceName()));
target.put(SegmentDurationTable.DURATION.getName(), data.getDuration());
target.put(SegmentDurationTable.START_TIME.getName(), data.getStartTime());
target.put(SegmentDurationTable.END_TIME.getName(), data.getEndTime());
......
......@@ -24,8 +24,10 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import com.google.gson.Gson;
import org.apache.skywalking.apm.collector.client.shardingjdbc.ShardingjdbcClient;
import org.apache.skywalking.apm.collector.client.shardingjdbc.ShardingjdbcClientException;
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
......@@ -48,6 +50,8 @@ public class SegmentDurationShardingjdbcUIDAO extends ShardingjdbcDAO implements
private static final Logger logger = LoggerFactory.getLogger(SegmentDurationShardingjdbcUIDAO.class);
private final Gson gson = new Gson();
public SegmentDurationShardingjdbcUIDAO(ShardingjdbcClient client) {
super(client);
}
......@@ -141,8 +145,11 @@ public class SegmentDurationShardingjdbcUIDAO extends ShardingjdbcDAO implements
basicTrace.setSegmentId(rs.getString(SegmentDurationTable.SEGMENT_ID.getName()));
basicTrace.setDuration(rs.getInt(SegmentDurationTable.DURATION.getName()));
basicTrace.setStart(rs.getLong(SegmentDurationTable.START_TIME.getName()));
//TODO linjiaqi operation name was changed to contains multiple values
//basicTrace.setOperationName(rs.getString(SegmentDurationTable.SERVICE_NAME.getName()));
String serviceNameJsonStr = rs.getString(SegmentDurationTable.SERVICE_NAME.getName());
if (StringUtils.isNotEmpty(serviceNameJsonStr)) {
List serviceNames = gson.fromJson(serviceNameJsonStr, LinkedList.class);
basicTrace.getOperationName().addAll(serviceNames);
}
basicTrace.setError(BooleanUtils.valueToBoolean(rs.getInt(SegmentDurationTable.IS_ERROR.getName())));
traceBrief.getTraces().add(basicTrace);
cnt++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册