You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by qi...@apache.org on 2023/05/12 06:03:02 UTC

[skywalking-grafana-plugins] branch main updated: fix: update edge metrics (#7)

This is an automated email from the ASF dual-hosted git repository.

qiuxiafan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-grafana-plugins.git


The following commit(s) were added to refs/heads/main by this push:
     new 46bbe9a  fix: update edge metrics (#7)
46bbe9a is described below

commit 46bbe9a85e35286fdb97a2d46fed259b388f81f8
Author: Fine0830 <fa...@gmail.com>
AuthorDate: Fri May 12 14:02:57 2023 +0800

    fix: update edge metrics (#7)
---
 src/datasource.ts | 3 +--
 src/types.ts      | 3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/datasource.ts b/src/datasource.ts
index 07f857b..f7835cb 100644
--- a/src/datasource.ts
+++ b/src/datasource.ts
@@ -122,7 +122,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
       const edgeServerMetricsResp = serverMetrics.length && idsS.length ? await this.queryMetrics(serverMetrics, idsS, duration) : null;
       const edgeClientMetricsResp = clientMetrics.length && idsC.length ? await this.queryMetrics(clientMetrics, idsC, duration) : null;
       const edgeMetricsResp: any = (edgeServerMetricsResp || edgeClientMetricsResp) ? {
-        data: {...edgeServerMetricsResp.data, ...edgeClientMetricsResp.data}
+        data: {...(edgeServerMetricsResp && edgeServerMetricsResp.data || {}), ...(edgeClientMetricsResp && edgeClientMetricsResp.data || {})}
       } : null;
       const fieldTypes = this.setFieldTypes({
         nodes,
@@ -283,7 +283,6 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
         });
       }
     }
-
     for (const call of calls) {
       idField.values.add(call.id);
       targetField.values.add(call.target);
diff --git a/src/types.ts b/src/types.ts
index 06247d7..c85b38a 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -15,7 +15,8 @@
  * limitations under the License.
  */
 
-import { DataQuery, DataSourceJsonData } from '@grafana/data';
+import { DataSourceJsonData } from '@grafana/data';
+import { DataQuery } from '@grafana/schema';
 
 export interface MyQuery extends DataQuery {
   layer?: string;