Merge branch 'master' into sync-ui
This commit is contained in:
commit
c6dce72be4
|
|
@ -25,6 +25,8 @@ import org.apache.skywalking.apm.collector.analysis.jvm.define.service.ICpuMetri
|
|||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IGCMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.jvm.define.service.IMemoryPoolMetricService;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.AnalysisMetricModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.define.service.IInstanceHeartBeatService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.server.grpc.GRPCHandler;
|
||||
|
|
@ -49,12 +51,14 @@ public class JVMMetricsServiceHandler extends JVMMetricsServiceGrpc.JVMMetricsSe
|
|||
private final IGCMetricService gcMetricService;
|
||||
private final IMemoryMetricService memoryMetricService;
|
||||
private final IMemoryPoolMetricService memoryPoolMetricService;
|
||||
private final IInstanceHeartBeatService instanceHeartBeatService;
|
||||
|
||||
public JVMMetricsServiceHandler(ModuleManager moduleManager) {
|
||||
this.cpuMetricService = moduleManager.find(AnalysisJVMModule.NAME).getService(ICpuMetricService.class);
|
||||
this.gcMetricService = moduleManager.find(AnalysisJVMModule.NAME).getService(IGCMetricService.class);
|
||||
this.memoryMetricService = moduleManager.find(AnalysisJVMModule.NAME).getService(IMemoryMetricService.class);
|
||||
this.memoryPoolMetricService = moduleManager.find(AnalysisJVMModule.NAME).getService(IMemoryPoolMetricService.class);
|
||||
this.instanceHeartBeatService = moduleManager.find(AnalysisMetricModule.NAME).getService(IInstanceHeartBeatService.class);
|
||||
}
|
||||
|
||||
@Override public void collect(JVMMetrics request, StreamObserver<Downstream> responseObserver) {
|
||||
|
|
@ -67,6 +71,7 @@ public class JVMMetricsServiceHandler extends JVMMetricsServiceGrpc.JVMMetricsSe
|
|||
sendToMemoryMetricService(instanceId, time, metric.getMemoryList());
|
||||
sendToMemoryPoolMetricService(instanceId, time, metric.getMemoryPoolList());
|
||||
sendToGCMetricService(instanceId, time, metric.getGcList());
|
||||
sendToInstanceHeartBeatService(instanceId, metric.getTime());
|
||||
});
|
||||
|
||||
responseObserver.onNext(Downstream.newBuilder().build());
|
||||
|
|
@ -90,4 +95,8 @@ public class JVMMetricsServiceHandler extends JVMMetricsServiceGrpc.JVMMetricsSe
|
|||
private void sendToGCMetricService(int instanceId, long timeBucket, List<GC> gcs) {
|
||||
gcs.forEach(gc -> gcMetricService.send(instanceId, timeBucket, gc.getPhraseValue(), gc.getCount(), gc.getTime()));
|
||||
}
|
||||
|
||||
private void sendToInstanceHeartBeatService(int instanceId, long heartBeatTime) {
|
||||
instanceHeartBeatService.heartBeat(instanceId, heartBeatTime);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class ServiceNameDiscoveryServiceHandler extends ServiceNameDiscoveryServ
|
|||
int applicationId = serviceNameElement.getApplicationId();
|
||||
String serviceName = serviceNameElement.getServiceName();
|
||||
int srcSpanType = serviceNameElement.getSrcSpanTypeValue();
|
||||
int serviceId = serviceNameService.getOrCreate(applicationId, srcSpanType, serviceName);
|
||||
int serviceId = serviceNameService.get(applicationId, srcSpanType, serviceName);
|
||||
|
||||
if (serviceId != 0) {
|
||||
ServiceNameMappingElement.Builder mappingElement = ServiceNameMappingElement.newBuilder();
|
||||
|
|
|
|||
|
|
@ -24,5 +24,8 @@ import org.apache.skywalking.apm.collector.core.module.Service;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IServiceNameService extends Service {
|
||||
|
||||
int getOrCreate(int applicationId, int srcSpanType, String serviceName);
|
||||
|
||||
int get(int applicationId, int srcSpanType, String serviceName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,4 +74,8 @@ public class ServiceNameService implements IServiceNameService {
|
|||
}
|
||||
return serviceId;
|
||||
}
|
||||
|
||||
@Override public int get(int applicationId, int srcSpanType, String serviceName) {
|
||||
return getServiceIdCacheService().get(applicationId, srcSpanType, serviceName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.apache.skywalking.apm.network.proto.UniqueId;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ReferenceDecorator implements StandardBuilder {
|
||||
|
||||
private boolean isOrigin = true;
|
||||
private StandardBuilder standardBuilder;
|
||||
private TraceSegmentReference referenceObject;
|
||||
|
|
|
|||
|
|
@ -66,8 +66,14 @@ public class MemoryMetricEsUIDAO extends EsDAO implements IMemoryMetricUIDAO {
|
|||
long max = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_MAX)).longValue();
|
||||
long used = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_USED)).longValue();
|
||||
long times = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_TIMES)).longValue();
|
||||
|
||||
trend.getMetrics().add((int)(used / times));
|
||||
trend.getMaxMetrics().add((int)(max / times));
|
||||
|
||||
if (max < 0) {
|
||||
trend.getMaxMetrics().add((int)(used / times));
|
||||
} else {
|
||||
trend.getMaxMetrics().add((int)(max / times));
|
||||
}
|
||||
} else {
|
||||
trend.getMetrics().add(0);
|
||||
trend.getMaxMetrics().add(0);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,12 @@ public class MemoryMetricH2UIDAO extends H2DAO implements IMemoryMetricUIDAO {
|
|||
long used = rs.getLong(MemoryMetricTable.COLUMN_USED);
|
||||
long times = rs.getLong(MemoryMetricTable.COLUMN_TIMES);
|
||||
trend.getMetrics().add((int)(used / times));
|
||||
trend.getMaxMetrics().add((int)(max / times));
|
||||
|
||||
if (max < 0) {
|
||||
trend.getMaxMetrics().add((int)(used / times));
|
||||
} else {
|
||||
trend.getMaxMetrics().add((int)(max / times));
|
||||
}
|
||||
} else {
|
||||
trend.getMetrics().add(0);
|
||||
trend.getMaxMetrics().add(0);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.skywalking.apm.collector.ui.graphql.Query;
|
|||
import org.apache.skywalking.apm.collector.ui.service.SegmentTopService;
|
||||
import org.apache.skywalking.apm.collector.ui.service.TraceStackService;
|
||||
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
|
||||
import org.apache.skywalking.apm.collector.ui.utils.PaginationUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -77,10 +78,9 @@ public class TraceQuery implements Query {
|
|||
long maxDuration = condition.getMaxTraceDuration();
|
||||
String operationName = condition.getOperationName();
|
||||
int applicationId = condition.getApplicationId();
|
||||
int limit = condition.getPaging().getPageSize();
|
||||
int from = condition.getPaging().getPageSize() * condition.getPaging().getPageNum();
|
||||
|
||||
return getSegmentTopService().loadTop(startSecondTimeBucket, endSecondTimeBucket, minDuration, maxDuration, operationName, traceId, applicationId, limit, from);
|
||||
PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(condition.getPaging());
|
||||
return getSegmentTopService().loadTop(startSecondTimeBucket, endSecondTimeBucket, minDuration, maxDuration, operationName, traceId, applicationId, page.getLimit(), page.getFrom());
|
||||
}
|
||||
|
||||
public Trace queryTrace(String traceId) {
|
||||
|
|
|
|||
|
|
@ -72,11 +72,12 @@ public class ApplicationService {
|
|||
int... applicationIds) {
|
||||
List<Application> applications = instanceDAO.getApplications(startSecondTimeBucket, endSecondTimeBucket, applicationIds);
|
||||
|
||||
applications.forEach(application -> {
|
||||
for (int i = applications.size() - 1; i >= 0; i--) {
|
||||
Application application = applications.get(i);
|
||||
if (application.getId() == Const.NONE_APPLICATION_ID) {
|
||||
applications.remove(application);
|
||||
applications.remove(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
applications.forEach(application -> {
|
||||
String applicationCode = applicationCacheService.getApplicationById(application.getId()).getApplicationCode();
|
||||
|
|
@ -112,11 +113,12 @@ public class ApplicationService {
|
|||
return applicationThroughput;
|
||||
}
|
||||
|
||||
public ConjecturalAppBrief getConjecturalApps(Step step, long startSecondTimeBucket, long endSecondTimeBucket) throws ParseException {
|
||||
public ConjecturalAppBrief getConjecturalApps(Step step, long startSecondTimeBucket,
|
||||
long endSecondTimeBucket) throws ParseException {
|
||||
List<ConjecturalApp> conjecturalApps = networkAddressUIDAO.getConjecturalApps();
|
||||
conjecturalApps.forEach(conjecturalApp -> {
|
||||
String name = ServerTypeDefine.getInstance().getServerType(conjecturalApp.getId());
|
||||
conjecturalApp.setName(name);
|
||||
String serverType = ServerTypeDefine.getInstance().getServerType(conjecturalApp.getId());
|
||||
conjecturalApp.setName(serverType);
|
||||
});
|
||||
|
||||
ConjecturalAppBrief conjecturalAppBrief = new ConjecturalAppBrief();
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@ class SecondBetweenService {
|
|||
Date startDate = new SimpleDateFormat("yyyyMMddHHmmss").parse(String.valueOf(startSecondTimeBucket));
|
||||
Date endDate = new SimpleDateFormat("yyyyMMddHHmmss").parse(String.valueOf(endSecondTimeBucket));
|
||||
|
||||
return Seconds.secondsBetween(new DateTime(startDate), new DateTime(endDate)).getSeconds();
|
||||
int seconds = Seconds.secondsBetween(new DateTime(startDate), new DateTime(endDate)).getSeconds();
|
||||
if (seconds == 0) {
|
||||
seconds = 1;
|
||||
}
|
||||
return seconds;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.cache.CacheModule;
|
||||
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
|
||||
import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.StringUtils;
|
||||
|
|
@ -59,7 +58,6 @@ public class ServerService {
|
|||
private final ICpuMetricUIDAO cpuMetricUIDAO;
|
||||
private final IGCMetricUIDAO gcMetricUIDAO;
|
||||
private final IMemoryMetricUIDAO memoryMetricUIDAO;
|
||||
private final InstanceCacheService instanceCacheService;
|
||||
private final ApplicationCacheService applicationCacheService;
|
||||
private final SecondBetweenService secondBetweenService;
|
||||
|
||||
|
|
@ -69,18 +67,18 @@ public class ServerService {
|
|||
this.cpuMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricUIDAO.class);
|
||||
this.gcMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricUIDAO.class);
|
||||
this.memoryMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryMetricUIDAO.class);
|
||||
this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class);
|
||||
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
|
||||
this.secondBetweenService = new SecondBetweenService(moduleManager);
|
||||
}
|
||||
|
||||
public List<AppServerInfo> searchServer(String keyword, long startSecondTimeBucket, long endSecondTimeBucket) {
|
||||
List<AppServerInfo> serverInfos = instanceUIDAO.searchServer(keyword, startSecondTimeBucket, endSecondTimeBucket);
|
||||
serverInfos.forEach(serverInfo -> {
|
||||
if (serverInfo.getId() == Const.NONE_INSTANCE_ID) {
|
||||
serverInfos.remove(serverInfo);
|
||||
|
||||
for (int i = serverInfos.size() - 1; i >= 0; i--) {
|
||||
if (serverInfos.get(i).getId() == Const.NONE_INSTANCE_ID) {
|
||||
serverInfos.remove(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
buildAppServerInfo(serverInfos);
|
||||
return serverInfos;
|
||||
|
|
@ -164,6 +162,8 @@ public class ServerService {
|
|||
private void buildAppServerInfo(List<AppServerInfo> serverInfos) {
|
||||
serverInfos.forEach(serverInfo -> {
|
||||
serverInfo.setApplicationCode(applicationCacheService.getApplicationById(serverInfo.getApplicationId()).getApplicationCode());
|
||||
StringBuilder nameBuilder = new StringBuilder();
|
||||
nameBuilder.append(serverInfo.getApplicationCode());
|
||||
if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) {
|
||||
JsonObject osInfoJson = gson.fromJson(serverInfo.getOsInfo(), JsonObject.class);
|
||||
if (osInfoJson.has("osName")) {
|
||||
|
|
@ -180,10 +180,14 @@ public class ServerService {
|
|||
JsonArray ipv4Array = osInfoJson.get("ipv4s").getAsJsonArray();
|
||||
|
||||
List<String> ipv4s = new LinkedList<>();
|
||||
ipv4Array.forEach(ipv4 -> ipv4s.add(ipv4.getAsString()));
|
||||
ipv4Array.forEach(ipv4 -> {
|
||||
ipv4s.add(ipv4.getAsString());
|
||||
nameBuilder.append(Const.ID_SPLIT).append(ipv4.getAsString());
|
||||
});
|
||||
serverInfo.setIpv4(ipv4s);
|
||||
}
|
||||
}
|
||||
serverInfo.setName(nameBuilder.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ public class ServiceTopologyService {
|
|||
Map<Integer, String> components = new HashMap<>();
|
||||
applicationComponents.forEach(component -> components.put(component.getApplicationId(), ComponentsDefine.getInstance().getComponentName(component.getComponentId())));
|
||||
|
||||
List<IServiceReferenceMetricUIDAO.ServiceReferenceMetric> referenceMetrics = serviceReferenceMetricUIDAO.getFrontServices(step, startTimeBucket, endTimeBucket, MetricSource.Callee, serviceId);
|
||||
referenceMetrics.addAll(serviceReferenceMetricUIDAO.getBehindServices(step, startTimeBucket, endTimeBucket, MetricSource.Caller, serviceId));
|
||||
List<IServiceReferenceMetricUIDAO.ServiceReferenceMetric> referenceMetrics = serviceReferenceMetricUIDAO.getFrontServices(step, startTimeBucket, endTimeBucket, MetricSource.Caller, serviceId);
|
||||
referenceMetrics.addAll(serviceReferenceMetricUIDAO.getBehindServices(step, startTimeBucket, endTimeBucket, MetricSource.Callee, serviceId));
|
||||
|
||||
Set<Integer> nodeIds = new HashSet<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public enum ApdexCalculator {
|
|||
INSTANCE;
|
||||
|
||||
public int calculate(long satisfiedCount, long toleratingCount, long frustratedCount) {
|
||||
return (int)(((satisfiedCount + toleratingCount / 2) * 100) / (satisfiedCount + toleratingCount + frustratedCount));
|
||||
if (satisfiedCount + toleratingCount + frustratedCount == 0) {
|
||||
return 100;
|
||||
} else {
|
||||
return (int)(((satisfiedCount + toleratingCount / 2) * 100) / (satisfiedCount + toleratingCount + frustratedCount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ public enum OperationNameDictionary {
|
|||
ServiceNameElement serviceNameElement = ServiceNameElement.newBuilder()
|
||||
.setApplicationId(operationNameKey.getApplicationId())
|
||||
.setServiceName(operationNameKey.getOperationName())
|
||||
.setSrcSpanType(operationNameKey.getSpanType())
|
||||
.build();
|
||||
builder.addElements(serviceNameElement);
|
||||
}
|
||||
|
|
@ -122,9 +123,14 @@ public enum OperationNameDictionary {
|
|||
|
||||
OperationNameKey key = (OperationNameKey)o;
|
||||
|
||||
if (applicationId != key.applicationId)
|
||||
return false;
|
||||
return operationName.equals(key.operationName);
|
||||
boolean isApplicationMatch = false;
|
||||
if (applicationId == key.applicationId) {
|
||||
isApplicationMatch = true;
|
||||
} else if (operationName.equals(key.operationName)) {
|
||||
isApplicationMatch = true;
|
||||
}
|
||||
return isApplicationMatch && isEntry == key.isEntry
|
||||
&& isExit == key.isExit;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
|
|
@ -140,5 +146,15 @@ public enum OperationNameDictionary {
|
|||
boolean isExit() {
|
||||
return isExit;
|
||||
}
|
||||
|
||||
SpanType getSpanType() {
|
||||
if (isEntry) {
|
||||
return SpanType.Entry;
|
||||
} else if (isExit) {
|
||||
return SpanType.Exit;
|
||||
} else {
|
||||
return SpanType.Local;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue