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
4692fa0f
Commit
4692fa0f
authored
Sep 23, 2021
by
Doug Stull
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor import metrics
- make projects_counter private - add test coverage
parent
a0ddad33
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
13 deletions
+37
-13
lib/gitlab/import/metrics.rb
lib/gitlab/import/metrics.rb
+7
-7
spec/lib/gitlab/import/metrics_spec.rb
spec/lib/gitlab/import/metrics_spec.rb
+30
-6
No files found.
lib/gitlab/import/metrics.rb
View file @
4692fa0f
...
@@ -19,13 +19,6 @@ module Gitlab
...
@@ -19,13 +19,6 @@ module Gitlab
projects_counter
.
increment
projects_counter
.
increment
end
end
def
projects_counter
@projects_counter
||=
Gitlab
::
Metrics
.
counter
(
:"
#{
importer
}
_imported_projects_total"
,
'The number of imported projects'
)
end
def
issues_counter
def
issues_counter
@issues_counter
||=
Gitlab
::
Metrics
.
counter
(
@issues_counter
||=
Gitlab
::
Metrics
.
counter
(
:"
#{
importer
}
_imported_issues_total"
,
:"
#{
importer
}
_imported_issues_total"
,
...
@@ -50,6 +43,13 @@ module Gitlab
...
@@ -50,6 +43,13 @@ module Gitlab
IMPORT_DURATION_BUCKETS
IMPORT_DURATION_BUCKETS
)
)
end
end
def
projects_counter
@projects_counter
||=
Gitlab
::
Metrics
.
counter
(
:"
#{
importer
}
_imported_projects_total"
,
'The number of imported projects'
)
end
end
end
end
end
end
end
spec/lib/gitlab/import/metrics_spec.rb
View file @
4692fa0f
...
@@ -2,20 +2,22 @@
...
@@ -2,20 +2,22 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Import
::
Metrics
do
RSpec
.
describe
Gitlab
::
Import
::
Metrics
,
:aggregate_failures
do
let
(
:importer
)
{
:test_importer
}
let
(
:importer
)
{
:test_importer
}
let
(
:project
)
{
create
(
:projec
t
)
}
let
(
:project
)
{
double
(
:project
,
created_at:
Time
.
curren
t
)
}
let
(
:histogram
)
{
double
(
:histogram
)
}
let
(
:histogram
)
{
double
(
:histogram
)
}
let
(
:counter
)
{
double
(
:counter
)
}
let
(
:counter
)
{
double
(
:counter
)
}
subject
{
described_class
.
new
(
importer
,
project
)
}
subject
{
described_class
.
new
(
importer
,
project
)
}
describe
'#report_import_time'
do
before
do
before
do
allow
(
Gitlab
::
Metrics
).
to
receive
(
:counter
)
{
counter
}
allow
(
Gitlab
::
Metrics
).
to
receive
(
:counter
)
{
counter
}
allow
(
Gitlab
::
Metrics
).
to
receive
(
:histogram
)
{
histogram
}
allow
(
counter
).
to
receive
(
:increment
)
allow
(
counter
).
to
receive
(
:increment
)
allow
(
counter
).
to
receive
(
:observe
)
end
describe
'#track_finished_import'
do
before
do
allow
(
Gitlab
::
Metrics
).
to
receive
(
:histogram
)
{
histogram
}
end
end
it
'emits importer metrics'
do
it
'emits importer metrics'
do
...
@@ -37,4 +39,26 @@ RSpec.describe Gitlab::Import::Metrics do
...
@@ -37,4 +39,26 @@ RSpec.describe Gitlab::Import::Metrics do
subject
.
track_finished_import
subject
.
track_finished_import
end
end
end
end
describe
'#issues_counter'
do
it
'creates a counter for issues'
do
expect
(
Gitlab
::
Metrics
).
to
receive
(
:counter
).
with
(
:test_importer_imported_issues_total
,
'The number of imported issues'
)
subject
.
issues_counter
end
end
describe
'#merge_requests_counter'
do
it
'creates a counter for issues'
do
expect
(
Gitlab
::
Metrics
).
to
receive
(
:counter
).
with
(
:test_importer_imported_merge_requests_total
,
'The number of imported merge (pull) requests'
)
subject
.
merge_requests_counter
end
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