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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
8d4a921c
Commit
8d4a921c
authored
Jul 07, 2020
by
Alper Akgun
Committed by
Robert Speicher
Jul 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move manage stage usage activity to CE
Also updates the documentation
parent
db775720
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
52 deletions
+88
-52
changelogs/unreleased/217362-move-manage-stage-usage-activity-to-ce.yml
...eleased/217362-move-manage-stage-usage-activity-to-ce.yml
+5
-0
doc/development/telemetry/usage_ping.md
doc/development/telemetry/usage_ping.md
+12
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+2
-18
ee/spec/lib/ee/gitlab/usage_data_spec.rb
ee/spec/lib/ee/gitlab/usage_data_spec.rb
+13
-33
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+20
-1
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+36
-0
No files found.
changelogs/unreleased/217362-move-manage-stage-usage-activity-to-ce.yml
0 → 100644
View file @
8d4a921c
---
title
:
Move manage stage usage activity to CE
merge_request
:
36089
author
:
type
:
changed
doc/development/telemetry/usage_ping.md
View file @
8d4a921c
...
...
@@ -655,6 +655,18 @@ appear to be associated to any of the services running, since they all appear to
|
`projects_prometheus_active`
|
`usage_activity_by_stage`
|
`monitor`
| | EE | |
|
`projects_with_error_tracking_enabled`
|
`usage_activity_by_stage`
|
`monitor`
| | EE | |
|
`projects_with_tracing_enabled`
|
`usage_activity_by_stage`
|
`monitor`
| | EE | |
|
`events`
|
`usage_activity_by_stage`
|
`manage`
| | CE+EE | |
|
`groups`
|
`usage_activity_by_stage`
|
`manage`
| | CE+EE | |
|
`users_created_at`
|
`usage_activity_by_stage`
|
`manage`
| | CE+EE | |
|
`omniauth_providers`
|
`usage_activity_by_stage`
|
`manage`
| | CE+EE | |
|
`ldap_keys`
|
`usage_activity_by_stage`
|
`manage`
| | EE | |
|
`ldap_users`
|
`usage_activity_by_stage`
|
`manage`
| | EE | |
|
`value_stream_management_customized_group_stages`
|
`usage_activity_by_stage`
|
`manage`
| | EE | |
|
`projects_with_compliance_framework`
|
`usage_activity_by_stage`
|
`manage`
| | EE | |
|
`ldap_servers`
|
`usage_activity_by_stage`
|
`manage`
| | EE | |
|
`ldap_group_sync_enabled`
|
`usage_activity_by_stage`
|
`manage`
| | EE | |
|
`ldap_admin_sync_enabled`
|
`usage_activity_by_stage`
|
`manage`
| | EE | |
|
`group_saml_enabled`
|
`usage_activity_by_stage`
|
`manage`
| | EE | |
|
`keys`
|
`usage_activity_by_stage`
|
`create`
| | | |
|
`projects_jira_dvcs_server_active`
|
`usage_activity_by_stage`
|
`plan`
| | | |
|
`service_desk_enabled_projects`
|
`usage_activity_by_stage`
|
`plan`
| | | |
...
...
ee/lib/ee/gitlab/usage_data.rb
View file @
8d4a921c
...
...
@@ -237,17 +237,13 @@ module EE
override
:usage_activity_by_stage_manage
def
usage_activity_by_stage_manage
(
time_period
)
super
.
merge
({
events:
distinct_count
(
::
Event
.
where
(
time_period
),
:author_id
),
groups:
distinct_count
(
::
GroupMember
.
where
(
time_period
),
:user_id
),
ldap_keys:
distinct_count
(
::
LDAPKey
.
where
(
time_period
),
:user_id
),
ldap_users:
distinct_count
(
::
GroupMember
.
of_ldap_type
.
where
(
time_period
),
:user_id
),
users_created:
count
(
::
User
.
where
(
time_period
),
start:
user_minimum_id
,
finish:
user_maximum_id
),
value_stream_management_customized_group_stages:
count
(
::
Analytics
::
CycleAnalytics
::
GroupStage
.
where
(
custom:
true
)),
projects_with_compliance_framework:
count
(
::
ComplianceManagement
::
ComplianceFramework
::
ProjectSettings
),
ldap_servers:
ldap_available_servers
.
size
,
ldap_group_sync_enabled:
ldap_config_present_for_any_provider?
(
:group_base
),
ldap_admin_sync_enabled:
ldap_config_present_for_any_provider?
(
:admin_group
),
omniauth_providers:
filtered_omniauth_provider_names
.
reject
{
|
name
|
name
==
'group_saml'
},
group_saml_enabled:
omniauth_provider_names
.
include?
(
'group_saml'
)
})
end
...
...
@@ -356,24 +352,12 @@ module EE
end
# rubocop:enable CodeReuse/ActiveRecord
def
ldap_available_servers
::
Gitlab
::
Auth
::
Ldap
::
Config
.
available_servers
end
def
ldap_config_present_for_any_provider?
(
configuration_item
)
ldap_available_servers
.
any?
{
|
server_config
|
server_config
[
configuration_item
.
to_s
]
}
end
def
omniauth_provider_names
::
Gitlab
.
config
.
omniauth
.
providers
.
map
(
&
:name
)
end
# LDAP provider names are set by customers and could include
# sensitive info (server names, etc). LDAP providers normally
# don't appear in omniauth providers but filter to ensure
# no internal details leak via usage ping.
def
filtered_omniauth_provider_names
omniauth_provider_names
.
reject
{
|
name
|
name
.
starts_with?
(
'ldap'
)
}
def
ldap_available_servers
::
Gitlab
::
Auth
::
Ldap
::
Config
.
available_servers
end
end
end
...
...
ee/spec/lib/ee/gitlab/usage_data_spec.rb
View file @
8d4a921c
...
...
@@ -364,59 +364,39 @@ RSpec.describe Gitlab::UsageData do
it
'includes accurate usage_activity_by_stage data'
do
stub_config
(
ldap:
{
enabled:
true
,
servers:
ldap_server_config
},
omniauth:
{
providers:
omniauth_providers
}
{
enabled:
true
,
servers:
ldap_server_config
}
)
for_defined_days_back
do
user
=
create
(
:user
)
create
(
:event
,
author:
user
)
create
(
:group_member
,
user:
user
)
create
(
:key
,
type:
'LDAPKey'
,
user:
user
)
create
(
:group_member
,
ldap:
true
,
user:
user
)
create
(
:cycle_analytics_group_stage
)
create
(
:compliance_framework_project_setting
)
end
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage
][
:manage
]).
to
eq
(
events:
2
,
groups:
2
,
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage
][
:manage
]).
to
include
(
ldap_keys:
2
,
ldap_users:
2
,
users_created:
8
,
value_stream_management_customized_group_stages:
2
,
projects_with_compliance_framework:
2
,
ldap_servers:
2
,
ldap_group_sync_enabled:
true
,
ldap_admin_sync_enabled:
true
,
omniauth_providers:
[
'google_oauth2'
],
group_saml_enabled:
true
)
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage_monthly
][
:manage
]).
to
eq
(
events:
1
,
groups:
1
,
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage_monthly
][
:manage
]).
to
include
(
ldap_keys:
1
,
ldap_users:
1
,
users_created:
5
,
value_stream_management_customized_group_stages:
2
,
projects_with_compliance_framework:
2
,
ldap_servers:
2
,
ldap_group_sync_enabled:
true
,
ldap_admin_sync_enabled:
true
,
omniauth_providers:
[
'google_oauth2'
],
group_saml_enabled:
true
)
end
def
omniauth_providers
[
OpenStruct
.
new
(
name:
'google_oauth2'
),
OpenStruct
.
new
(
name:
'ldapmain'
),
OpenStruct
.
new
(
name:
'group_saml'
)
]
end
def
ldap_server_config
{
'main'
=>
...
...
lib/gitlab/usage_data.rb
View file @
8d4a921c
...
...
@@ -486,9 +486,16 @@ module Gitlab
end
# Omitted because no user, creator or author associated: `campaigns_imported_from_github`, `ldap_group_links`
# rubocop: disable CodeReuse/ActiveRecord
def
usage_activity_by_stage_manage
(
time_period
)
{}
{
events:
distinct_count
(
::
Event
.
where
(
time_period
),
:author_id
),
groups:
distinct_count
(
::
GroupMember
.
where
(
time_period
),
:user_id
),
users_created:
count
(
::
User
.
where
(
time_period
),
start:
user_minimum_id
,
finish:
user_maximum_id
),
omniauth_providers:
filtered_omniauth_provider_names
.
reject
{
|
name
|
name
==
'group_saml'
}
}
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
usage_activity_by_stage_monitor
(
time_period
)
...
...
@@ -596,6 +603,18 @@ module Gitlab
distinct_count
(
clusters
.
where
(
time_period
),
:user_id
)
end
# rubocop: enable CodeReuse/ActiveRecord
def
omniauth_provider_names
::
Gitlab
.
config
.
omniauth
.
providers
.
map
(
&
:name
)
end
# LDAP provider names are set by customers and could include
# sensitive info (server names, etc). LDAP providers normally
# don't appear in omniauth providers but filter to ensure
# no internal details leak via usage ping.
def
filtered_omniauth_provider_names
omniauth_provider_names
.
reject
{
|
name
|
name
.
starts_with?
(
'ldap'
)
}
end
end
end
end
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
8d4a921c
...
...
@@ -75,6 +75,42 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
)
end
end
context
'for manage'
do
it
'includes accurate usage_activity_by_stage data'
do
stub_config
(
omniauth:
{
providers:
omniauth_providers
}
)
for_defined_days_back
do
user
=
create
(
:user
)
create
(
:event
,
author:
user
)
create
(
:group_member
,
user:
user
)
end
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage
][
:manage
]).
to
include
(
events:
2
,
groups:
2
,
users_created:
Gitlab
.
ee?
?
6
:
5
,
omniauth_providers:
[
'google_oauth2'
]
)
expect
(
described_class
.
uncached_data
[
:usage_activity_by_stage_monthly
][
:manage
]).
to
include
(
events:
1
,
groups:
1
,
users_created:
Gitlab
.
ee?
?
4
:
3
,
omniauth_providers:
[
'google_oauth2'
]
)
end
def
omniauth_providers
[
OpenStruct
.
new
(
name:
'google_oauth2'
),
OpenStruct
.
new
(
name:
'ldapmain'
),
OpenStruct
.
new
(
name:
'group_saml'
)
]
end
end
end
context
'for create'
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