Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e5a7d1da
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 搜索 >>
提交
e5a7d1da
编写于
7月 05, 2017
作者:
R
Rémy Coutable
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve Features API and its docs and add a Changelog item
Signed-off-by:
N
Rémy Coutable
<
remy@rymai.me
>
上级
00ac76cc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
48 addition
and
19 deletion
+48
-19
changelogs/unreleased/33929-allow-to-enable-perf-bar-for-a-group.yml
...unreleased/33929-allow-to-enable-perf-bar-for-a-group.yml
+4
-0
doc/administration/monitoring/performance/performance_bar.md
doc/administration/monitoring/performance/performance_bar.md
+9
-4
doc/api/features.md
doc/api/features.md
+2
-2
doc/development/feature_flags.md
doc/development/feature_flags.md
+2
-1
lib/api/features.rb
lib/api/features.rb
+17
-12
spec/requests/api/features_spec.rb
spec/requests/api/features_spec.rb
+14
-0
未找到文件。
changelogs/unreleased/33929-allow-to-enable-perf-bar-for-a-group.yml
0 → 100644
浏览文件 @
e5a7d1da
---
title
:
Allow to enable the performance bar per user or Feature group
merge_request
:
12362
author
:
doc/administration/monitoring/performance/performance_bar.md
浏览文件 @
e5a7d1da
# Performance Bar
>**Note:**
Available since GitLab 9.4.
Available since GitLab 9.4. For installations from source you'll have to
configure it yourself.
A Performance Bar can be displayed, to dig into the performance of a page. When
activated, it looks as follows:
...
...
@@ -22,8 +23,9 @@ It allows you to:
## Enable the Performance Bar
By default, the Performance Bar is disabled. You can enable it either for a
given feature group or user.
By default, the Performance Bar is disabled. You can enable it for a group
and/or users. Note that it's possible to enable it for a group and for
individual users at the same time.
1.
Edit
`/etc/gitlab/gitlab.rb`
1.
Find the following line, and set it to the group's
**full path**
that should
...
...
@@ -47,7 +49,10 @@ The `performance_team` feature group maps to the group specified by the
curl --data "feature_group=performance_team" --data "value=true" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/features/performance_bar
```
### Enable for a specific user
### Enable for specific users
It's possible to enable the Performance Bar for specific users in addition to a
group, or even instead of a group:
```
curl --data "user=my_username" --data "value=true" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/features/performance_bar
...
...
doc/api/features.md
浏览文件 @
e5a7d1da
...
...
@@ -61,8 +61,8 @@ POST /features/:name
|
`feature_group`
| string | no | A Feature group name |
|
`user`
| string | no | A GitLab username |
Note that
`feature_group`
and
`user`
are mutually exclusive, with
`
feature_group`
taking priority
.
Note that
you can enable or disable a feature for both a
`feature_group`
and a
`
user`
with a single API call
.
```
bash
curl
--data
"value=30"
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/features/new_library
...
...
doc/development/feature_flags.md
浏览文件 @
e5a7d1da
...
...
@@ -13,7 +13,8 @@ During runtime you can set the values for the gates via the
Starting from GitLab 9.4 we support feature groups via
[
Flipper groups
](
https://github.com/jnunemaker/flipper/blob/v0.10.2/docs/Gates.md#2-group
)
.
Feature groups must be defined statically in
`lib/feature.rb`
(in the
`.register_feature_groups`
method), but their implementation can obviously be
Feature groups must be defined statically in
`lib/feature.rb`
(in the
`.register_feature_groups`
method), but their implementation can obviously be
dynamic (querying the DB etc.). You can see how the
`performance_team`
feature
group for a concrete example.
...
...
lib/api/features.rb
浏览文件 @
e5a7d1da
...
...
@@ -14,14 +14,12 @@ module API
end
end
def
gate_target
(
params
)
if
params
[
:feature_group
]
Feature
.
group
(
params
[
:feature_group
])
elsif
params
[
:user
]
User
.
find_by_username
(
params
[
:user
])
else
gate_value
(
params
)
end
def
gate_targets
(
params
)
targets
=
[]
targets
<<
Feature
.
group
(
params
[
:feature_group
])
if
params
[
:feature_group
]
targets
<<
User
.
find_by_username
(
params
[
:user
])
if
params
[
:user
]
targets
end
end
...
...
@@ -42,18 +40,25 @@ module API
requires
:value
,
type:
String
,
desc:
'`true` or `false` to enable/disable, an integer for percentage of time'
optional
:feature_group
,
type:
String
,
desc:
'A Feature group name'
optional
:user
,
type:
String
,
desc:
'A GitLab username'
mutually_exclusive
:feature_group
,
:user
end
post
':name'
do
feature
=
Feature
.
get
(
params
[
:name
])
target
=
gate_target
(
params
)
target
s
=
gate_targets
(
params
)
value
=
gate_value
(
params
)
case
value
when
true
feature
.
enable
(
target
)
if
targets
.
present?
targets
.
each
{
|
target
|
feature
.
enable
(
target
)
}
else
feature
.
enable
end
when
false
feature
.
disable
(
target
)
if
targets
.
present?
targets
.
each
{
|
target
|
feature
.
disable
(
target
)
}
else
feature
.
disable
end
else
feature
.
enable_percentage_of_time
(
value
)
end
...
...
spec/requests/api/features_spec.rb
浏览文件 @
e5a7d1da
...
...
@@ -113,6 +113,20 @@ describe API::Features do
{
'key'
=>
'actors'
,
'value'
=>
[
"User:
#{
user
.
id
}
"
]
}
])
end
it
'creates an enabled feature for the given user and feature group when passed user=username and feature_group=perf_team'
do
post
api
(
"/features/
#{
feature_name
}
"
,
admin
),
value:
'true'
,
user:
user
.
username
,
feature_group:
'perf_team'
expect
(
response
).
to
have_http_status
(
201
)
expect
(
json_response
).
to
eq
(
'name'
=>
'my_feature'
,
'state'
=>
'conditional'
,
'gates'
=>
[
{
'key'
=>
'boolean'
,
'value'
=>
false
},
{
'key'
=>
'groups'
,
'value'
=>
[
'perf_team'
]
},
{
'key'
=>
'actors'
,
'value'
=>
[
"User:
#{
user
.
id
}
"
]
}
])
end
end
it
'creates a feature with the given percentage if passed an integer'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录