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
7d2dcdc9
Commit
7d2dcdc9
authored
Nov 12, 2020
by
Igor Drozdov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include aggregated git-write usage counts
It counts how many unique users triggered push, design or wiki events
parent
03e30155
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
2 deletions
+25
-2
changelogs/unreleased/id-track-git-write-operations.yml
changelogs/unreleased/id-track-git-write-operations.yml
+5
-0
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+2
-1
lib/gitlab/usage_data_counters/known_events/common.yml
lib/gitlab/usage_data_counters/known_events/common.yml
+3
-0
lib/gitlab/usage_data_counters/track_unique_events.rb
lib/gitlab/usage_data_counters/track_unique_events.rb
+11
-0
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+4
-1
No files found.
changelogs/unreleased/id-track-git-write-operations.yml
0 → 100644
View file @
7d2dcdc9
---
title
:
Include aggregated git-write usage counts
merge_request
:
47511
author
:
type
:
added
lib/gitlab/usage_data.rb
View file @
7d2dcdc9
...
...
@@ -765,7 +765,8 @@ module Gitlab
data
=
{
action_monthly_active_users_project_repo:
Gitlab
::
UsageDataCounters
::
TrackUniqueEvents
::
PUSH_ACTION
,
action_monthly_active_users_design_management:
Gitlab
::
UsageDataCounters
::
TrackUniqueEvents
::
DESIGN_ACTION
,
action_monthly_active_users_wiki_repo:
Gitlab
::
UsageDataCounters
::
TrackUniqueEvents
::
WIKI_ACTION
action_monthly_active_users_wiki_repo:
Gitlab
::
UsageDataCounters
::
TrackUniqueEvents
::
WIKI_ACTION
,
action_monthly_active_users_git_write:
Gitlab
::
UsageDataCounters
::
TrackUniqueEvents
::
GIT_WRITE_ACTION
}
data
.
each
do
|
key
,
event
|
...
...
lib/gitlab/usage_data_counters/known_events/common.yml
View file @
7d2dcdc9
...
...
@@ -121,6 +121,9 @@
-
name
:
project_action
category
:
source_code
aggregation
:
daily
-
name
:
git_write_action
category
:
source_code
aggregation
:
daily
-
name
:
merge_request_action
category
:
source_code
aggregation
:
daily
...
...
lib/gitlab/usage_data_counters/track_unique_events.rb
View file @
7d2dcdc9
...
...
@@ -8,6 +8,9 @@ module Gitlab
PUSH_ACTION
=
:project_action
MERGE_REQUEST_ACTION
=
:merge_request_action
GIT_WRITE_ACTIONS
=
[
WIKI_ACTION
,
DESIGN_ACTION
,
PUSH_ACTION
].
freeze
GIT_WRITE_ACTION
=
:git_write_action
ACTION_TRANSFORMATIONS
=
HashWithIndifferentAccess
.
new
({
wiki:
{
created:
WIKI_ACTION
,
...
...
@@ -41,6 +44,8 @@ module Gitlab
return
unless
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
known_event?
(
transformed_action
.
to_s
)
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
track_event
(
author_id
,
transformed_action
.
to_s
,
time
)
track_git_write_action
(
author_id
,
transformed_action
,
time
)
end
def
count_unique_events
(
event_action
:,
date_from
:,
date_to
:)
...
...
@@ -64,6 +69,12 @@ module Gitlab
def
valid_action?
(
action
)
Event
.
actions
.
key?
(
action
)
end
def
track_git_write_action
(
author_id
,
transformed_action
,
time
)
return
unless
GIT_WRITE_ACTIONS
.
include?
(
transformed_action
)
Gitlab
::
UsageDataCounters
::
HLLRedisCounter
.
track_event
(
author_id
,
GIT_WRITE_ACTION
,
time
)
end
end
end
end
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
7d2dcdc9
...
...
@@ -1085,6 +1085,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
let
(
:user1
)
{
build
(
:user
,
id:
1
)
}
let
(
:user2
)
{
build
(
:user
,
id:
2
)
}
let
(
:user3
)
{
build
(
:user
,
id:
3
)
}
let
(
:user4
)
{
build
(
:user
,
id:
4
)
}
before
do
counter
=
Gitlab
::
UsageDataCounters
::
TrackUniqueEvents
...
...
@@ -1099,6 +1100,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
counter
.
track_event
(
event_action: :pushed
,
event_target:
project
,
author_id:
4
,
time:
time
-
3
.
days
)
counter
.
track_event
(
event_action: :created
,
event_target:
wiki
,
author_id:
3
)
counter
.
track_event
(
event_action: :created
,
event_target:
design
,
author_id:
3
)
counter
.
track_event
(
event_action: :created
,
event_target:
design
,
author_id:
4
)
counter
=
Gitlab
::
UsageDataCounters
::
EditorUniqueCounter
...
...
@@ -1118,9 +1120,10 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
it
'returns the distinct count of user actions within the specified time period'
do
expect
(
described_class
.
action_monthly_active_users
(
time_period
)).
to
eq
(
{
action_monthly_active_users_design_management:
1
,
action_monthly_active_users_design_management:
2
,
action_monthly_active_users_project_repo:
3
,
action_monthly_active_users_wiki_repo:
1
,
action_monthly_active_users_git_write:
4
,
action_monthly_active_users_web_ide_edit:
2
,
action_monthly_active_users_sfe_edit:
2
,
action_monthly_active_users_snippet_editor_edit:
2
,
...
...
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