Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
GitLab
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
需求
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
测试用例
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
洞察
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
gitlab-cn
GitLab
提交
8e22b5fc
提交
8e22b5fc
编辑于
1 year ago
作者:
Sarah Yasonik
提交者:
syasonik
1 year ago
浏览文件
操作
下载
补丁
差异文件
Combine json-schemas for metrics into a single file
上级
d07b2044
No related branches found
No related tags found
无相关合并请求
变更
3
隐藏空白变更内容
行内
左右并排
显示
3 个更改的文件
config/metrics/schema/base.json
+21
-4
21 个添加, 4 个删除
config/metrics/schema/base.json
lib/gitlab/tracking/event_definition.rb
+1
-1
1 个添加, 1 个删除
lib/gitlab/tracking/event_definition.rb
lib/gitlab/usage/metric_definition.rb
+3
-21
3 个添加, 21 个删除
lib/gitlab/usage/metric_definition.rb
有
25 个添加
和
26 个删除
config/metrics/schema/base.json
+
21
−
4
浏览文件 @
8e22b5fc
...
@@ -71,18 +71,21 @@
...
@@ -71,18 +71,21 @@
"type"
:
[
"type"
:
[
"string"
,
"string"
,
"null"
"null"
]
],
"format"
:
"uri"
},
},
"removed_by_url"
:
{
"removed_by_url"
:
{
"type"
:
[
"type"
:
[
"string"
,
"string"
,
"null"
"null"
]
],
"format"
:
"uri"
},
},
"repair_issue_url"
:
{
"repair_issue_url"
:
{
"type"
:
[
"type"
:
[
"string"
"string"
]
],
"format"
:
"uri"
},
},
"options"
:
{
"options"
:
{
"type"
:
"object"
"type"
:
"object"
...
@@ -166,5 +169,19 @@
...
@@ -166,5 +169,19 @@
"value_json_schema"
:
{
"value_json_schema"
:
{
"type"
:
"string"
"type"
:
"string"
}
}
}
},
"allOf"
:
[
{
"$ref"
:
"internal_events.json"
},
{
"$ref"
:
"redis_hll.json"
},
{
"$ref"
:
"redis.json"
},
{
"$ref"
:
"status.json"
}
]
}
}
此差异已折叠。
点击以展开。
lib/gitlab/tracking/event_definition.rb
+
1
−
1
浏览文件 @
8e22b5fc
...
@@ -6,7 +6,7 @@ module Tracking
...
@@ -6,7 +6,7 @@ module Tracking
class
EventDefinition
class
EventDefinition
EVENT_SCHEMA_PATH
=
Rails
.
root
.
join
(
'config'
,
'events'
,
'schema.json'
)
EVENT_SCHEMA_PATH
=
Rails
.
root
.
join
(
'config'
,
'events'
,
'schema.json'
)
SCHEMA
=
::
JSONSchemer
.
schema
(
Pathname
.
new
(
EVENT_SCHEMA_PATH
)
)
SCHEMA
=
::
JSONSchemer
.
schema
(
EVENT_SCHEMA_PATH
)
attr_reader
:path
attr_reader
:path
attr_reader
:attributes
attr_reader
:attributes
...
...
此差异已折叠。
点击以展开。
lib/gitlab/usage/metric_definition.rb
+
3
−
21
浏览文件 @
8e22b5fc
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
module
Gitlab
module
Gitlab
module
Usage
module
Usage
class
MetricDefinition
class
MetricDefinition
METRIC_SCHEMA_PATH
=
Rails
.
root
.
join
(
'config'
,
'metrics'
,
'schema'
,
'**'
,
'*.json'
)
METRIC_SCHEMA_PATH
=
Rails
.
root
.
join
(
'config'
,
'metrics'
,
'schema'
,
'base.json'
)
SCHEMA
=
::
JSONSchemer
.
schema
(
METRIC_SCHEMA_PATH
)
AVAILABLE_STATUSES
=
%w[active broken]
.
to_set
.
freeze
AVAILABLE_STATUSES
=
%w[active broken]
.
to_set
.
freeze
VALID_SERVICE_PING_STATUSES
=
%w[active broken]
.
to_set
.
freeze
VALID_SERVICE_PING_STATUSES
=
%w[active broken]
.
to_set
.
freeze
...
@@ -60,7 +61,7 @@ def has_json_schema?
...
@@ -60,7 +61,7 @@ def has_json_schema?
end
end
def
validation_errors
def
validation_errors
errors
.
map
do
|
error
|
SCHEMA
.
validate
(
attributes
.
deep_stringify_keys
)
.
map
do
|
error
|
<<~
ERROR_MSG
<<~
ERROR_MSG
--------------- VALIDATION ERROR ---------------
--------------- VALIDATION ERROR ---------------
Metric file:
#{
path
}
Metric file:
#{
path
}
...
@@ -116,12 +117,6 @@ def context_for(key_path)
...
@@ -116,12 +117,6 @@ def context_for(key_path)
definitions
[
key_path
]
&
.
to_context
definitions
[
key_path
]
&
.
to_context
end
end
def
schemers
@schemers
||=
Dir
[
METRIC_SCHEMA_PATH
].
map
do
|
path
|
::
JSONSchemer
.
schema
(
Pathname
.
new
(
path
))
end
end
def
dump_metrics_yaml
def
dump_metrics_yaml
@metrics_yaml
||=
definitions
.
values
.
map
(
&
:to_h
).
map
(
&
:deep_stringify_keys
).
to_yaml
@metrics_yaml
||=
definitions
.
values
.
map
(
&
:to_h
).
map
(
&
:deep_stringify_keys
).
to_yaml
end
end
...
@@ -159,19 +154,6 @@ def load_all_from_path!(definitions, glob_path)
...
@@ -159,19 +154,6 @@ def load_all_from_path!(definitions, glob_path)
private
private
def
errors
result
=
[]
self
.
class
.
schemers
.
each
do
|
schemer
|
# schemer.validate returns an Enumerator object
schemer
.
validate
(
attributes
.
deep_stringify_keys
).
each
do
|
error
|
result
<<
error
end
end
result
end
def
method_missing
(
method
,
*
args
)
def
method_missing
(
method
,
*
args
)
attributes
[
method
]
||
super
attributes
[
method
]
||
super
end
end
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录