Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
67bc8f8b
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
67bc8f8b
编写于
11月 19, 2020
作者:
wu-sheng
提交者:
GitHub
11月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Provide `listMetrics` GraphQL query service. (#5866)
* Provide `listMetrics` GraphQL query service. * Update chagnelog.
上级
d6c9926e
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
130 addition
and
11 deletion
+130
-11
CHANGES.md
CHANGES.md
+1
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricDefinition.java
...he/skywalking/oap/server/core/query/MetricDefinition.java
+44
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricsMetadataQueryService.java
...ng/oap/server/core/query/MetricsMetadataQueryService.java
+21
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java
...skywalking/oap/server/core/source/DefaultScopeDefine.java
+28
-0
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/ValueColumnMetadata.java
...p/server/core/storage/annotation/ValueColumnMetadata.java
+14
-2
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/StorageModels.java
...ywalking/oap/server/core/storage/model/StorageModels.java
+8
-7
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/storage/query/MetricsQueryUtilTest.java
...g/oap/server/core/storage/query/MetricsQueryUtilTest.java
+2
-1
oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java
...e/skywalking/oap/query/graphql/resolver/MetricsQuery.java
+11
-0
oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
...in/query-graphql-plugin/src/main/resources/query-protocol
+1
-1
未找到文件。
CHANGES.md
浏览文件 @
67bc8f8b
...
...
@@ -27,6 +27,7 @@ Release Notes.
*
Add the thread pool to the Kafka fetcher to increase the performance.
*
Add
`contain`
and
`not contain`
OPS in OAL.
*
Add Envoy ALS analyzer based on metadata exchange.
*
Add
`listMetrics`
GraphQL query.
*
Support keeping collecting the slowly segments in the sampling mechanism.
*
Support choose files to active the meter analyzer.
*
Support nested class definition in the Service, ServiceInstance, Endpoint, ServiceRelation, and ServiceInstanceRelation sources.
...
...
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricDefinition.java
0 → 100644
浏览文件 @
67bc8f8b
/*
* 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.oap.server.core.query
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
org.apache.skywalking.oap.server.core.query.enumeration.MetricsType
;
/**
* Define the metrics provided in the OAP server.
*
* @since 8.3.0
*/
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public
class
MetricDefinition
{
private
String
name
;
private
MetricsType
type
;
/**
* Catalog includes SERVICE_CATALOG,SERVICE_INSTANCE_CATALOG,ENDPOINT_CATALOG,
* SERVICE_RELATION_CATALOG,SERVICE_INSTANCE_RELATION_CATALOG_NAME,ENDPOINT_RELATION_CATALOG_NAME
*/
private
String
catalog
;
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricsMetadataQueryService.java
浏览文件 @
67bc8f8b
...
...
@@ -18,8 +18,12 @@
package
org.apache.skywalking.oap.server.core.query
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
org.apache.skywalking.apm.util.StringUtil
;
import
org.apache.skywalking.oap.server.core.query.enumeration.MetricsType
;
import
org.apache.skywalking.oap.server.core.source.DefaultScopeDefine
;
import
org.apache.skywalking.oap.server.core.storage.annotation.ValueColumnMetadata
;
import
org.apache.skywalking.oap.server.library.module.Service
;
...
...
@@ -48,4 +52,21 @@ public class MetricsMetadataQueryService implements Service {
return
MetricsType
.
UNKNOWN
;
}
}
public
List
<
MetricDefinition
>
listMetrics
(
String
regex
)
{
return
ValueColumnMetadata
.
INSTANCE
.
getAllMetadata
()
.
entrySet
()
.
stream
()
.
filter
(
metadata
->
StringUtil
.
isNotEmpty
(
regex
)
?
metadata
.
getKey
().
matches
(
regex
)
:
true
)
.
map
(
metadata
->
new
MetricDefinition
(
metadata
.
getKey
(),
typeOfMetrics
(
metadata
.
getKey
()),
DefaultScopeDefine
.
catalogOf
(
metadata
.
getValue
().
getScopeId
())
)
)
.
collect
(
Collectors
.
toList
());
}
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/DefaultScopeDefine.java
浏览文件 @
67bc8f8b
...
...
@@ -295,6 +295,34 @@ public class DefaultScopeDefine {
return
ENDPOINT_RELATION_CATALOG
.
containsKey
(
scopeId
);
}
/**
* Get the catalog string name of the given scope
*
* @param scope id of the source scope.
* @return literal string name of the catalog owning the scope.
*/
public
static
String
catalogOf
(
int
scope
)
{
if
(
inServiceCatalog
(
scope
))
{
return
SERVICE_CATALOG_NAME
;
}
if
(
inServiceInstanceCatalog
(
scope
))
{
return
SERVICE_INSTANCE_CATALOG_NAME
;
}
if
(
inEndpointCatalog
(
scope
))
{
return
ENDPOINT_CATALOG_NAME
;
}
if
(
inServiceRelationCatalog
(
scope
))
{
return
SERVICE_RELATION_CATALOG_NAME
;
}
if
(
inServiceInstanceRelationCatalog
(
scope
))
{
return
SERVICE_INSTANCE_RELATION_CATALOG_NAME
;
}
if
(
inEndpointRelationCatalog
(
scope
))
{
return
ENDPOINT_RELATION_CATALOG_NAME
;
}
return
"UNKNOWN"
;
}
/**
* Get the default columns defined in Scope. All those columns will forward to persistent entity.
*
...
...
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/annotation/ValueColumnMetadata.java
浏览文件 @
67bc8f8b
...
...
@@ -41,8 +41,9 @@ public enum ValueColumnMetadata {
String
valueCName
,
Column
.
ValueDataType
dataType
,
Function
function
,
int
defaultValue
)
{
mapping
.
putIfAbsent
(
modelName
,
new
ValueColumn
(
valueCName
,
dataType
,
function
,
defaultValue
));
int
defaultValue
,
int
scopeId
)
{
mapping
.
putIfAbsent
(
modelName
,
new
ValueColumn
(
valueCName
,
dataType
,
function
,
defaultValue
,
scopeId
));
}
/**
...
...
@@ -63,10 +64,20 @@ public enum ValueColumnMetadata {
return
findColumn
(
metricsName
).
defaultValue
;
}
/**
* @return metric metadata if found
*/
public
Optional
<
ValueColumn
>
readValueColumnDefinition
(
String
metricsName
)
{
return
Optional
.
ofNullable
(
mapping
.
get
(
metricsName
));
}
/**
* @return all metrics metadata.
*/
public
Map
<
String
,
ValueColumn
>
getAllMetadata
()
{
return
mapping
;
}
private
ValueColumn
findColumn
(
String
metricsName
)
{
ValueColumn
column
=
mapping
.
get
(
metricsName
);
if
(
column
==
null
)
{
...
...
@@ -82,5 +93,6 @@ public enum ValueColumnMetadata {
private
final
Column
.
ValueDataType
dataType
;
private
final
Function
function
;
private
final
int
defaultValue
;
private
final
int
scopeId
;
}
}
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/StorageModels.java
浏览文件 @
67bc8f8b
...
...
@@ -56,7 +56,7 @@ public class StorageModels implements IModelManager, ModelCreator, ModelManipula
List
<
ModelColumn
>
modelColumns
=
new
ArrayList
<>();
List
<
ExtraQueryIndex
>
extraQueryIndices
=
new
ArrayList
<>();
retrieval
(
aClass
,
storage
.
getModelName
(),
modelColumns
,
extraQueryIndices
);
retrieval
(
aClass
,
storage
.
getModelName
(),
modelColumns
,
extraQueryIndices
,
scopeId
);
Model
model
=
new
Model
(
storage
.
getModelName
(),
modelColumns
,
extraQueryIndices
,
scopeId
,
...
...
@@ -91,10 +91,11 @@ public class StorageModels implements IModelManager, ModelCreator, ModelManipula
/**
* Read model column metadata based on the class level definition.
*/
private
void
retrieval
(
Class
<?>
clazz
,
String
modelName
,
List
<
ModelColumn
>
modelColumns
,
List
<
ExtraQueryIndex
>
extraQueryIndices
)
{
private
void
retrieval
(
final
Class
<?>
clazz
,
final
String
modelName
,
final
List
<
ModelColumn
>
modelColumns
,
final
List
<
ExtraQueryIndex
>
extraQueryIndices
,
final
int
scopeId
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"Analysis {} to generate Model."
,
clazz
.
getName
());
}
...
...
@@ -131,7 +132,7 @@ public class StorageModels implements IModelManager, ModelCreator, ModelManipula
if
(
column
.
dataType
().
isValue
())
{
ValueColumnMetadata
.
INSTANCE
.
putIfAbsent
(
modelName
,
column
.
columnName
(),
column
.
dataType
(),
column
.
function
(),
column
.
defaultValue
()
column
.
defaultValue
()
,
scopeId
);
}
...
...
@@ -152,7 +153,7 @@ public class StorageModels implements IModelManager, ModelCreator, ModelManipula
}
if
(
Objects
.
nonNull
(
clazz
.
getSuperclass
()))
{
retrieval
(
clazz
.
getSuperclass
(),
modelName
,
modelColumns
,
extraQueryIndices
);
retrieval
(
clazz
.
getSuperclass
(),
modelName
,
modelColumns
,
extraQueryIndices
,
scopeId
);
}
}
...
...
oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/storage/query/MetricsQueryUtilTest.java
浏览文件 @
67bc8f8b
...
...
@@ -37,6 +37,7 @@ import org.junit.runners.Parameterized;
import
static
com
.
google
.
common
.
collect
.
ImmutableMap
.
of
;
import
static
java
.
util
.
Arrays
.
asList
;
import
static
org
.
apache
.
skywalking
.
oap
.
server
.
core
.
source
.
DefaultScopeDefine
.
SERVICE
;
import
static
org
.
apache
.
skywalking
.
oap
.
server
.
core
.
storage
.
annotation
.
Column
.
ValueDataType
.
LABELED_VALUE
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
core
.
Is
.
is
;
...
...
@@ -108,7 +109,7 @@ public class MetricsQueryUtilTest {
@Before
public
void
setup
()
{
ValueColumnMetadata
.
INSTANCE
.
putIfAbsent
(
MODULE_NAME
,
"value"
,
LABELED_VALUE
,
Function
.
None
,
DEFAULT_VALUE
MODULE_NAME
,
"value"
,
LABELED_VALUE
,
Function
.
None
,
DEFAULT_VALUE
,
SERVICE
);
}
...
...
oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetricsQuery.java
浏览文件 @
67bc8f8b
...
...
@@ -26,6 +26,7 @@ import java.util.List;
import
org.apache.skywalking.oap.server.core.CoreModule
;
import
org.apache.skywalking.oap.server.core.analysis.metrics.DataTable
;
import
org.apache.skywalking.oap.server.core.query.AggregationQueryService
;
import
org.apache.skywalking.oap.server.core.query.MetricDefinition
;
import
org.apache.skywalking.oap.server.core.query.MetricsMetadataQueryService
;
import
org.apache.skywalking.oap.server.core.query.MetricsQueryService
;
import
org.apache.skywalking.oap.server.core.query.PointOfTime
;
...
...
@@ -99,6 +100,16 @@ public class MetricsQuery implements GraphQLQueryResolver {
return
getMetricsMetadataQueryService
().
typeOfMetrics
(
name
);
}
/**
* Get the list of all available metrics in the current OAP server.
*
* @param regex to filter the metrics by name, if existing.
* @return all available metrics.
*/
public
List
<
MetricDefinition
>
listMetrics
(
String
regex
)
{
return
getMetricsMetadataQueryService
().
listMetrics
(
regex
);
}
/**
* Read metrics single value in the duration of required metrics
*/
...
...
query-protocol
@
d3608e86
比较
77afd814
...
d3608e86
Subproject commit
77afd814040c5532e5e4a68f5ef1694a80dad0c4
Subproject commit
d3608e86f7c9aaf54aa4ad2c8d2afd09d0680dd6
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录