wu-sheng closed pull request #804: Provide the getServerThroughput query. URL: https://github.com/apache/incubator-skywalking/pull/804
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java index 0e605ae67..bb089ddd8 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java @@ -30,7 +30,7 @@ */ public interface IInstanceMetricUIDAO extends DAO { - List<AppServerInfo> getTopNServerThroughput(int applicationId, Step step, long start, long end, long secondBetween, + List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end, long secondBetween, int topN, MetricSource metricSource); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java index fc32f5b24..352f24cdb 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java @@ -58,7 +58,7 @@ public InstanceMetricEsUIDAO(ElasticSearchClient client) { super(client); } - @Override public List<AppServerInfo> getTopNServerThroughput(int applicationId, Step step, long start, long end, + @Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end, long secondBetween, int topN, MetricSource metricSource) { String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java index fdc746e82..d7fb12e56 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java @@ -49,7 +49,7 @@ public InstanceMetricH2UIDAO(H2Client client) { super(client); } - @Override public List<AppServerInfo> getTopNServerThroughput(int applicationId, Step step, long start, long end, + @Override public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, long end, long secondBetween, int topN, MetricSource metricSource) { return null; } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java index 121cdce78..76b6fff45 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java @@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.ui.graphql.Query; import org.apache.skywalking.apm.collector.ui.service.ApplicationService; import org.apache.skywalking.apm.collector.ui.service.ApplicationTopologyService; +import org.apache.skywalking.apm.collector.ui.service.ServerService; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** @@ -40,6 +41,7 @@ private final ModuleManager moduleManager; private ApplicationService applicationService; private ApplicationTopologyService applicationTopologyService; + private ServerService serverService; public ApplicationQuery(ModuleManager moduleManager) { this.moduleManager = moduleManager; @@ -59,6 +61,13 @@ private ApplicationTopologyService getApplicationTopologyService() { return applicationTopologyService; } + private ServerService getServerService() { + if (ObjectUtils.isEmpty(serverService)) { + this.serverService = new ServerService(moduleManager); + } + return serverService; + } + public List<Application> getAllApplication(Duration duration) throws ParseException { long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); @@ -73,14 +82,19 @@ public Topology getApplicationTopology(int applicationId, Duration duration) thr return getApplicationTopologyService().getApplicationTopology(duration.getStep(), applicationId, start, end); } - public List<ServiceMetric> getSlowService(int applicationId, Duration duration, Integer top) throws ParseException { + public List<ServiceMetric> getSlowService(int applicationId, Duration duration, + Integer topN) throws ParseException { long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); - return getApplicationService().getSlowService(applicationId, duration.getStep(), start, end, top); + return getApplicationService().getSlowService(applicationId, duration.getStep(), start, end, topN); } - public List<AppServerInfo> getServerThroughput(int applicationId, Duration duration, Integer top) { - return null; + public List<AppServerInfo> getServerThroughput(int applicationId, Duration duration, + Integer topN) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + + return getServerService().getServerThroughput(applicationId, duration.getStep(), start, end, topN); } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java index ce91185ee..577e159a9 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java @@ -36,6 +36,8 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; @@ -97,6 +99,21 @@ public ResponseTimeTrend getServerResponseTimeTrend(int instanceId, Step step, l return responseTimeTrend; } + public List<AppServerInfo> getServerThroughput(int applicationId, Step step, long start, + long end, Integer topN) throws ParseException { + //TODO + List<AppServerInfo> serverThroughput = instanceMetricUIDAO.getServerThroughput(applicationId, step, start, end, 1000, topN, MetricSource.Callee); + serverThroughput.forEach(appServerInfo -> { + String applicationCode = applicationCacheService.getApplicationById(applicationId).getApplicationCode(); + appServerInfo.setApplicationCode(applicationCode); + Instance instance = instanceUIDAO.getInstance(appServerInfo.getId()); + appServerInfo.setOsInfo(instance.getOsInfo()); + }); + + buildAppServerInfo(serverThroughput); + return serverThroughput; + } + public ThroughputTrend getServerTPSTrend(int instanceId, Step step, long start, long end) throws ParseException { ThroughputTrend throughputTrend = new ThroughputTrend(); List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls index 67f435073..1cf9643f3 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls @@ -43,6 +43,6 @@ type Application { extend type Query { getAllApplication(duration: Duration!): [Application!]! getApplicationTopology(applicationId: ID!, duration: Duration!): Topology - getSlowService(applicationId: ID!, duration: Duration!, top: Int!): [ServiceMetric!]! - getServerThroughput(applicationId: ID!, duration: Duration!, top: Int!): [AppServerInfo!]! + getSlowService(applicationId: ID!, duration: Duration!, topN: Int!): [ServiceMetric!]! + getServerThroughput(applicationId: ID!, duration: Duration!, topN: Int!): [AppServerInfo!]! } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services