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/04/30 14:24:16 UTC
[skywalking-grafana-plugins] 03/03: refactor: update types
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
commit 548f163995b7af09a3e75c2b69f53482e1465a9a
Author: Fine0830 <fa...@gmail.com>
AuthorDate: Sun Apr 30 22:23:59 2023 +0800
refactor: update types
---
src/datasource.ts | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/datasource.ts b/src/datasource.ts
index 0aa5955..69e2dd7 100644
--- a/src/datasource.ts
+++ b/src/datasource.ts
@@ -12,7 +12,16 @@ import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
-import { MyQuery, MyDataSourceOptions, DEFAULT_QUERY, DurationTime, MetricData, Call, Node, Recordable } from './types';
+import {
+ MyQuery,
+ MyDataSourceOptions,
+ DEFAULT_QUERY,
+ DurationTime,
+ MetricData,
+ Call,
+ Node,
+ Recordable
+} from './types';
import {Fragments, RoutePath, TimeType } from "./constant";
export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
@@ -47,7 +56,10 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
const edgeServerMetrics = getTemplateSrv().replace(query.edgeServerMetrics, options.scopedVars);
const edgeClientMetrics = getTemplateSrv().replace(query.edgeClientMetrics, options.scopedVars);
let services = [];
- let t: any = {
+ let t: {
+ query: string;
+ variables: Recordable;
+ } = {
query: Fragments.globalTopology,
variables: {duration},
};
@@ -130,7 +142,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
return Promise.all(promises).then(data => ({ data: data[0] }));
}
- async doRequest(params?: Record<string, any>) {
+ async doRequest(params?: Recordable) {
// Do the request on proxy; the server will replace url + routePath with the url
// defined in plugin.json
const result = getBackendSrv().post(`${this.URL}${RoutePath}`, params, {headers: {
@@ -156,7 +168,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
if (!(params.nodes.length && params.calls.length)) {
return {nodes: [], calls: []}
}
- const obj = {} as Record<string, any>;
+ const obj = {} as Recordable;
const nodes = (params.nodes || []).reduce((prev: Node[], next: Node) => {
if (!obj[next.id]) {
obj[next.id] = true;