You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/06/09 11:40:21 UTC
[incubator-skywalking] branch master updated: #1176 (#1335)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 5f81c00 #1176 (#1335)
5f81c00 is described below
commit 5f81c0068ed16911f2ba8961bb0555b2d91b12c8
Author: 彭勇升 pengys <80...@qq.com>
AuthorDate: Sat Jun 9 19:40:04 2018 +0800
#1176 (#1335)
Add application id and code into ServiceInfo.
---
.../collector/storage/ui/service/ServiceInfo.java | 18 ++++++++++++++++++
.../storage/es/dao/ui/ServiceNameServiceEsUIDAO.java | 1 +
.../storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java | 5 +++--
.../apm/collector/ui/service/ServiceNameService.java | 20 ++++++++++++++++----
.../main/resources/ui-graphql/service-layer.graphqls | 2 ++
5 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java
index 808fe25..1a25728 100644
--- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java
@@ -24,6 +24,8 @@ package org.apache.skywalking.apm.collector.storage.ui.service;
public class ServiceInfo {
private int id;
private String name;
+ private int applicationId;
+ private String applicationName;
public int getId() {
return id;
@@ -40,4 +42,20 @@ public class ServiceInfo {
public void setName(String name) {
this.name = name;
}
+
+ public int getApplicationId() {
+ return applicationId;
+ }
+
+ public void setApplicationId(int applicationId) {
+ this.applicationId = applicationId;
+ }
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
}
diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java
index 5f7cde5..d28846a 100644
--- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java
+++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java
@@ -83,6 +83,7 @@ public class ServiceNameServiceEsUIDAO extends EsDAO implements IServiceNameServ
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setId(((Number)searchHit.getSource().get(ServiceNameTable.SERVICE_ID.getName())).intValue());
serviceInfo.setName((String)searchHit.getSource().get(ServiceNameTable.SERVICE_NAME.getName()));
+ serviceInfo.setApplicationId(((Number)searchHit.getSource().get(ServiceNameTable.APPLICATION_ID.getName())).intValue());
serviceInfos.add(serviceInfo);
}
return serviceInfos;
diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java
index 167b8f6..16923f2 100644
--- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java
+++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java
@@ -57,8 +57,8 @@ public class ServiceNameServiceH2UIDAO extends H2DAO implements IServiceNameServ
@Override
public List<ServiceInfo> searchService(String keyword, int applicationId, long startTimeMillis, int topN) {
- String dynamicSql = "select {0},{1} from {2} where {3} like ? and {4} = ? and {5} = ? and {6} >= ? limit ?";
- String sql = SqlBuilder.buildSql(dynamicSql, ServiceNameTable.SERVICE_ID.getName(), ServiceNameTable.SERVICE_NAME.getName(), ServiceNameTable.TABLE, ServiceNameTable.SERVICE_NAME.getName(), ServiceNameTable.SRC_SPAN_TYPE.getName(), ServiceNameTable.APPLICATION_ID.getName(), ServiceNameTable.HEARTBEAT_TIME.getName());
+ String dynamicSql = "select {0},{1},{2} from {3} where {4} like ? and {5} = ? and {6} = ? and {7} >= ? limit ?";
+ String sql = SqlBuilder.buildSql(dynamicSql, ServiceNameTable.SERVICE_ID.getName(), ServiceNameTable.SERVICE_NAME.getName(), ServiceNameTable.APPLICATION_ID.getName(), ServiceNameTable.TABLE, ServiceNameTable.SERVICE_NAME.getName(), ServiceNameTable.SRC_SPAN_TYPE.getName(), ServiceNameTable.APPLICATION_ID.getName(), ServiceNameTable.HEARTBEAT_TIME.getName());
Object[] params = new Object[] {keyword, SpanType.Entry_VALUE, applicationId, startTimeMillis, topN};
List<ServiceInfo> serviceInfos = new LinkedList<>();
@@ -67,6 +67,7 @@ public class ServiceNameServiceH2UIDAO extends H2DAO implements IServiceNameServ
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setId(rs.getInt(ServiceNameTable.SERVICE_ID.getName()));
serviceInfo.setName(rs.getString(ServiceNameTable.SERVICE_NAME.getName()));
+ serviceInfo.setApplicationId(rs.getInt(ServiceNameTable.APPLICATION_ID.getName()));
serviceInfos.add(serviceInfo);
}
} catch (SQLException | H2ClientException e) {
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java
index 964317f..94fda5f 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java
@@ -19,14 +19,15 @@
package org.apache.skywalking.apm.collector.ui.service;
import java.text.ParseException;
-import java.util.List;
+import java.util.*;
import org.apache.skywalking.apm.collector.cache.CacheModule;
-import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService;
+import org.apache.skywalking.apm.collector.cache.service.*;
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
+import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.storage.StorageModule;
import org.apache.skywalking.apm.collector.storage.dao.ui.*;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
-import org.apache.skywalking.apm.collector.storage.table.register.ServiceName;
+import org.apache.skywalking.apm.collector.storage.table.register.*;
import org.apache.skywalking.apm.collector.storage.ttl.ITTLConfigService;
import org.apache.skywalking.apm.collector.storage.ui.common.*;
import org.apache.skywalking.apm.collector.storage.ui.service.*;
@@ -41,6 +42,7 @@ public class ServiceNameService {
private static final Logger logger = LoggerFactory.getLogger(ServiceNameService.class);
+ private final ApplicationCacheService applicationCacheService;
private final IServiceNameServiceUIDAO serviceNameServiceUIDAO;
private final IServiceMetricUIDAO serviceMetricUIDAO;
private final ServiceNameCacheService serviceNameCacheService;
@@ -48,6 +50,7 @@ public class ServiceNameService {
private final ITTLConfigService configService;
public ServiceNameService(ModuleManager moduleManager) {
+ this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
this.serviceNameServiceUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceNameServiceUIDAO.class);
this.serviceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceMetricUIDAO.class);
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
@@ -60,7 +63,16 @@ public class ServiceNameService {
}
public List<ServiceInfo> searchService(String keyword, int applicationId, int topN) {
- return serviceNameServiceUIDAO.searchService(keyword, applicationId, startTimeMillis(), topN);
+ List<ServiceInfo> services = serviceNameServiceUIDAO.searchService(keyword, applicationId, startTimeMillis(), topN);
+ services.forEach(service -> {
+ Application application = applicationCacheService.getApplicationById(service.getApplicationId());
+ if (Objects.nonNull(application)) {
+ service.setApplicationName(application.getApplicationCode());
+ } else {
+ service.setApplicationName(Const.EMPTY_STRING);
+ }
+ });
+ return services;
}
private long startTimeMillis() {
diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls
index a33ad3d..40ab994 100644
--- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls
+++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls
@@ -30,6 +30,8 @@ type ServiceNode implements Node {
type ServiceInfo {
id: ID!
name: String
+ applicationId: ID!
+ applicationName: String
}
type ServiceMetric {
--
To stop receiving notification emails like this one, please contact
wusheng@apache.org.