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
a12c5f17
Commit
a12c5f17
authored
Nov 16, 2020
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove avg_cycle_analytics from usage ping
This change removes the `avg_cycle_analytics` key from usage ping.
parent
bb7640c0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
5 additions
and
250 deletions
+5
-250
changelogs/unreleased/271538-remove-vsa-usage-ping.yml
changelogs/unreleased/271538-remove-vsa-usage-ping.yml
+5
-0
doc/development/product_analytics/usage_ping.md
doc/development/product_analytics/usage_ping.md
+0
-38
lib/gitlab/cycle_analytics/usage_data.rb
lib/gitlab/cycle_analytics/usage_data.rb
+0
-91
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+0
-7
spec/lib/gitlab/cycle_analytics/usage_data_spec.rb
spec/lib/gitlab/cycle_analytics/usage_data_spec.rb
+0
-95
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+0
-18
spec/support/helpers/usage_data_helpers.rb
spec/support/helpers/usage_data_helpers.rb
+0
-1
No files found.
changelogs/unreleased/271538-remove-vsa-usage-ping.yml
0 → 100644
View file @
a12c5f17
---
title
:
Remove avg_cycle_analytics from usage ping
merge_request
:
47812
author
:
type
:
other
doc/development/product_analytics/usage_ping.md
View file @
a12c5f17
...
...
@@ -857,44 +857,6 @@ The following is example content of the Usage Ping payload.
"version": "9.6.15",
"pg_system_id": 6842684531675334351
},
"avg_cycle_analytics": {
"issue": {
"average": 999,
"sd": 999,
"missing": 999
},
"plan": {
"average": null,
"sd": 999,
"missing": 999
},
"code": {
"average": null,
"sd": 999,
"missing": 999
},
"test": {
"average": null,
"sd": 999,
"missing": 999
},
"review": {
"average": null,
"sd": 999,
"missing": 999
},
"staging": {
"average": null,
"sd": 999,
"missing": 999
},
"production": {
"average": null,
"sd": 999,
"missing": 999
},
"total": 999
},
"analytics_unique_visits": {
"g_analytics_contribution": 999,
...
...
...
lib/gitlab/cycle_analytics/usage_data.rb
deleted
100644 → 0
View file @
bb7640c0
# frozen_string_literal: true
module
Gitlab
module
CycleAnalytics
class
UsageData
include
Gitlab
::
Utils
::
StrongMemoize
PROJECTS_LIMIT
=
10
attr_reader
:options
def
initialize
@options
=
{
from:
7
.
days
.
ago
}
end
def
projects
strong_memoize
(
:projects
)
do
projects
=
Project
.
where
.
not
(
last_activity_at:
nil
).
order
(
last_activity_at: :desc
).
limit
(
10
)
+
Project
.
where
.
not
(
last_repository_updated_at:
nil
).
order
(
last_repository_updated_at: :desc
).
limit
(
10
)
projects
=
projects
.
uniq
.
sort_by
do
|
project
|
[
project
.
last_activity_at
,
project
.
last_repository_updated_at
].
min
end
if
projects
.
size
<
10
projects
.
concat
(
Project
.
where
(
last_activity_at:
nil
,
last_repository_updated_at:
nil
).
limit
(
10
))
end
projects
.
uniq
.
first
(
10
)
end
end
def
to_json
(
*
)
total
=
0
values
=
medians_per_stage
.
each_with_object
({})
do
|
(
stage_name
,
medians
),
hsh
|
calculations
=
stage_values
(
medians
)
total
+=
calculations
.
values
.
compact
.
sum
hsh
[
stage_name
]
=
calculations
end
values
[
:total
]
=
total
{
avg_cycle_analytics:
values
}
end
private
def
medians_per_stage
projects
.
each_with_object
({})
do
|
project
,
hsh
|
::
CycleAnalytics
::
ProjectLevel
.
new
(
project
,
options:
options
).
all_medians_by_stage
.
each
do
|
stage_name
,
median
|
hsh
[
stage_name
]
||=
[]
hsh
[
stage_name
]
<<
median
end
end
end
def
stage_values
(
medians
)
medians
=
medians
.
map
(
&
:presence
).
compact
average
=
calc_average
(
medians
)
{
average:
average
,
sd:
standard_deviation
(
medians
,
average
),
missing:
projects
.
length
-
medians
.
length
}
end
def
calc_average
(
values
)
return
if
values
.
empty?
(
values
.
sum
/
values
.
length
).
to_i
end
def
standard_deviation
(
values
,
average
)
Math
.
sqrt
(
sample_variance
(
values
,
average
)).
to_i
end
def
sample_variance
(
values
,
average
)
return
0
if
values
.
length
<=
1
sum
=
values
.
inject
(
0
)
do
|
acc
,
val
|
acc
+
(
val
-
average
)
**
2
end
sum
/
(
values
.
length
-
1
)
end
end
end
end
lib/gitlab/usage_data.rb
View file @
a12c5f17
...
...
@@ -47,7 +47,6 @@ module Gitlab
.
merge
(
system_usage_data_weekly
)
.
merge
(
features_usage_data
)
.
merge
(
components_usage_data
)
.
merge
(
cycle_analytics_usage_data
)
.
merge
(
object_store_usage_data
)
.
merge
(
topology_usage_data
)
.
merge
(
usage_activity_by_stage
)
...
...
@@ -250,12 +249,6 @@ module Gitlab
}
end
def
cycle_analytics_usage_data
Gitlab
::
CycleAnalytics
::
UsageData
.
new
.
to_json
rescue
ActiveRecord
::
StatementInvalid
{
avg_cycle_analytics:
{}
}
end
# rubocop:disable CodeReuse/ActiveRecord
def
grafana_embed_usage_data
count
(
Issue
.
joins
(
'JOIN grafana_integrations USING (project_id)'
)
...
...
spec/lib/gitlab/cycle_analytics/usage_data_spec.rb
deleted
100644 → 0
View file @
bb7640c0
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
CycleAnalytics
::
UsageData
do
describe
'#to_json'
do
before
do
# Since git commits only have second precision, round up to the
# nearest second to ensure we have accurate median and standard
# deviation calculations.
current_time
=
Time
.
at
(
Time
.
now
.
to_i
)
Timecop
.
freeze
(
current_time
)
do
user
=
create
(
:user
,
:admin
)
projects
=
create_list
(
:project
,
2
,
:repository
)
projects
.
each_with_index
do
|
project
,
time
|
issue
=
create
(
:issue
,
project:
project
,
created_at:
(
time
+
1
).
hour
.
ago
)
allow_next_instance_of
(
Gitlab
::
ReferenceExtractor
)
do
|
instance
|
allow
(
instance
).
to
receive
(
:issues
).
and_return
([
issue
])
end
milestone
=
create
(
:milestone
,
project:
project
)
mr
=
create_merge_request_closing_issue
(
user
,
project
,
issue
,
commit_message:
"References
#{
issue
.
to_reference
}
"
)
pipeline
=
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
mr
.
source_branch
,
sha:
mr
.
source_branch_sha
,
head_pipeline_of:
mr
)
create_cycle
(
user
,
project
,
issue
,
mr
,
milestone
,
pipeline
)
deploy_master
(
user
,
project
,
environment:
'staging'
)
deploy_master
(
user
,
project
)
end
end
end
context
'a valid usage data result'
do
let
(
:expect_values_per_stage
)
do
{
issue:
{
average:
5400
,
sd:
2545
,
missing:
0
},
plan:
{
average:
1
,
sd:
0
,
missing:
0
},
code:
{
average:
nil
,
sd:
0
,
missing:
2
},
test:
{
average:
nil
,
sd:
0
,
missing:
2
},
review:
{
average:
0
,
sd:
0
,
missing:
0
},
staging:
{
average:
0
,
sd:
0
,
missing:
0
},
production:
{
average:
5400
,
sd:
2545
,
missing:
0
}
}
end
it
'returns the aggregated usage data of every selected project'
,
:sidekiq_might_not_need_inline
do
result
=
subject
.
to_json
expect
(
result
).
to
have_key
(
:avg_cycle_analytics
)
CycleAnalytics
::
LevelBase
::
STAGES
.
each
do
|
stage
|
expect
(
result
[
:avg_cycle_analytics
]).
to
have_key
(
stage
)
stage_values
=
result
[
:avg_cycle_analytics
][
stage
]
expected_values
=
expect_values_per_stage
[
stage
]
expected_values
.
each_pair
do
|
op
,
value
|
expect
(
stage_values
).
to
have_key
(
op
)
expect
(
stage_values
[
op
]).
to
eq
(
value
)
end
end
end
end
end
end
spec/lib/gitlab/usage_data_spec.rb
View file @
a12c5f17
...
...
@@ -840,24 +840,6 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
end
end
describe
'.cycle_analytics_usage_data'
do
subject
{
described_class
.
cycle_analytics_usage_data
}
it
'works when queries time out in new'
do
allow
(
Gitlab
::
CycleAnalytics
::
UsageData
)
.
to
receive
(
:new
).
and_raise
(
ActiveRecord
::
StatementInvalid
.
new
(
''
))
expect
{
subject
}.
not_to
raise_error
end
it
'works when queries time out in to_json'
do
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
UsageData
)
.
to
receive
(
:to_json
).
and_raise
(
ActiveRecord
::
StatementInvalid
.
new
(
''
))
expect
{
subject
}.
not_to
raise_error
end
end
describe
'.ingress_modsecurity_usage'
do
subject
{
described_class
.
ingress_modsecurity_usage
}
...
...
spec/support/helpers/usage_data_helpers.rb
View file @
a12c5f17
...
...
@@ -161,7 +161,6 @@ module UsageDataHelpers
git
gitaly
database
avg_cycle_analytics
prometheus_metrics_enabled
web_ide_clientside_preview_enabled
ingress_modsecurity_enabled
...
...
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