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 2019/11/30 14:27:19 UTC

[skywalking-rocketbot-ui] branch master updated: Feat: Add Apdex metric (#215)

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/skywalking-rocketbot-ui.git


The following commit(s) were added to refs/heads/master by this push:
     new 77d6532  Feat: Add Apdex metric (#215)
77d6532 is described below

commit 77d6532d0e1bb1dcaadbcc739cc9f60ea7e870fe
Author: Qiuxia Fan <fi...@outlook.com>
AuthorDate: Sat Nov 30 22:27:13 2019 +0800

    Feat: Add Apdex metric (#215)
    
    * add service apdex metric
    
    * fix: typo
    
    * feat: add apdex in default service layout
    
    * fix: unit
    
    * fix: temp data
---
 src/store/modules/comparison/comparison-store.ts       |  5 +++++
 src/store/modules/dashboard/fragments/service.ts       | 11 +++++++++++
 src/store/modules/dashboard/source/index.ts            |  1 +
 src/store/modules/dashboard/source/service.ts          |  6 ++++++
 .../modules/dashboard/template/service-template.ts     | 18 +++++++++++++-----
 src/utils/queryChartData.ts                            |  2 ++
 src/views/components/dashboard/charts/chart-num.vue    |  5 ++++-
 src/views/components/dashboard/dashboard-comp.vue      |  2 +-
 8 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/src/store/modules/comparison/comparison-store.ts b/src/store/modules/comparison/comparison-store.ts
index 6ae06e6..7942b2e 100644
--- a/src/store/modules/comparison/comparison-store.ts
+++ b/src/store/modules/comparison/comparison-store.ts
@@ -548,6 +548,11 @@ const actions: ActionTree<State, ActionsParamType> = {
         return {value: i.value / 100};
       });
     }
+    if (params.value.serviceApdexScore) {
+      params.value.serviceApdexScore.values = params.value.serviceApdexScore.values.map((i: any) => {
+        return {value: (i.value / 10000).toFixed(2)};
+      });
+    }
     if (params.value.heap && params.value.maxHeap) {
       params.value.heap.values = params.value.heap.values.map((i: any) => {
         return {value: (i.value / 1048576).toFixed(2)};
diff --git a/src/store/modules/dashboard/fragments/service.ts b/src/store/modules/dashboard/fragments/service.ts
index dd8f126..d7ba424 100644
--- a/src/store/modules/dashboard/fragments/service.ts
+++ b/src/store/modules/dashboard/fragments/service.ts
@@ -107,3 +107,14 @@ export const serviceInstanceThroughput =  {
     value
   }`,
 };
+
+export const serviceApdexScore =  {
+  variable: ['$serviceId: ID!', '$duration: Duration!'],
+  fragment: `
+  serviceApdexScore: getLinearIntValues(metric: {
+    name: "service_apdex"
+    id: $serviceId
+  }, duration: $duration) {
+    values {value}
+  }`,
+};
diff --git a/src/store/modules/dashboard/source/index.ts b/src/store/modules/dashboard/source/index.ts
index 707f8a8..2d52256 100644
--- a/src/store/modules/dashboard/source/index.ts
+++ b/src/store/modules/dashboard/source/index.ts
@@ -40,6 +40,7 @@ export interface State {
   globalHeatmap: number[][];
   globalSlow: SlowItem[];
   globalThroughput: SlowItem[];
+  serviceApdexScore: { ApdexScore: number[]; };
   serviceResponseTime: { ResponseTime: number[]; };
   serviceInstanceThroughput: SlowItem[];
   serviceSLA: { SLA: number[]; };
diff --git a/src/store/modules/dashboard/source/service.ts b/src/store/modules/dashboard/source/service.ts
index fe27ea9..5f39380 100644
--- a/src/store/modules/dashboard/source/service.ts
+++ b/src/store/modules/dashboard/source/service.ts
@@ -19,6 +19,7 @@ import { SlowItem } from '@/types/global';
 import { Value } from '@/types/dashboard';
 
 export interface State {
+  serviceApdexScore: {ApdexScore: number[]};
   serviceResponseTime: { ResponseTime: number[]; };
   serviceInstanceThroughput: SlowItem[];
   serviceSLA: { SLA: number[]; };
@@ -34,6 +35,7 @@ export interface State {
 }
 
 export const initState: State = {
+  serviceApdexScore: { ApdexScore: [] },
   serviceResponseTime: { ResponseTime: [] },
   serviceInstanceThroughput: [],
   serviceSLA: { SLA: [] },
@@ -71,4 +73,8 @@ export const SetService = (state: State, params: any) => {
   if (params && params.serviceThroughput) {
     state.serviceThroughput.Throughput = params.serviceThroughput.values.map((i: Value) => i.value);
   }
+  if (params && params.serviceApdexScore) {
+    state.serviceApdexScore.ApdexScore =
+      params.serviceApdexScore.values.map((i: any) => Number((i.value / 10000).toFixed(2)));
+  }
 };
diff --git a/src/store/modules/dashboard/template/service-template.ts b/src/store/modules/dashboard/template/service-template.ts
index ce4c262..1770e67 100644
--- a/src/store/modules/dashboard/template/service-template.ts
+++ b/src/store/modules/dashboard/template/service-template.ts
@@ -17,12 +17,12 @@
 
 export default [
   {
-    o: 'Global',
-    d: 'globalBrief',
-    c: 'ChartBrief',
-    t: 'Global Brief',
+    o: 'Service',
+    d: 'serviceApdexScore',
+    c: 'ChartNum',
+    t: 'Service Avg ApdexScore',
     w: 3,
-    h: 250,
+    h: 80,
   },
   {
     o: 'Service',
@@ -50,6 +50,14 @@ export default [
   },
   {
     o: 'Service',
+    d: 'serviceApdexScore',
+    c: 'ChartLine',
+    t: 'Service ApdexScore',
+    w: 3,
+    h: 170,
+  },
+  {
+    o: 'Service',
     d: 'serviceResponseTime',
     c: 'ChartLine',
     t: 'Service ResponseTime',
diff --git a/src/utils/queryChartData.ts b/src/utils/queryChartData.ts
index 2aed768..5965a2d 100644
--- a/src/utils/queryChartData.ts
+++ b/src/utils/queryChartData.ts
@@ -39,6 +39,8 @@ export const queryChartData = {
     { o: 'Service', d: 'serviceInstanceThroughput', c: 'ChartTrace', t: 'Running ServiceInstance', w: 3, h: 250 },
     { o: 'Service', d: 'servicePercent', c: 'ChartLine', t: 'Service Response Time Percentile', w: 3, h: 250 },
     { o: 'Service', d: 'serviceSlowEndpoint', c: 'ChartSlow', t: 'Service Slow Endpoint', w: 3, h: 250 },
+    { o: 'Service', d: 'serviceApdexScore', c: 'ChartLine', t: 'Service ApdexScore', w: 3, h: 250},
+    { o: 'Service', d: 'serviceApdexScore', c: 'ChartNum', t: 'Service Avg ApdexScore', w: 3, h: 250},
     // Endpoint
     { o: 'ServiceEndpoint', d: 'endpointResponseTime', c: 'ChartNum', t: 'Endpoint Avg ResponseTime', w: 3, h: 250 },
     { o: 'ServiceEndpoint', d: 'endpointThroughput', c: 'ChartNum', t: 'Endpoint Avg Throughput', w: 3, h: 250 },
diff --git a/src/views/components/dashboard/charts/chart-num.vue b/src/views/components/dashboard/charts/chart-num.vue
index 6a82961..8030af3 100644
--- a/src/views/components/dashboard/charts/chart-num.vue
+++ b/src/views/components/dashboard/charts/chart-num.vue
@@ -34,7 +34,7 @@ export default class ChartNum extends Vue {
     return data.reduce((acc: number, val: number) => acc + val, 0) / data.length;
   }
   get unit() {
-    let unit = 'ms';
+    let unit = 'ms' as string | null;
     if (
       this.i.d === 'databaseThroughput' ||
       this.i.d === 'serviceThroughput' ||
@@ -51,6 +51,9 @@ export default class ChartNum extends Vue {
     ) {
       unit = '%';
     }
+    if (this.i.d === 'serviceApdexScore') {
+      unit = null;
+    }
     return unit;
   }
 }
diff --git a/src/views/components/dashboard/dashboard-comp.vue b/src/views/components/dashboard/dashboard-comp.vue
index 2c777b3..7faeca8 100644
--- a/src/views/components/dashboard/dashboard-comp.vue
+++ b/src/views/components/dashboard/dashboard-comp.vue
@@ -66,7 +66,7 @@ export default class DashboardComp extends Vue {
       Database: [],
     };
     this.rocketComps.data[this.compType].forEach((i: any) => {
-      temp[i.o].push(i);
+      temp[i.o] && temp[i.o].push(i);
     });
     return temp;
   }