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
This commit is contained in:
parent
5139fa99af
commit
48dacdb3f8
|
|
@ -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++;
|
||||
|
|
|
|||
Loading…
Reference in New Issue