提交 282b5931 编写于 作者: wu-sheng's avatar wu-sheng

v6 query protocol.

上级 23488dac
......@@ -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
}
# 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.
type CPUTrend {
cost: [Int!]!
}
# The gc trend represents the numbers and time of Garbage Collector execution
type GCTrend {
youngGCCount: [Int!]!
oldGCount: [Int!]!
youngGCTime: [Int!]!
oldGCTime: [Int!]!
}
# The memory used and max limit in heap and noheap space.
type MemoryTrend {
heap: [Int!]!
maxHeap: [Int!]!
noheap: [Int!]!
maxNoheap: [Int!]!
}
extend type Query {
getJVMCPUTrend(serviceInstanceId: ID!, duration: Duration!): CPUTrend
getJVMGCTrend(serviceInstanceId: ID!, duration: Duration!): GCTrend
getJVMMemoryTrend(serviceInstanceId: ID!, duration: Duration!): MemoryTrend
}
\ No newline at end of file
......@@ -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
......@@ -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
# 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
}
/*
* 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();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册