Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
e5a7d1da
Commit
e5a7d1da
authored
Jul 05, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Features API and its docs and add a Changelog item
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
00ac76cc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
19 deletions
+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
No files found.
changelogs/unreleased/33929-allow-to-enable-perf-bar-for-a-group.yml
0 → 100644
View file @
e5a7d1da
---
title
:
Allow to enable the performance bar per user or Feature group
merge_request
:
12362
author
:
doc/administration/monitoring/performance/performance_bar.md
View file @
e5a7d1da
# Performance Bar
# Performance Bar
>**Note:**
>**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
A Performance Bar can be displayed, to dig into the performance of a page. When
activated, it looks as follows:
activated, it looks as follows:
...
@@ -22,8 +23,9 @@ It allows you to:
...
@@ -22,8 +23,9 @@ It allows you to:
## Enable the Performance Bar
## Enable the Performance Bar
By default, the Performance Bar is disabled. You can enable it either for a
By default, the Performance Bar is disabled. You can enable it for a group
given feature group or user.
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.
Edit
`/etc/gitlab/gitlab.rb`
1.
Find the following line, and set it to the group's
**full path**
that should
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
...
@@ -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
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
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
View file @
e5a7d1da
...
@@ -61,8 +61,8 @@ POST /features/:name
...
@@ -61,8 +61,8 @@ POST /features/:name
|
`feature_group`
| string | no | A Feature group name |
|
`feature_group`
| string | no | A Feature group name |
|
`user`
| string | no | A GitLab username |
|
`user`
| string | no | A GitLab username |
Note that
`feature_group`
and
`user`
are mutually exclusive, with
Note that
you can enable or disable a feature for both a
`feature_group`
and a
`
feature_group`
taking priority
.
`
user`
with a single API call
.
```
bash
```
bash
curl
--data
"value=30"
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/features/new_library
curl
--data
"value=30"
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v4/features/new_library
...
...
doc/development/feature_flags.md
View file @
e5a7d1da
...
@@ -13,7 +13,8 @@ During runtime you can set the values for the gates via the
...
@@ -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
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
)
.
[
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
dynamic (querying the DB etc.). You can see how the
`performance_team`
feature
group for a concrete example.
group for a concrete example.
...
...
lib/api/features.rb
View file @
e5a7d1da
...
@@ -14,14 +14,12 @@ module API
...
@@ -14,14 +14,12 @@ module API
end
end
end
end
def
gate_target
(
params
)
def
gate_targets
(
params
)
if
params
[
:feature_group
]
targets
=
[]
Feature
.
group
(
params
[
:feature_group
])
targets
<<
Feature
.
group
(
params
[
:feature_group
])
if
params
[
:feature_group
]
elsif
params
[
:user
]
targets
<<
User
.
find_by_username
(
params
[
:user
])
if
params
[
:user
]
User
.
find_by_username
(
params
[
:user
])
else
targets
gate_value
(
params
)
end
end
end
end
end
...
@@ -42,18 +40,25 @@ module API
...
@@ -42,18 +40,25 @@ module API
requires
:value
,
type:
String
,
desc:
'`true` or `false` to enable/disable, an integer for percentage of time'
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
:feature_group
,
type:
String
,
desc:
'A Feature group name'
optional
:user
,
type:
String
,
desc:
'A GitLab username'
optional
:user
,
type:
String
,
desc:
'A GitLab username'
mutually_exclusive
:feature_group
,
:user
end
end
post
':name'
do
post
':name'
do
feature
=
Feature
.
get
(
params
[
:name
])
feature
=
Feature
.
get
(
params
[
:name
])
target
=
gate_target
(
params
)
target
s
=
gate_targets
(
params
)
value
=
gate_value
(
params
)
value
=
gate_value
(
params
)
case
value
case
value
when
true
when
true
feature
.
enable
(
target
)
if
targets
.
present?
targets
.
each
{
|
target
|
feature
.
enable
(
target
)
}
else
feature
.
enable
end
when
false
when
false
feature
.
disable
(
target
)
if
targets
.
present?
targets
.
each
{
|
target
|
feature
.
disable
(
target
)
}
else
feature
.
disable
end
else
else
feature
.
enable_percentage_of_time
(
value
)
feature
.
enable_percentage_of_time
(
value
)
end
end
...
...
spec/requests/api/features_spec.rb
View file @
e5a7d1da
...
@@ -113,6 +113,20 @@ describe API::Features do
...
@@ -113,6 +113,20 @@ describe API::Features do
{
'key'
=>
'actors'
,
'value'
=>
[
"User:
#{
user
.
id
}
"
]
}
{
'key'
=>
'actors'
,
'value'
=>
[
"User:
#{
user
.
id
}
"
]
}
])
])
end
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
end
it
'creates a feature with the given percentage if passed an integer'
do
it
'creates a feature with the given percentage if passed an integer'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment