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 2018/07/27 05:39:53 UTC
[incubator-skywalking] branch 6.0 updated: v6 query protocol.
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch 6.0
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/6.0 by this push:
new 282b593 v6 query protocol.
282b593 is described below
commit 282b59312bade113f1ab35a0aed71b286cc94a8d
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Fri Jul 27 13:39:01 2018 +0800
v6 query protocol.
---
.../{common.graphql => common.graphqls} | 14 +++
.../{overview.graphql => jvm.graphqls} | 38 +++----
.../{metric.graphql => metric.graphqls} | 20 ++--
.../{overview.graphql => overview.graphqls} | 25 ++++-
.../{topology.graphql => topology.graphqls} | 0
.../src/main/resources/ui-graphql-v6/trace.graphql | 0
.../main/resources/ui-graphql-v6/trace.graphqls | 118 +++++++++++++++++++++
.../apm/ui/protocol/GraphQLv6ScriptTest.java | 55 ++++++++++
8 files changed, 242 insertions(+), 28 deletions(-)
diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/common.graphql b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/common.graphqls
similarity index 91%
rename from apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/common.graphql
rename to apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/common.graphqls
index d1cf270..b0a8785 100644
--- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/common.graphql
+++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/common.graphqls
@@ -60,6 +60,11 @@ enum Step {
SECOND
}
+enum Order {
+ ASC
+ DES
+}
+
input Pagination {
# pageNum starts in 1, the default is 1.
pageNum: Int
@@ -68,3 +73,12 @@ input Pagination {
needTotal: Boolean
}
+enum Language {
+ # For not language based agent, the language is impossible to tell.
+ UNKNOWN
+ JAVA
+ DOTNET
+ NODEJS
+ PYTHON
+ RUBY
+}
diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/overview.graphql b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/jvm.graphqls
similarity index 57%
copy from apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/overview.graphql
copy to apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/jvm.graphqls
index 6998658..eb098d4 100644
--- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/overview.graphql
+++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/jvm.graphqls
@@ -14,32 +14,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Query the cluster brief based on the given duration
-type ClusterBrief {
- numOfService: Int!
- numOfServiceInstance: Int!
- numOfDatabase: Int!
- numOfCache: Int!
- numOfMQ: Int!
+type CPUTrend {
+ cost: [Int!]!
}
-# Query the trend of alarm rate based on the given duration
-type AlarmTrend {
- numOfAlarmRate: [Int]!
+# The gc trend represents the numbers and time of Garbage Collector execution
+type GCTrend {
+ youngGCCount: [Int!]!
+ oldGCount: [Int!]!
+ youngGCTime: [Int!]!
+ oldGCTime: [Int!]!
}
-type Service {
- id: ID!
- name: String!
-}
-
-type ServiceInstance {
-
+# The memory used and max limit in heap and noheap space.
+type MemoryTrend {
+ heap: [Int!]!
+ maxHeap: [Int!]!
+ noheap: [Int!]!
+ maxNoheap: [Int!]!
}
extend type Query {
- getGlobalBrief(duration: Duration!): ClusterBrief
- getAlarmTrend(duration: Duration!): AlarmTrend
-
- getAllService(duration: Duration!): [Service!]!
+ getJVMCPUTrend(serviceInstanceId: ID!, duration: Duration!): CPUTrend
+ getJVMGCTrend(serviceInstanceId: ID!, duration: Duration!): GCTrend
+ getJVMMemoryTrend(serviceInstanceId: ID!, duration: Duration!): MemoryTrend
}
\ No newline at end of file
diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/metric.graphql b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/metric.graphqls
similarity index 88%
rename from apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/metric.graphql
rename to apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/metric.graphqls
index c0de3a7..f63cc15 100644
--- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/metric.graphql
+++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/metric.graphqls
@@ -23,12 +23,6 @@ input MetricCondition {
# Id in this metric type.
# In the above case, the id should be endpoint id.
id: ID
- topN: TopN
-}
-
-# TopN filter
-input TopN {
- n: Int!
}
type LinearIntValues {
@@ -60,7 +54,21 @@ type Thermodynamic {
axisYStep: Int!
}
+# Match the metric by name, order by metric value(such as: avg, percent)
+input MetricTopNCondition {
+ name: String!
+ topN: Int!
+ order: Order!
+}
+
+type MetricEntity {
+ name: String!
+ id: ID!
+ value: Int!
+}
+
extend type Query {
getLinearIntValues(metric: MetricCondition!, duration: Duration!): LinearIntValues
getThermodynamic(metric: MetricCondition!, duration: Duration!): Thermodynamic
+ getTopN(metric: MetricTopNCondition!): [MetricEntity!]!
}
\ No newline at end of file
diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/overview.graphql b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/overview.graphqls
similarity index 64%
rename from apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/overview.graphql
rename to apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/overview.graphqls
index 6998658..42ad5de 100644
--- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/overview.graphql
+++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/overview.graphqls
@@ -34,12 +34,35 @@ type Service {
}
type ServiceInstance {
+ id: ID!
+ name: String!
+ attributes: [Attribute!]!
+ language: Language!
+}
+
+type Attribute {
+ name: String!
+ value: String!
+}
+type Endpoint {
+ id: ID!
+ name: String!
}
extend type Query {
getGlobalBrief(duration: Duration!): ClusterBrief
getAlarmTrend(duration: Duration!): AlarmTrend
- getAllService(duration: Duration!): [Service!]!
+ # Service related meta info.
+ getAllServices(duration: Duration!): [Service!]!
+ searchServices(duration: Duration!, keyword: String!): [Service!]!
+
+ # Service intance query
+ getServiceInstances(duration: Duration!, id: ID!): [ServiceInstance!]!
+
+ # Endpoint query
+ # Consider there are huge numbers of endpoint,
+ # must use endpoint owner's service id, keyword and top N filter to do query.
+ searchEndpoint(keyword: String!, serviceId: ID!, topNFilter: MetricTopNCondition!): [Endpoint!]!
}
\ No newline at end of file
diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/topology.graphql b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/topology.graphqls
similarity index 100%
rename from apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/topology.graphql
rename to apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/topology.graphqls
diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/trace.graphql b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/trace.graphql
deleted file mode 100644
index e69de29..0000000
diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/trace.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/trace.graphqls
new file mode 100644
index 0000000..72ccf98
--- /dev/null
+++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql-v6/trace.graphqls
@@ -0,0 +1,118 @@
+# 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.
+
+# The list of traces
+type TraceBrief {
+ traces: [BasicTrace!]!
+ total: Int!
+}
+
+# Trace basic info
+type BasicTrace {
+ segmentId: String!
+ operationNames: [String!]!
+ duration: Int!
+ start: String!
+ isError: Boolean
+ traceIds: [String!]!
+}
+
+# Represent the conditions used for query TraceBrief
+input TraceQueryCondition {
+ # The value of 0 means all application.
+ applicationId: Int
+ traceId: String
+ operationName: String
+ # The time range of traces started
+ queryDuration: Duration
+ # The mix time of trace
+ minTraceDuration: Int
+ # The max time of trace
+ maxTraceDuration: Int
+ traceState: TraceState!
+ queryOrder: QueryOrder!
+ paging: Pagination!
+}
+
+enum TraceState {
+ ALL
+ SUCCESS
+ ERROR
+}
+
+enum QueryOrder {
+ BY_START_TIME
+ BY_DURATION
+}
+
+# The trace represents a distributed trace, includes all segments and spans.
+type Trace {
+ spans: [Span!]!
+}
+
+type Span {
+ traceId: ID!
+ segmentId: ID!
+ spanId: Int!
+ parentSpanId: Int!
+ refs: [Ref!]!
+ applicationCode: String!
+ startTime: Long!
+ endTime: Long!
+ operationName: String
+ # There are three span types: Local, Entry and Exit
+ type: String!
+ # Peer network id, e.g. host+port, ip+port
+ peer: String
+ component: String
+ isError: Boolean
+ # There are 5 layers: Unknown, Database, RPCFramework, Http, MQ and Cache
+ layer: String
+ tags: [KeyValue!]!
+ logs: [LogEntity!]!
+}
+
+# Ref represents the link between the segment and its parents.
+# The parent(ref) may not exists, which means batch process.
+# The UI should display a list, representing the other trace IDs.
+type Ref {
+ traceId: ID!
+ parentSegmentId: ID!
+ parentSpanId: Int!
+ # Ref type represents why did the ref happen.
+ # Include: 1) CrossProcess 2) CrossThread
+ type: RefType!
+}
+
+enum RefType {
+ CROSS_PROCESS,
+ CROSS_THREAD
+}
+
+type KeyValue {
+ key: String!
+ value: String
+}
+
+type LogEntity {
+ time: Long!
+ data: [KeyValue!]
+}
+
+extend type Query {
+ queryBasicTraces(condition: TraceQueryCondition): TraceBrief
+ queryTrace(traceId: ID!): Trace
+}
diff --git a/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLv6ScriptTest.java b/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLv6ScriptTest.java
new file mode 100644
index 0000000..71cead4
--- /dev/null
+++ b/apm-protocol/apm-ui-protocol/src/test/java/org/apache/skywalking/apm/ui/protocol/GraphQLv6ScriptTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ *
+ */
+
+package org.apache.skywalking.apm.ui.protocol;
+
+import graphql.schema.idl.EchoingWiringFactory;
+import graphql.schema.idl.RuntimeWiring;
+import graphql.schema.idl.SchemaGenerator;
+import graphql.schema.idl.SchemaParser;
+import graphql.schema.idl.TypeDefinitionRegistry;
+import java.io.File;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class GraphQLv6ScriptTest {
+ @Test
+ public void assertScriptFormat() {
+ SchemaParser schemaParser = new SchemaParser();
+ SchemaGenerator schemaGenerator = new SchemaGenerator();
+
+ TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry();
+ typeRegistry.merge(schemaParser.parse(loadSchema("common.graphqls")));
+ typeRegistry.merge(schemaParser.parse(loadSchema("trace.graphqls")));
+ typeRegistry.merge(schemaParser.parse(loadSchema("metric.graphqls")));
+ typeRegistry.merge(schemaParser.parse(loadSchema("overview.graphqls")));
+ typeRegistry.merge(schemaParser.parse(loadSchema("topology.graphqls")));
+ typeRegistry.merge(schemaParser.parse(loadSchema("jvm.graphqls")));
+ RuntimeWiring wiring = buildRuntimeWiring();
+ assertTrue(schemaGenerator.makeExecutableSchema(typeRegistry, wiring).getAllTypesAsList().size() > 0);
+ }
+
+ private File loadSchema(final String s) {
+ return new File(GraphQLScriptTest.class.getClassLoader().getResource("ui-graphql-v6/" + s).getFile());
+ }
+
+ private RuntimeWiring buildRuntimeWiring() {
+ return RuntimeWiring.newRuntimeWiring().wiringFactory(new EchoingWiringFactory()).build();
+ }
+}