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/09 10:03:07 UTC
[skywalking-grafana-plugins] branch main updated (751b642 -> fbfed94)
This is an automated email from the ASF dual-hosted git repository.
qiuxiafan pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-grafana-plugins.git
from 751b642 build: update ci
new 82b1095 refactor: update metrics
new fbfed94 docs: add headers
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.asf.yaml | 38 ++++++++
.eslintrc | 16 ++++
.github/workflows/is-compatible.yml | 16 ++++
.github/workflows/nodejs.yml | 16 ++++
.github/workflows/release.yml | 16 ++++
.gitignore | 18 ++++
.nvmrc | 16 ++++
.prettierrc.js | 16 ++++
cypress/integration/01-smoke.spec.ts | 16 ++++
docker-compose.yaml | 17 ++++
jest-setup.js | 17 +++-
jest.config.js | 16 ++++
src/components/ConfigEditor.tsx | 16 ++++
src/components/QueryEditor.tsx | 16 ++++
src/constant.ts | 17 ++++
src/datasource.ts | 178 +++++++++++++++++++++--------------
src/img/logo.svg | 15 +++
src/module.ts | 17 ++++
src/plugin.json | 16 ++++
src/types.ts | 18 ++++
tsconfig.json | 16 ++++
21 files changed, 457 insertions(+), 70 deletions(-)
create mode 100644 .asf.yaml
[skywalking-grafana-plugins] 02/02: docs: add headers
Posted by qi...@apache.org.
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 fbfed9420c51e35d6327535c93c7b25ae3bec48c
Author: Fine0830 <fa...@gmail.com>
AuthorDate: Tue May 9 17:59:01 2023 +0800
docs: add headers
---
.asf.yaml | 38 ++++++++++++++++++++++++++++++++++++
.eslintrc | 16 +++++++++++++++
.github/workflows/is-compatible.yml | 16 +++++++++++++++
.github/workflows/nodejs.yml | 16 +++++++++++++++
.github/workflows/release.yml | 16 +++++++++++++++
.gitignore | 18 +++++++++++++++++
.nvmrc | 16 +++++++++++++++
.prettierrc.js | 16 +++++++++++++++
cypress/integration/01-smoke.spec.ts | 16 +++++++++++++++
docker-compose.yaml | 17 ++++++++++++++++
jest-setup.js | 17 +++++++++++++++-
jest.config.js | 16 +++++++++++++++
src/components/ConfigEditor.tsx | 16 +++++++++++++++
src/components/QueryEditor.tsx | 16 +++++++++++++++
src/constant.ts | 17 ++++++++++++++++
src/datasource.ts | 19 +++++++++++++++++-
src/img/logo.svg | 15 ++++++++++++++
src/module.ts | 17 ++++++++++++++++
src/plugin.json | 16 +++++++++++++++
src/types.ts | 18 +++++++++++++++++
tsconfig.json | 16 +++++++++++++++
21 files changed, 366 insertions(+), 2 deletions(-)
diff --git a/.asf.yaml b/.asf.yaml
new file mode 100644
index 0000000..4a7ca0c
--- /dev/null
+++ b/.asf.yaml
@@ -0,0 +1,38 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+github:
+ description: Apache SkyWalking grafana plugins
+ homepage: https://skywalking.apache.org/
+ labels:
+ - skywalking
+ - observability
+ - apm
+ - visualization
+ enabled_merge_buttons:
+ squash: true
+ merge: false
+ rebase: false
+ protected_branches:
+ main:
+ required_status_checks:
+ strict: true
+ contexts:
+ - build
+ required_pull_request_reviews:
+ dismiss_stale_reviews: true
+ required_approving_review_count: 1
diff --git a/.eslintrc b/.eslintrc
index 01e61df..0b3250a 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
{
"extends": "./.config/.eslintrc"
}
\ No newline at end of file
diff --git a/.github/workflows/is-compatible.yml b/.github/workflows/is-compatible.yml
index 289489a..54076ef 100644
--- a/.github/workflows/is-compatible.yml
+++ b/.github/workflows/is-compatible.yml
@@ -1,3 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
name: Latest Grafana API compatibility check
on: [pull_request]
diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml
index 76da805..ac0fb5a 100644
--- a/.github/workflows/nodejs.yml
+++ b/.github/workflows/nodejs.yml
@@ -1,3 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
name: CI
on:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index fd86539..d874156 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,3 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
name: Release
on:
diff --git a/.gitignore b/.gitignore
index c21ee45..97eb6f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,21 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
# Logs
logs
*.log
diff --git a/.nvmrc b/.nvmrc
index 19c7bdb..9ca7cd8 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1,17 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
16
\ No newline at end of file
diff --git a/.prettierrc.js b/.prettierrc.js
index aaa5045..0c67936 100644
--- a/.prettierrc.js
+++ b/.prettierrc.js
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
module.exports = {
// Prettier configuration provided by Grafana scaffolding
...require("./.config/.prettierrc.js")
diff --git a/cypress/integration/01-smoke.spec.ts b/cypress/integration/01-smoke.spec.ts
index ed0867d..89307d8 100644
--- a/cypress/integration/01-smoke.spec.ts
+++ b/cypress/integration/01-smoke.spec.ts
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import { e2e } from '@grafana/e2e';
e2e.scenario({
diff --git a/docker-compose.yaml b/docker-compose.yaml
index f7cb76a..eff5cee 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -1,3 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
version: '3.0'
services:
diff --git a/jest-setup.js b/jest-setup.js
index 35a700b..b3df822 100644
--- a/jest-setup.js
+++ b/jest-setup.js
@@ -1,2 +1,17 @@
-// Jest setup provided by Grafana scaffolding
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import './.config/jest-setup';
diff --git a/jest.config.js b/jest.config.js
index 79fd52a..8b4aa3a 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
// force timezone to UTC to allow tests to work regardless of local timezone
// generally used by snapshots, but can affect specific tests
process.env.TZ = 'UTC';
diff --git a/src/components/ConfigEditor.tsx b/src/components/ConfigEditor.tsx
index c1afd1c..cecc99d 100644
--- a/src/components/ConfigEditor.tsx
+++ b/src/components/ConfigEditor.tsx
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import React, { ChangeEvent } from 'react';
import { InlineField, Input, SecretInput } from '@grafana/ui';
import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
diff --git a/src/components/QueryEditor.tsx b/src/components/QueryEditor.tsx
index 7b8cdb5..643820d 100644
--- a/src/components/QueryEditor.tsx
+++ b/src/components/QueryEditor.tsx
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import React, { ChangeEvent } from 'react';
import { InlineField, Input } from '@grafana/ui';
import { QueryEditorProps } from '@grafana/data';
diff --git a/src/constant.ts b/src/constant.ts
index 7495a39..79f1658 100644
--- a/src/constant.ts
+++ b/src/constant.ts
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
export const Fragments = {
servicesTopolgy: "query queryData($serviceIds: [ID!]!, $duration: Duration!) {\n topology: getServicesTopology(serviceIds: $serviceIds, duration: $duration) {\n nodes {\n id\n name\n type\n isReal\n }\n calls {\n id\n source\n detectPoints\n target\n }\n }}",
services: "query queryServices($duration: Duration!,$keyword: String!) {\n services: getAllServices(duration: $duration, group: $keyword) {\n id\n name\n group\n layers\n }\n }",
diff --git a/src/datasource.ts b/src/datasource.ts
index 42f7e02..07f857b 100644
--- a/src/datasource.ts
+++ b/src/datasource.ts
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import defaults from 'lodash/defaults';
import {
DataQueryRequest,
@@ -24,7 +41,7 @@ import {
Node,
Recordable
} from './types';
-import {Fragments, RoutePath, TimeType, Calculations } from "./constant";
+import { Fragments, RoutePath, TimeType, Calculations } from "./constant";
export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
URL: string;
diff --git a/src/img/logo.svg b/src/img/logo.svg
index 823f4d2..e9a543f 100644
--- a/src/img/logo.svg
+++ b/src/img/logo.svg
@@ -1 +1,16 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License. -->
+
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1645353544631" class="icon" viewBox="0 0 4327 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1115" xmlns:xlink="http://www.w3.org/1999/xlink" width="845.1171875" height="200"><defs><style type="text/css"></style></defs><path d="M1739.616604 441.967094v2.334189l-70.798491 357.875925c-9.33434 46.678943-21.782943 65.351245-69.240755 65. [...]
\ No newline at end of file
diff --git a/src/module.ts b/src/module.ts
index b8231eb..40e72af 100644
--- a/src/module.ts
+++ b/src/module.ts
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import { DataSourcePlugin } from '@grafana/data';
import { DataSource } from './datasource';
import { ConfigEditor } from './components/ConfigEditor';
diff --git a/src/plugin.json b/src/plugin.json
index d3ac2fd..648f15a 100644
--- a/src/plugin.json
+++ b/src/plugin.json
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
{
"$schema": "https://raw.githubusercontent.com/grafana/grafana/master/docs/sources/developers/plugins/plugin.schema.json",
"type": "datasource",
diff --git a/src/types.ts b/src/types.ts
index 1444af5..06247d7 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
import { DataQuery, DataSourceJsonData } from '@grafana/data';
export interface MyQuery extends DataQuery {
@@ -35,6 +52,7 @@ export type MetricData = {
label: string;
calculation: string;
unit: string;
+ type: string;
}
export type Recordable = Record<string, any>;
diff --git a/tsconfig.json b/tsconfig.json
index d294745..3f2cb3b 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
{
"extends": "./.config/tsconfig.json"
}
\ No newline at end of file
[skywalking-grafana-plugins] 01/02: refactor: update metrics
Posted by qi...@apache.org.
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 82b1095a869a34d2d23b61b6020370fed74cd21e
Author: Fine0830 <fa...@gmail.com>
AuthorDate: Tue May 9 16:57:13 2023 +0800
refactor: update metrics
---
src/datasource.ts | 159 +++++++++++++++++++++++++++++++-----------------------
1 file changed, 91 insertions(+), 68 deletions(-)
diff --git a/src/datasource.ts b/src/datasource.ts
index 42a5af7..42f7e02 100644
--- a/src/datasource.ts
+++ b/src/datasource.ts
@@ -6,7 +6,8 @@ import {
DataSourceInstanceSettings,
MutableDataFrame,
FieldType,
- // FieldColorModeId,
+ ArrayVector,
+ NodeGraphDataFrameFieldNames,
} from '@grafana/data';
import { getBackendSrv, getTemplateSrv } from '@grafana/runtime';
import dayjs from "dayjs";
@@ -53,10 +54,10 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
const promises = options.targets.map(async (target) => {
const query = defaults(target, DEFAULT_QUERY);
const layer = getTemplateSrv().replace(query.layer, options.scopedVars);
- if (!layer) {
+ const serviceName = getTemplateSrv().replace(query.service, options.scopedVars);
+ if (!layer && !serviceName) {
return [];
}
- const serviceName = getTemplateSrv().replace(query.service, options.scopedVars);
const nodeMetricsStr = getTemplateSrv().replace(query.nodeMetrics, options.scopedVars);
const nodeMetrics = nodeMetricsStr ? this.parseMetrics(nodeMetricsStr) : [];
const edgeMetricsStr = getTemplateSrv().replace(query.edgeMetrics, options.scopedVars);
@@ -106,25 +107,16 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
const edgeMetricsResp: any = (edgeServerMetricsResp || edgeClientMetricsResp) ? {
data: {...edgeServerMetricsResp.data, ...edgeClientMetricsResp.data}
} : null;
- const topology = this.setTopologyMetrics({
+ const fieldTypes = this.setFieldTypes({
nodes,
calls,
nodeMetrics: nodeMetricsResp ? {...nodeMetricsResp, config: nodeMetrics} : undefined,
edgeMetrics: edgeMetricsResp ? {...edgeMetricsResp, config: edgeMetrics} : undefined,
});
- const {nodeFieldTypes, edgeFieldTypes} = this.setFieldTypes({
- nodeMetrics: nodeMetricsResp ? {...nodeMetricsResp, config: nodeMetrics} : undefined,
- edgeMetrics: edgeMetricsResp ? {...edgeMetricsResp, config: edgeMetrics} : undefined,
- });
- console.log(topology);
const nodeFrame = new MutableDataFrame({
name: 'Nodes',
refId: target.refId,
- fields: [
- { name: 'id', type: FieldType.string },
- { name: 'title', type: FieldType.string },
- ...nodeFieldTypes
- ],
+ fields: fieldTypes.nodeFieldTypes,
meta: {
preferredVisualisationType: 'nodeGraph',
}
@@ -132,22 +124,12 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
const edgeFrame = new MutableDataFrame({
name: 'Edges',
refId: target.refId,
- fields: [
- { name: 'id', type: FieldType.string },
- { name: 'source', type: FieldType.string },
- { name: 'target', type: FieldType.string },
- ...edgeFieldTypes,
- ],
+ fields: fieldTypes.edgeFieldTypes,
meta: {
preferredVisualisationType: 'nodeGraph',
}
});
- for (const node of topology.nodes) {
- nodeFrame.add({...node, title: node.name});
- }
- for (const call of topology.calls) {
- edgeFrame.add(call);
- }
+
return [nodeFrame, edgeFrame];
});
@@ -203,67 +185,108 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
return {nodes, calls}
}
- setFieldTypes(params: {nodeMetrics: Recordable, edgeMetrics: Recordable}) {
+ setFieldTypes(params: {nodes: Node[], calls: Call[], nodeMetrics: Recordable, edgeMetrics: Recordable}) {
const nodeMetrics = params.nodeMetrics || {config: [], data: {}};
const edgeMetrics = params.edgeMetrics || {config: [], data: {}};
- const nodeFieldTypes = this.getTypes(nodeMetrics);
- const edgeFieldTypes = this.getTypes(edgeMetrics);
+ if (!(params.nodes && params.calls)) {
+ return {nodeFieldTypes: [], edgeFieldTypes: []};;
+ }
+ const nodeFieldTypes = this.getNodeTypes(params.nodes || [], nodeMetrics);
+ const edgeFieldTypes = this.getEdgeTypes(params.calls || [], edgeMetrics);
return {nodeFieldTypes, edgeFieldTypes};
}
- getTypes(metrics: Recordable) {
- const types = Object.keys(metrics.data).map((k: string, index: number) => {
+ getNodeTypes(nodes: Node[], metrics: Recordable) {
+ const idField = { name: NodeGraphDataFrameFieldNames.id, type: FieldType.string, values: new ArrayVector(), config: {}};
+ const titleField = { name: NodeGraphDataFrameFieldNames.title, type: FieldType.string, values: new ArrayVector(), config: {}};
+ const mainStatField = { name: NodeGraphDataFrameFieldNames.mainStat, type: FieldType.number, values: new ArrayVector(), config: {}};
+ const secondaryStatField = { name: NodeGraphDataFrameFieldNames.secondaryStat, type: FieldType.number, values: new ArrayVector(), config: {}};
+ const detailsFields: any = [];
+ for (const [index, k] of Object.keys(metrics.data).entries()) {
const c = metrics.config.find((d: MetricData) => d.name === k) || {};
const config = {displayName: c.label, unit: c.unit};
if (index === 0) {
- return { name: 'mainstat', type: FieldType.number, config};
+ mainStatField.config = config;
+ } else if (index === 1) {
+ secondaryStatField.config = config;
+ } else {
+ detailsFields.push({
+ name: `${NodeGraphDataFrameFieldNames.detail}${k}`,
+ type: FieldType.number,
+ values: new ArrayVector(),
+ config: {displayName: `${c.label || k } ${c.unit || ''}`}
+ });
}
- if (index === 1) {
- return { name: 'secondarystat', type: FieldType.number, config};
+ }
+ for (const node of nodes) {
+ idField.values.add(node.id || '');
+ titleField.values.add(node.name);
+ for (let i = 0; i < metrics.config.length; i++) {
+ const item = metrics.config[i];
+ const m = (metrics.data[item.name].values).find((v: {id: string}) => v.id === node.id) || {isEmptyValue: true};
+ const value = m.isEmptyValue ? NaN : this.expression(Number(m.value), item.calculation);
+ if(i > 1) {
+ detailsFields[i - 2]?.values.add(Number(value));
+ } else {
+ if (i === 0) {
+ mainStatField.values.add(Number(value));
+ }
+ if (i === 1) {
+ secondaryStatField.values.add(Number(value));
+ }
+ }
}
+ }
- return { name: `detail__${k}`, type: FieldType.number, config: {displayName: c.label || k, unit: c.unit} };
- });
-
- return types;
+ return [idField, titleField, mainStatField, secondaryStatField, ...detailsFields];
}
- setTopologyMetrics(params: {nodes: Node[], calls: Call[], nodeMetrics: Recordable, edgeMetrics: Recordable}) {
- const nodeMetrics = params.nodeMetrics || {config: [], data: {}};
- const edgeMetrics = params.edgeMetrics || {config: [], data: {}};
- const nodes = params.nodes.map((next: Node) => {
- for (const [index, k] of Object.keys(nodeMetrics.data).entries()) {
- const c = nodeMetrics.config.find((d: MetricData) => d.name === k) || {};
- const m = (nodeMetrics.data[k].values).find((v: {id: string}) => v.id === next.id) || {isEmptyValue: true};
- const value = m.isEmptyValue ? NaN : this.expression(Number(m.value), c.calculation);
- if (index === 0) {
- next.mainstat = value;
- } else if (index === 1) {
- next.secondarystat = value;
- } else {
- next[`detail__${k}`] = value;
- }
+ getEdgeTypes(calls: Call[], metrics: Recordable) {
+ const idField = { name: NodeGraphDataFrameFieldNames.id, type: FieldType.string, values: new ArrayVector(), config: {}};
+ const targetField = { name: NodeGraphDataFrameFieldNames.target, type: FieldType.string, values: new ArrayVector(), config: {}};
+ const sourceField = { name: NodeGraphDataFrameFieldNames.source, type: FieldType.string, values: new ArrayVector(), config: {}};
+ const mainStatField = { name: NodeGraphDataFrameFieldNames.mainStat, type: FieldType.number, values: new ArrayVector(), config: {}};
+ const secondaryStatField = { name: NodeGraphDataFrameFieldNames.secondaryStat, type: FieldType.number, values: new ArrayVector(), config: {}};
+ const detailsFields: any = [];
+ for (const [index, k] of Object.keys(metrics.data).entries()) {
+ const c = metrics.config.find((d: MetricData) => d.name === k) || {};
+ const config = {displayName: c.label, unit: c.unit};
+ if (index === 0) {
+ mainStatField.config = config;
+ }
+ else if (index === 1) {
+ secondaryStatField.config = config;
+ } else {
+ detailsFields.push({
+ name: `${NodeGraphDataFrameFieldNames.detail}${k}`,
+ type: FieldType.number,
+ values: new ArrayVector(),
+ config: {displayName: `${c.label || k } ${c.unit || ''}`}
+ });
}
- return next;
- })
- const calls = params.calls.map((next: Call) => {
- for (const [index, k] of Object.keys(edgeMetrics.data).entries()) {
- const c = edgeMetrics.config.find((d: MetricData) => d.name === k) || {};
- const m = (edgeMetrics.data[k].values).find((v: {id: string}) => v.id === next.id) || {value: NaN};
- const value = m.isEmptyValue ? NaN : this.expression(Number(m.value), c.calculation);
- if (index === 0) {
- next.mainstat = value;
- } else if (index === 1) {
- next.secondarystat = value;
+ }
+
+ for (const call of calls) {
+ idField.values.add(call.id);
+ targetField.values.add(call.target);
+ sourceField.values.add(call.source);
+ for (let i = 0; i < metrics.config.length; i++) {
+ const item = metrics.config[i];
+ const m = (metrics.data[item.name].values).find((v: {id: string}) => v.id === call.id) || {isEmptyValue: true};
+ const value = m.isEmptyValue ? NaN : this.expression(Number(m.value), item.calculation);
+
+ if (i === 0) {
+ mainStatField.values.add(Number(value));
+ } else if (i === 1) {
+ secondaryStatField.values.add(Number(value));
} else {
- next[`detail__${k}`] = value;
+ detailsFields[i - 2]?.values.add(Number(value));
}
}
- return next;
- })
+ }
- return {nodes, calls}
+ return [idField, targetField, sourceField, mainStatField, secondaryStatField, ...detailsFields];
}
expression(val: number, calculation: string): number | string {