Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
d13ae9c2
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d13ae9c2
编写于
9月 05, 2018
作者:
S
Sean McGivern
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle statement timeouts in usage ping
上级
df1a9d67
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
74 addition
and
47 deletion
+74
-47
changelogs/unreleased/45938-postgres-timeout-when-counting-number-of-ci-builds-for-usage-ping.yml
...eout-when-counting-number-of-ci-builds-for-usage-ping.yml
+5
-0
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+53
-47
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+16
-0
未找到文件。
changelogs/unreleased/45938-postgres-timeout-when-counting-number-of-ci-builds-for-usage-ping.yml
0 → 100644
浏览文件 @
d13ae9c2
---
title
:
Handle database statement timeouts in usage ping
merge_request
:
21523
author
:
type
:
fixed
lib/gitlab/usage_data.rb
浏览文件 @
d13ae9c2
...
...
@@ -22,7 +22,7 @@ module Gitlab
hostname:
Gitlab
.
config
.
gitlab
.
host
,
version:
Gitlab
::
VERSION
,
installation_type:
Gitlab
::
INSTALLATION_TYPE
,
active_user_count:
User
.
active
.
count
,
active_user_count:
count
(
User
.
active
)
,
recorded_at:
Time
.
now
,
edition:
'CE'
}
...
...
@@ -34,51 +34,51 @@ module Gitlab
def
system_usage_data
{
counts:
{
assignee_lists:
List
.
assignee
.
count
,
boards:
Board
.
count
,
ci_builds:
::
Ci
::
Build
.
count
,
ci_internal_pipelines:
::
Ci
::
Pipeline
.
internal
.
count
,
ci_external_pipelines:
::
Ci
::
Pipeline
.
external
.
count
,
ci_pipeline_config_auto_devops:
::
Ci
::
Pipeline
.
auto_devops_source
.
count
,
ci_pipeline_config_repository:
::
Ci
::
Pipeline
.
repository_source
.
count
,
ci_runners:
::
Ci
::
Runner
.
count
,
ci_triggers:
::
Ci
::
Trigger
.
count
,
ci_pipeline_schedules:
::
Ci
::
PipelineSchedule
.
count
,
auto_devops_enabled:
::
ProjectAutoDevops
.
enabled
.
count
,
auto_devops_disabled:
::
ProjectAutoDevops
.
disabled
.
count
,
deploy_keys:
DeployKey
.
count
,
deployments:
Deployment
.
count
,
environments:
::
Environment
.
count
,
clusters:
::
Clusters
::
Cluster
.
count
,
clusters_enabled:
::
Clusters
::
Cluster
.
enabled
.
count
,
clusters_disabled:
::
Clusters
::
Cluster
.
disabled
.
count
,
clusters_platforms_gke:
::
Clusters
::
Cluster
.
gcp_installed
.
enabled
.
count
,
clusters_platforms_user:
::
Clusters
::
Cluster
.
user_provided
.
enabled
.
count
,
clusters_applications_helm:
::
Clusters
::
Applications
::
Helm
.
installed
.
count
,
clusters_applications_ingress:
::
Clusters
::
Applications
::
Ingress
.
installed
.
count
,
clusters_applications_prometheus:
::
Clusters
::
Applications
::
Prometheus
.
installed
.
count
,
clusters_applications_runner:
::
Clusters
::
Applications
::
Runner
.
installed
.
count
,
in_review_folder:
::
Environment
.
in_review_folder
.
count
,
groups:
Group
.
count
,
issues:
Issue
.
count
,
keys:
Key
.
count
,
label_lists:
List
.
label
.
count
,
labels:
Label
.
count
,
lfs_objects:
LfsObject
.
count
,
merge_requests:
MergeRequest
.
count
,
milestone_lists:
List
.
milestone
.
count
,
milestones:
Milestone
.
count
,
notes:
Note
.
count
,
pages_domains:
PagesDomain
.
count
,
projects:
Project
.
count
,
projects_imported_from_github:
Project
.
where
(
import_type:
'github'
).
count
,
protected_branches:
ProtectedBranch
.
count
,
releases:
Release
.
count
,
remote_mirrors:
RemoteMirror
.
count
,
snippets:
Snippet
.
count
,
todos:
Todo
.
count
,
uploads:
Upload
.
count
,
web_hooks:
WebHook
.
count
assignee_lists:
count
(
List
.
assignee
)
,
boards:
count
(
Board
)
,
ci_builds:
count
(
::
Ci
::
Build
)
,
ci_internal_pipelines:
count
(
::
Ci
::
Pipeline
.
internal
)
,
ci_external_pipelines:
count
(
::
Ci
::
Pipeline
.
external
)
,
ci_pipeline_config_auto_devops:
count
(
::
Ci
::
Pipeline
.
auto_devops_source
)
,
ci_pipeline_config_repository:
count
(
::
Ci
::
Pipeline
.
repository_source
)
,
ci_runners:
count
(
::
Ci
::
Runner
)
,
ci_triggers:
count
(
::
Ci
::
Trigger
)
,
ci_pipeline_schedules:
count
(
::
Ci
::
PipelineSchedule
)
,
auto_devops_enabled:
count
(
::
ProjectAutoDevops
.
enabled
)
,
auto_devops_disabled:
count
(
::
ProjectAutoDevops
.
disabled
)
,
deploy_keys:
count
(
DeployKey
)
,
deployments:
count
(
Deployment
)
,
environments:
count
(
::
Environment
)
,
clusters:
count
(
::
Clusters
::
Cluster
)
,
clusters_enabled:
count
(
::
Clusters
::
Cluster
.
enabled
)
,
clusters_disabled:
count
(
::
Clusters
::
Cluster
.
disabled
)
,
clusters_platforms_gke:
count
(
::
Clusters
::
Cluster
.
gcp_installed
.
enabled
)
,
clusters_platforms_user:
count
(
::
Clusters
::
Cluster
.
user_provided
.
enabled
)
,
clusters_applications_helm:
count
(
::
Clusters
::
Applications
::
Helm
.
installed
)
,
clusters_applications_ingress:
count
(
::
Clusters
::
Applications
::
Ingress
.
installed
)
,
clusters_applications_prometheus:
count
(
::
Clusters
::
Applications
::
Prometheus
.
installed
)
,
clusters_applications_runner:
count
(
::
Clusters
::
Applications
::
Runner
.
installed
)
,
in_review_folder:
count
(
::
Environment
.
in_review_folder
)
,
groups:
count
(
Group
)
,
issues:
count
(
Issue
)
,
keys:
count
(
Key
)
,
label_lists:
count
(
List
.
label
)
,
labels:
count
(
Label
)
,
lfs_objects:
count
(
LfsObject
)
,
merge_requests:
count
(
MergeRequest
)
,
milestone_lists:
count
(
List
.
milestone
)
,
milestones:
count
(
Milestone
)
,
notes:
count
(
Note
)
,
pages_domains:
count
(
PagesDomain
)
,
projects:
count
(
Project
)
,
projects_imported_from_github:
count
(
Project
.
where
(
import_type:
'github'
))
,
protected_branches:
count
(
ProtectedBranch
)
,
releases:
count
(
Release
)
,
remote_mirrors:
count
(
RemoteMirror
)
,
snippets:
count
(
Snippet
)
,
todos:
count
(
Todo
)
,
uploads:
count
(
Upload
)
,
web_hooks:
count
(
WebHook
)
}.
merge
(
services_usage
)
}
end
...
...
@@ -120,9 +120,15 @@ module Gitlab
PrometheusService
:
:projects_prometheus_active
}
results
=
Service
.
unscoped
.
where
(
type:
types
.
keys
,
active:
true
).
group
(
:type
).
count
results
=
count
(
Service
.
unscoped
.
where
(
type:
types
.
keys
,
active:
true
).
group
(
:type
),
fallback:
Hash
.
new
(
-
1
))
results
.
each_with_object
({})
{
|
(
key
,
value
),
response
|
response
[
types
[
key
.
to_sym
]]
=
value
}
end
def
count
(
relation
,
fallback:
-
1
)
relation
.
count
rescue
ActiveRecord
::
StatementInvalid
fallback
end
end
end
end
spec/lib/gitlab/usage_data_spec.rb
浏览文件 @
d13ae9c2
...
...
@@ -166,4 +166,20 @@ describe Gitlab::UsageData do
expect
(
subject
[
:recorded_at
]).
to
be_a
(
Time
)
end
end
describe
'#count'
do
let
(
:relation
)
{
double
(
:relation
)
}
it
'returns the count when counting succeeds'
do
allow
(
relation
).
to
receive
(
:count
).
and_return
(
1
)
expect
(
described_class
.
count
(
relation
)).
to
eq
(
1
)
end
it
'returns the fallback value when counting fails'
do
allow
(
relation
).
to
receive
(
:count
).
and_raise
(
ActiveRecord
::
StatementInvalid
.
new
(
''
))
expect
(
described_class
.
count
(
relation
,
fallback:
15
)).
to
eq
(
15
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录