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
95dd6e9e
Commit
95dd6e9e
authored
Feb 24, 2022
by
Allen Cook
Committed by
Shinya Maeda
Feb 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add analytics to detect deployment jobs being executed
Changelog: added
parent
41da2c3d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
125 additions
and
1 deletion
+125
-1
app/models/ci/build.rb
app/models/ci/build.rb
+8
-0
app/models/concerns/ci/has_deployment_name.rb
app/models/concerns/ci/has_deployment_name.rb
+15
-0
app/workers/ci/build_finished_worker.rb
app/workers/ci/build_finished_worker.rb
+1
-0
config/feature_flags/development/job_deployment_count.yml
config/feature_flags/development/job_deployment_count.yml
+8
-0
config/metrics/counts_28d/20220202160126_ci_users_executing_deployment_job_monthly.yml
...20202160126_ci_users_executing_deployment_job_monthly.yml
+26
-0
config/metrics/counts_7d/20220202160120_ci_users_executing_deployment_job_weekly.yml
...220202160120_ci_users_executing_deployment_job_weekly.yml
+26
-0
lib/gitlab/usage_data_counters/known_events/ci_users.yml
lib/gitlab/usage_data_counters/known_events/ci_users.yml
+5
-0
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
.../lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
+2
-1
spec/models/concerns/ci/has_deployment_name_spec.rb
spec/models/concerns/ci/has_deployment_name_spec.rb
+34
-0
No files found.
app/models/ci/build.rb
View file @
95dd6e9e
...
@@ -10,6 +10,8 @@ module Ci
...
@@ -10,6 +10,8 @@ module Ci
include
Presentable
include
Presentable
include
Importable
include
Importable
include
Ci
::
HasRef
include
Ci
::
HasRef
include
HasDeploymentName
extend
::
Gitlab
::
Utils
::
Override
extend
::
Gitlab
::
Utils
::
Override
BuildArchivedError
=
Class
.
new
(
StandardError
)
BuildArchivedError
=
Class
.
new
(
StandardError
)
...
@@ -35,6 +37,8 @@ module Ci
...
@@ -35,6 +37,8 @@ module Ci
DEGRADATION_THRESHOLD_VARIABLE_NAME
=
'DEGRADATION_THRESHOLD'
DEGRADATION_THRESHOLD_VARIABLE_NAME
=
'DEGRADATION_THRESHOLD'
RUNNERS_STATUS_CACHE_EXPIRATION
=
1
.
minute
RUNNERS_STATUS_CACHE_EXPIRATION
=
1
.
minute
DEPLOYMENT_NAMES
=
%w[deploy release rollout]
.
freeze
has_one
:deployment
,
as: :deployable
,
class_name:
'Deployment'
has_one
:deployment
,
as: :deployable
,
class_name:
'Deployment'
has_one
:pending_state
,
class_name:
'Ci::BuildPendingState'
,
inverse_of: :build
has_one
:pending_state
,
class_name:
'Ci::BuildPendingState'
,
inverse_of: :build
has_one
:queuing_entry
,
class_name:
'Ci::PendingBuild'
,
foreign_key: :build_id
has_one
:queuing_entry
,
class_name:
'Ci::PendingBuild'
,
foreign_key: :build_id
...
@@ -1123,6 +1127,10 @@ module Ci
...
@@ -1123,6 +1127,10 @@ module Ci
.
include?
(
exit_code
)
.
include?
(
exit_code
)
end
end
def
track_deployment_usage
Gitlab
::
Utils
::
UsageData
.
track_usage_event
(
'ci_users_executing_deployment_job'
,
user_id
)
if
user_id
.
present?
&&
count_user_deployment?
end
protected
protected
def
run_status_commit_hooks!
def
run_status_commit_hooks!
...
...
app/models/concerns/ci/has_deployment_name.rb
0 → 100644
View file @
95dd6e9e
# frozen_string_literal: true
module
Ci
module
HasDeploymentName
extend
ActiveSupport
::
Concern
def
count_user_deployment?
Feature
.
enabled?
(
:job_deployment_count
)
&&
deployment_name?
end
def
deployment_name?
self
.
class
::
DEPLOYMENT_NAMES
.
any?
{
|
n
|
name
.
downcase
.
include?
(
n
)
}
end
end
end
app/workers/ci/build_finished_worker.rb
View file @
95dd6e9e
...
@@ -39,6 +39,7 @@ module Ci
...
@@ -39,6 +39,7 @@ module Ci
# We execute these async as these are independent operations.
# We execute these async as these are independent operations.
BuildHooksWorker
.
perform_async
(
build
.
id
)
BuildHooksWorker
.
perform_async
(
build
.
id
)
ChatNotificationWorker
.
perform_async
(
build
.
id
)
if
build
.
pipeline
.
chat?
ChatNotificationWorker
.
perform_async
(
build
.
id
)
if
build
.
pipeline
.
chat?
build
.
track_deployment_usage
if
build
.
failed?
&&
!
build
.
auto_retry_expected?
if
build
.
failed?
&&
!
build
.
auto_retry_expected?
::
Ci
::
MergeRequests
::
AddTodoWhenBuildFailsWorker
.
perform_async
(
build
.
id
)
::
Ci
::
MergeRequests
::
AddTodoWhenBuildFailsWorker
.
perform_async
(
build
.
id
)
...
...
config/feature_flags/development/job_deployment_count.yml
0 → 100644
View file @
95dd6e9e
---
name
:
job_deployment_count
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79272
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/351591
milestone
:
'
14.8'
type
:
development
group
:
group::release
default_enabled
:
false
config/metrics/counts_28d/20220202160126_ci_users_executing_deployment_job_monthly.yml
0 → 100644
View file @
95dd6e9e
---
key_path
:
redis_hll_counters.ci_users.ci_users_executing_deployment_job_monthly
description
:
Monthly counts of times users have executed deployment jobs
product_section
:
ops
product_stage
:
release
product_group
:
group::release
product_category
:
continuous_delivery
value_type
:
number
status
:
active
milestone
:
"
14.8"
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79272
time_frame
:
28d
data_source
:
redis_hll
data_category
:
optional
instrumentation_class
:
RedisHLLMetric
performance_indicator_type
:
[]
options
:
events
:
-
ci_users_executing_deployment_job
distribution
:
-
ce
-
ee
tier
:
-
free
-
premium
-
ultimate
config/metrics/counts_7d/20220202160120_ci_users_executing_deployment_job_weekly.yml
0 → 100644
View file @
95dd6e9e
---
key_path
:
redis_hll_counters.ci_users.ci_users_executing_deployment_job_weekly
description
:
Weekly counts of times users have executed deployment jobs
product_section
:
ops
product_stage
:
release
product_group
:
group::release
product_category
:
continuous_delivery
value_type
:
number
status
:
active
milestone
:
"
14.8"
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79272
time_frame
:
7d
data_source
:
redis_hll
data_category
:
optional
instrumentation_class
:
RedisHLLMetric
performance_indicator_type
:
[]
options
:
events
:
-
ci_users_executing_deployment_job
distribution
:
-
ce
-
ee
tier
:
-
free
-
premium
-
ultimate
lib/gitlab/usage_data_counters/known_events/ci_users.yml
0 → 100644
View file @
95dd6e9e
-
name
:
ci_users_executing_deployment_job
category
:
ci_users
redis_slot
:
ci_users
aggregation
:
weekly
feature_flag
:
job_deployment_count
spec/lib/gitlab/usage_data_counters/hll_redis_counter_spec.rb
View file @
95dd6e9e
...
@@ -51,7 +51,8 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
...
@@ -51,7 +51,8 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
'network_policies'
,
'network_policies'
,
'geo'
,
'geo'
,
'growth'
,
'growth'
,
'work_items'
'work_items'
,
'ci_users'
)
)
end
end
end
end
...
...
spec/models/concerns/ci/has_deployment_name_spec.rb
0 → 100644
View file @
95dd6e9e
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Ci
::
HasDeploymentName
do
describe
'deployment_name?'
do
let
(
:build
)
{
create
(
:ci_build
)
}
subject
{
build
.
branch?
}
it
'does detect deployment names'
do
build
.
name
=
'deployment'
expect
(
build
.
deployment_name?
).
to
be_truthy
end
it
'does detect partial deployment names'
do
build
.
name
=
'do a really cool deploy'
expect
(
build
.
deployment_name?
).
to
be_truthy
end
it
'does not detect non-deployment names'
do
build
.
name
=
'testing'
expect
(
build
.
deployment_name?
).
to
be_falsy
end
it
'is case insensitive'
do
build
.
name
=
'DEPLOY'
expect
(
build
.
deployment_name?
).
to
be_truthy
end
end
end
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