Skip to content

Commit 0fa1f42

Browse files
committed
feat: 监控trace datasource插件开发
# Reviewed, transaction id: 25595
1 parent c7220a1 commit 0fa1f42

File tree

6 files changed

+11
-63
lines changed

6 files changed

+11
-63
lines changed

src/profiling/src/datasource/datasource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export default class DashboardDatasource extends DataSourceApi<ProfilingQuery, Q
254254
title: 'Error',
255255
}));
256256
}
257-
private request<T = any>(apiUrl: string, options?: Partial<BackendSrvRequest>): Observable<T | undefined> {
257+
private request<T>(apiUrl: string, options?: Partial<BackendSrvRequest>): Observable<T | undefined> {
258258
const url = `${this.useToken ? `${this.url}/profiling/${apiUrl}` : this.baseUrl + apiUrl}`;
259259
const req = {
260260
...options,

src/trace/src/configuration/ConfigEditor.tsx

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
/*
3-
* Tencent is pleased to support the open source community by making
4-
* 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
5-
*
6-
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
7-
*
8-
* 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
9-
*
10-
* License for 蓝鲸智云PaaS平台 (BlueKing PaaS):
11-
*
12-
* ---------------------------------------------------
13-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
14-
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
15-
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
16-
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
17-
*
18-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
19-
* the Software.
20-
*
21-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
22-
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24-
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25-
* IN THE SOFTWARE.
26-
*/
271
import React from 'react';
282
import type { DataSourcePluginOptionsEditorProps } from '@grafana/data';
293
import { LegacyForms, TagsInput } from '@grafana/ui';

src/trace/src/datasource.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
21
import {
32
type DataQueryRequest,
43
type DataQueryResponse,
@@ -21,7 +20,7 @@ import type { TraceQuery } from './types';
2120
import { convertTagsFilters } from './util';
2221
import type { QueryOption } from './types/config';
2322
import { random } from 'common/utils/utils';
24-
import type { IApplication } from './types/trace';
23+
import type { IApplication, TraceResponse } from './types/trace';
2524
export enum QueryUrl {
2625
list_application = 'list_trace_application_info/',
2726
load_options = 'get_trace_field_option_values/',
@@ -141,8 +140,10 @@ export default class TraceDatasource extends DataSourceApi<TraceQuery, QueryOpti
141140
'limit',
142141
]);
143142
// remove empty properties
144-
let traceQuery = pickBy(traceInterpolated, identity);
145-
return this.request(QueryUrl.list_trace, {
143+
const traceQuery = pickBy(traceInterpolated, identity);
144+
return this.request<{
145+
data: TraceResponse[];
146+
}>(QueryUrl.list_trace, {
146147
data: {
147148
...this.getTimeRange(),
148149
app_name: getTemplateSrv().replace(target.app_name, options.scopedVars),
@@ -162,7 +163,7 @@ export default class TraceDatasource extends DataSourceApi<TraceQuery, QueryOpti
162163
}).pipe(
163164
map(data => {
164165
return {
165-
data: [createTableFrame(target.app_name!, data.data || [], this.instanceSettings)],
166+
data: [createTableFrame(target.app_name!, data?.data || [], this.instanceSettings)],
166167
};
167168
}),
168169
);
@@ -183,7 +184,7 @@ export default class TraceDatasource extends DataSourceApi<TraceQuery, QueryOpti
183184
}
184185

185186
applyVariables(query: TraceQuery, scopedVars: ScopedVars) {
186-
let expandedQuery = { ...query };
187+
const expandedQuery = { ...query };
187188
const template = getTemplateSrv();
188189
return {
189190
...expandedQuery,
@@ -228,7 +229,7 @@ export default class TraceDatasource extends DataSourceApi<TraceQuery, QueryOpti
228229
}
229230

230231
getTimeRange(): { start_time: number; end_time: number } {
231-
const range = (getTemplateSrv() as any).timeRange;
232+
const range = getTemplateSrv().timeRange;
232233
return {
233234
start_time: range.from.unix(),
234235
end_time: range.to.unix(),
@@ -254,7 +255,7 @@ export default class TraceDatasource extends DataSourceApi<TraceQuery, QueryOpti
254255
}),
255256
);
256257
}
257-
private request<T = any>(apiUrl: string, options?: Partial<BackendSrvRequest>): Observable<T | undefined> {
258+
private request<T>(apiUrl: string, options?: Partial<BackendSrvRequest>): Observable<T | undefined> {
258259
const url = `${this.useToken ? `${this.url}/trace/${apiUrl}` : this.baseUrl + apiUrl}`;
259260
const req = {
260261
...options,

src/trace/src/dependencyGraphTransform.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
21
import {
32
type DataFrame,
43
type DataQueryResponse,
@@ -71,7 +70,7 @@ function convertDependenciesToGraph(dependencies: any[]): DataFrame[] {
7170
addServiceNode(dependency.child, servicesByName);
7271

7372
edges.push({
74-
[Fields.id]: dependency.parent + '--' + dependency.child,
73+
[Fields.id]: `${dependency.parent}--${dependency.child}`,
7574
[Fields.target]: dependency.child,
7675
[Fields.source]: dependency.parent,
7776
[Fields.mainStat]: dependency.callCount,

src/trace/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
21
import type { DataQuery } from '@grafana/data';
32
export type TraceKeyValuePair = {
43
key: string;

src/trace/src/types/config.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
/*
2-
* Tencent is pleased to support the open source community by making
3-
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
4-
*
5-
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
6-
*
7-
* 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
8-
*
9-
* License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
10-
*
11-
* ---------------------------------------------------
12-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13-
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
14-
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15-
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16-
*
17-
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
18-
* the Software.
19-
*
20-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
21-
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23-
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24-
* IN THE SOFTWARE.
25-
*/
261
import type { DataSourceJsonData } from '@grafana/data';
272

283
// config editor 数据

0 commit comments

Comments
 (0)