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
28a93879
Commit
28a93879
authored
Dec 22, 2021
by
Marius Bobin
Committed by
Grzegorz Bizon
Dec 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log pipeline tags size
parent
f15c5491
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
4 deletions
+69
-4
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+18
-0
config/feature_flags/development/ci_pipeline_logger_tags_count.yml
...ature_flags/development/ci_pipeline_logger_tags_count.yml
+8
-0
lib/gitlab/ci/pipeline/logger.rb
lib/gitlab/ci/pipeline/logger.rb
+12
-2
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+28
-0
spec/services/ci/create_pipeline_service/logger_spec.rb
spec/services/ci/create_pipeline_service/logger_spec.rb
+3
-2
No files found.
app/models/ci/pipeline.rb
View file @
28a93879
...
...
@@ -466,6 +466,18 @@ module Ci
statuses
.
count
(
:id
)
end
def
tags_count
if
tag_counts_enabled?
ActsAsTaggableOn
::
Tagging
.
where
(
taggable:
builds
).
count
end
end
def
distinct_tags_count
if
tag_counts_enabled?
ActsAsTaggableOn
::
Tagging
.
where
(
taggable:
builds
).
count
(
'distinct(tag_id)'
)
end
end
def
stages_names
statuses
.
order
(
:stage_idx
).
distinct
.
pluck
(
:stage
,
:stage_idx
).
map
(
&
:first
)
...
...
@@ -1340,6 +1352,12 @@ module Ci
::
Gitlab
::
Ci
::
PipelineObjectHierarchy
.
new
(
self
.
class
.
unscoped
.
where
(
id:
id
),
options:
options
)
end
def
tag_counts_enabled?
strong_memoize
(
:tag_counts_enabled
)
do
::
Feature
.
enabled?
(
:ci_pipeline_logger_tags_count
,
project
,
default_enabled: :yaml
)
end
end
end
end
...
...
config/feature_flags/development/ci_pipeline_logger_tags_count.yml
0 → 100644
View file @
28a93879
---
name
:
ci_pipeline_logger_tags_count
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/77112
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/348967
milestone
:
'
14.7'
type
:
development
group
:
group::pipeline execution
default_enabled
:
false
lib/gitlab/ci/pipeline/logger.rb
View file @
28a93879
...
...
@@ -50,11 +50,21 @@ module Gitlab
class:
self
.
class
.
name
.
to_s
,
pipeline_creation_caller:
caller
,
project_id:
project
.
id
,
pipeline_id:
pipeline
.
id
,
pipeline_persisted:
pipeline
.
persisted?
,
pipeline_source:
pipeline
.
source
,
pipeline_creation_service_duration_s:
age
}.
stringify_keys
.
merge
(
observations_hash
)
}
if
pipeline
.
persisted?
attributes
[
:pipeline_builds_tags_count
]
=
pipeline
.
tags_count
attributes
[
:pipeline_builds_distinct_tags_count
]
=
pipeline
.
distinct_tags_count
attributes
[
:pipeline_id
]
=
pipeline
.
id
end
attributes
.
compact!
attributes
.
stringify_keys!
attributes
.
merge!
(
observations_hash
)
destination
.
info
(
attributes
)
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
28a93879
...
...
@@ -4677,4 +4677,32 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
let!
(
:model
)
{
create
(
:ci_pipeline
,
user:
create
(
:user
))
}
let!
(
:parent
)
{
model
.
user
}
end
describe
'tags count'
do
let_it_be_with_refind
(
:pipeline
)
do
create
(
:ci_empty_pipeline
,
project:
project
)
end
it
{
expect
(
pipeline
.
tags_count
).
to
eq
(
0
)
}
it
{
expect
(
pipeline
.
distinct_tags_count
).
to
eq
(
0
)
}
context
'with builds'
do
before
do
create
(
:ci_build
,
pipeline:
pipeline
,
tag_list:
%w[a b]
)
create
(
:ci_build
,
pipeline:
pipeline
,
tag_list:
%w[b c]
)
end
it
{
expect
(
pipeline
.
tags_count
).
to
eq
(
4
)
}
it
{
expect
(
pipeline
.
distinct_tags_count
).
to
eq
(
3
)
}
end
context
'with the FF disabled'
do
before
do
stub_feature_flags
(
ci_pipeline_logger_tags_count:
false
)
end
it
{
expect
(
pipeline
.
tags_count
).
to
be_nil
}
it
{
expect
(
pipeline
.
distinct_tags_count
).
to
be_nil
}
end
end
end
spec/services/ci/create_pipeline_service/logger_spec.rb
View file @
28a93879
...
...
@@ -35,7 +35,9 @@ RSpec.describe Ci::CreatePipelineService do
'pipeline_creation_service_duration_s'
=>
a_kind_of
(
Numeric
),
'pipeline_creation_duration_s'
=>
counters
,
'pipeline_size_count'
=>
counters
,
'pipeline_step_gitlab_ci_pipeline_chain_seed_duration_s'
=>
counters
'pipeline_step_gitlab_ci_pipeline_chain_seed_duration_s'
=>
counters
,
'pipeline_builds_tags_count'
=>
a_kind_of
(
Numeric
),
'pipeline_builds_distinct_tags_count'
=>
a_kind_of
(
Numeric
)
}
end
...
...
@@ -81,7 +83,6 @@ RSpec.describe Ci::CreatePipelineService do
{
'pipeline_creation_caller'
=>
'Ci::CreatePipelineService'
,
'pipeline_source'
=>
'push'
,
'pipeline_id'
=>
nil
,
'pipeline_persisted'
=>
false
,
'project_id'
=>
project
.
id
,
'pipeline_creation_service_duration_s'
=>
a_kind_of
(
Numeric
),
...
...
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