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
10616a22
Commit
10616a22
authored
Aug 24, 2021
by
Avielle Wolfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix step histogram label usage
The labels need to be passed to `#observe`
parent
34810d37
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
24 deletions
+20
-24
lib/gitlab/ci/pipeline/chain/command.rb
lib/gitlab/ci/pipeline/chain/command.rb
+2
-4
lib/gitlab/ci/pipeline/metrics.rb
lib/gitlab/ci/pipeline/metrics.rb
+10
-6
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
+2
-2
spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb
spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb
+3
-9
spec/lib/gitlab/ci/pipeline/metrics_spec.rb
spec/lib/gitlab/ci/pipeline/metrics_spec.rb
+3
-3
No files found.
lib/gitlab/ci/pipeline/chain/command.rb
View file @
10616a22
...
...
@@ -88,10 +88,8 @@ module Gitlab
end
def
observe_step_duration
(
step_class
,
duration
)
step
=
step_class
.
name
.
underscore
.
tr
(
'/'
,
'_'
)
metrics
.
pipeline_creation_step_duration_histogram
(
step
)
.
observe
({},
duration
.
seconds
)
metrics
.
pipeline_creation_step_duration_histogram
.
observe
({
step:
step_class
.
name
},
duration
.
seconds
)
end
def
observe_creation_duration
(
duration
)
...
...
lib/gitlab/ci/pipeline/metrics.rb
View file @
10616a22
...
...
@@ -4,6 +4,8 @@ module Gitlab
module
Ci
module
Pipeline
class
Metrics
extend
Gitlab
::
Utils
::
StrongMemoize
def
self
.
pipeline_creation_duration_histogram
name
=
:gitlab_ci_pipeline_creation_duration_seconds
comment
=
'Pipeline creation duration'
...
...
@@ -13,13 +15,15 @@ module Gitlab
::
Gitlab
::
Metrics
.
histogram
(
name
,
comment
,
labels
,
buckets
)
end
def
self
.
pipeline_creation_step_duration_histogram
(
step
)
name
=
:gitlab_ci_pipeline_creation_step_duration_seconds
comment
=
'Duration of each pipeline creation step'
labels
=
{
step:
step
.
remove
(
'gitlab_ci_'
)
}
buckets
=
[
0.01
,
0.05
,
0.1
,
0.5
,
1.0
,
2.0
,
5.0
,
10.0
,
15.0
,
20.0
,
50.0
,
240.0
]
def
self
.
pipeline_creation_step_duration_histogram
strong_memoize
(
:pipeline_creation_step_histogram
)
do
name
=
:gitlab_ci_pipeline_creation_step_duration_seconds
comment
=
'Duration of each pipeline creation step'
labels
=
{
step:
nil
}
buckets
=
[
0.01
,
0.05
,
0.1
,
0.5
,
1.0
,
2.0
,
5.0
,
10.0
,
15.0
,
20.0
,
50.0
,
240.0
]
::
Gitlab
::
Metrics
.
histogram
(
name
,
comment
,
labels
,
buckets
)
::
Gitlab
::
Metrics
.
histogram
(
name
,
comment
,
labels
,
buckets
)
end
end
def
self
.
pipeline_security_orchestration_policy_processing_duration_histogram
...
...
spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
View file @
10616a22
...
...
@@ -347,10 +347,10 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Command do
histogram
=
double
(
:histogram
)
duration
=
1
.
hour
expect
(
histogram
).
to
receive
(
:observe
).
with
({},
duration
.
seconds
)
expect
(
::
Gitlab
::
Ci
::
Pipeline
::
Metrics
).
to
receive
(
:pipeline_creation_step_duration_histogram
)
.
with
(
'gitlab_ci_pipeline_chain_build'
)
.
and_return
(
histogram
)
expect
(
histogram
).
to
receive
(
:observe
)
.
with
({
step:
'Gitlab::Ci::Pipeline::Chain::Build'
},
duration
.
seconds
)
described_class
.
new
.
observe_step_duration
(
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Build
,
...
...
spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb
View file @
10616a22
...
...
@@ -64,18 +64,12 @@ RSpec.describe Gitlab::Ci::Pipeline::Chain::Sequence do
it
'adds step sequence duration to duration histogram'
do
expect
(
command
.
metrics
)
.
to
receive
(
:pipeline_creation_step_duration_histogram
)
.
with
(
'first_step'
)
.
ordered
.
and_return
(
histogram
)
expect
(
command
.
metrics
)
.
to
receive
(
:pipeline_creation_step_duration_histogram
)
.
with
(
'second_step'
)
.
ordered
.
twice
.
and_return
(
histogram
)
expect
(
histogram
).
to
receive
(
:observe
).
with
({
step:
'FirstStep'
},
any_args
).
ordered
expect
(
histogram
).
to
receive
(
:observe
).
with
({
step:
'SecondStep'
},
any_args
).
ordered
subject
.
build!
expect
(
histogram
).
to
have_received
(
:observe
).
twice
end
it
'records pipeline size by pipeline source in a histogram'
do
...
...
spec/lib/gitlab/ci/pipeline/metrics_spec.rb
View file @
10616a22
...
...
@@ -5,17 +5,17 @@ require 'spec_helper'
RSpec
.
describe
::
Gitlab
::
Ci
::
Pipeline
::
Metrics
do
describe
'.pipeline_creation_step_duration_histogram'
do
it
'adds the step to the step duration histogram'
do
step
=
'gitlab_ci_pipeline_chain_build'
described_class
.
clear_memoization
(
:pipeline_creation_step_histogram
)
expect
(
::
Gitlab
::
Metrics
).
to
receive
(
:histogram
)
.
with
(
:gitlab_ci_pipeline_creation_step_duration_seconds
,
'Duration of each pipeline creation step'
,
{
step:
'pipeline_chain_build'
},
{
step:
nil
},
[
0.01
,
0.05
,
0.1
,
0.5
,
1.0
,
2.0
,
5.0
,
10.0
,
15.0
,
20.0
,
50.0
,
240.0
]
)
described_class
.
pipeline_creation_step_duration_histogram
(
step
)
described_class
.
pipeline_creation_step_duration_histogram
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