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
8c4a0ada
Commit
8c4a0ada
authored
Aug 23, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add event metrics to mirrors and remote mirrors.
parent
1a5b66c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
11 deletions
+13
-11
app/models/remote_mirror.rb
app/models/remote_mirror.rb
+3
-3
app/workers/repository_update_mirror_worker.rb
app/workers/repository_update_mirror_worker.rb
+9
-3
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+1
-1
lib/gitlab/mirror.rb
lib/gitlab/mirror.rb
+0
-4
No files found.
app/models/remote_mirror.rb
View file @
8c4a0ada
...
...
@@ -43,13 +43,13 @@ class RemoteMirror < ActiveRecord::Base
state
:failed
after_transition
any
=>
:started
do
|
remote_mirror
,
_
|
Gitlab
::
M
irror
.
increment_metric
(
:remote_mirrors_running
,
'Remote mirrors running count'
)
Gitlab
::
M
etrics
.
add_event
(
:remote_mirrors_running
,
path:
remote_mirror
.
project
.
full_path
)
remote_mirror
.
update
(
last_update_started_at:
Time
.
now
)
end
after_transition
started: :finished
do
|
remote_mirror
,
_
|
Gitlab
::
M
irror
.
increment_metric
(
:remote_mirrors_finished
,
'Remote mirrors successfully finished count'
)
Gitlab
::
M
etrics
.
add_event
(
:remote_mirrors_finished
,
path:
remote_mirror
.
project
.
full_path
)
timestamp
=
Time
.
now
remote_mirror
.
update_attributes!
(
...
...
@@ -58,7 +58,7 @@ class RemoteMirror < ActiveRecord::Base
end
after_transition
started: :failed
do
|
remote_mirror
,
_
|
Gitlab
::
M
irror
.
increment_metric
(
:remote_mirrors_failed
,
'Remote mirrors failed count'
)
Gitlab
::
M
etrics
.
add_event
(
:remote_mirrors_failed
,
path:
remote_mirror
.
project
.
full_path
)
remote_mirror
.
update
(
last_update_at:
Time
.
now
)
end
...
...
app/workers/repository_update_mirror_worker.rb
View file @
8c4a0ada
...
...
@@ -46,8 +46,11 @@ class RepositoryUpdateMirrorWorker
def
start_mirror
(
project
)
if
project
.
import_start
Gitlab
::
Mirror
.
increment_metric
(
:mirrors_running
,
'Mirrors running count'
)
Rails
.
logger
.
info
(
"Mirror update for
#{
project
.
full_path
}
started. Waiting duration:
#{
project
.
mirror_waiting_duration
}
"
)
Gitlab
::
Metrics
.
add_event_with_values
(
:mirrors_running
,
{
duration:
project
.
mirror_waiting_duration
},
{
path:
project
.
full_path
})
true
else
...
...
@@ -60,14 +63,17 @@ class RepositoryUpdateMirrorWorker
error_message
=
"Mirror update for
#{
project
.
full_path
}
failed with the following message:
#{
message
}
"
project
.
mark_import_as_failed
(
error_message
)
Gitlab
::
Mirror
.
increment_metric
(
:mirrors_failed
,
'Mirrors failed count'
)
Rails
.
logger
.
error
(
error_message
)
Gitlab
::
Metrics
.
add_event
(
:mirrors_failed
,
path:
project
.
full_path
)
end
def
finish_mirror
(
project
)
project
.
import_finish
Gitlab
::
Mirror
.
increment_metric
(
:mirrors_finished
,
'Mirrors successfully finished count'
)
Rails
.
logger
.
info
(
"Mirror update for
#{
project
.
full_path
}
successfully finished. Update duration:
#{
project
.
mirror_update_duration
}
}."
)
Gitlab
::
Metrics
.
add_event_with_values
(
:mirrors_finished
,
{
duration:
project
.
mirror_update_duration
},
{
path:
project
.
full_path
})
end
end
ee/app/models/ee/project.rb
View file @
8c4a0ada
...
...
@@ -205,7 +205,7 @@ module EE
if
import?
&&
!
repository_exists?
super
elsif
mirror?
::
Gitlab
::
M
irror
.
increment_metric
(
:mirrors_scheduled
,
'Mirrors scheduled count'
)
::
Gitlab
::
M
etrics
.
add_event
(
:mirrors_scheduled
,
path:
full_path
)
job_id
=
RepositoryUpdateMirrorWorker
.
perform_async
(
self
.
id
)
log_import_activity
(
job_id
,
type: :mirror
)
...
...
lib/gitlab/mirror.rb
View file @
8c4a0ada
...
...
@@ -77,10 +77,6 @@ module Gitlab
current_application_settings
.
mirror_capacity_threshold
end
def
increment_metric
(
name
,
docstring
)
Gitlab
::
Metrics
.
counter
(
name
,
docstring
).
increment
end
private
def
update_all_mirrors_cron_job
...
...
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