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
c7b8b63e
Commit
c7b8b63e
authored
Jun 13, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds prometheus metrics to both mirroring and remote mirroring features
parent
1501d7c9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
4 deletions
+34
-4
app/models/ee/project.rb
app/models/ee/project.rb
+2
-0
app/models/remote_mirror.rb
app/models/remote_mirror.rb
+6
-0
app/workers/repository_update_mirror_worker.rb
app/workers/repository_update_mirror_worker.rb
+16
-3
app/workers/repository_update_remote_mirror_worker.rb
app/workers/repository_update_remote_mirror_worker.rb
+2
-1
changelogs/unreleased-ee/mirroring-prometheus-metrics.yml
changelogs/unreleased-ee/mirroring-prometheus-metrics.yml
+4
-0
lib/gitlab/mirror.rb
lib/gitlab/mirror.rb
+4
-0
No files found.
app/models/ee/project.rb
View file @
c7b8b63e
...
...
@@ -73,6 +73,8 @@ module EE
if
import?
&&
!
repository_exists?
super
elsif
mirror?
::
Gitlab
::
Mirror
.
increment_metric
(:
mirrors_scheduled
,
'Mirrors scheduled count'
)
RepositoryUpdateMirrorWorker
.
perform_async
(
self
.
id
)
end
end
...
...
app/models/remote_mirror.rb
View file @
c7b8b63e
...
...
@@ -46,10 +46,14 @@ class RemoteMirror < ActiveRecord::Base
state
:failed
after_transition
any
=>
:started
do
|
remote_mirror
,
_
|
Gitlab
::
Mirror
.
increment_metric
(
:remote_mirrors_running
,
'Remote mirrors running count'
)
remote_mirror
.
update
(
last_update_started_at:
Time
.
now
)
end
after_transition
started: :finished
do
|
remote_mirror
,
_
|
Gitlab
::
Mirror
.
increment_metric
(
:remote_mirrors_finished
,
'Remote mirrors successfully finished count'
)
timestamp
=
Time
.
now
remote_mirror
.
update_attributes!
(
last_update_at:
timestamp
,
last_successful_update_at:
timestamp
,
last_error:
nil
...
...
@@ -57,6 +61,8 @@ class RemoteMirror < ActiveRecord::Base
end
after_transition
started: :failed
do
|
remote_mirror
,
_
|
Gitlab
::
Mirror
.
increment_metric
(
:remote_mirrors_failed
,
'Remote mirrors failed count'
)
remote_mirror
.
update
(
last_update_at:
Time
.
now
)
end
end
...
...
app/workers/repository_update_mirror_worker.rb
View file @
c7b8b63e
...
...
@@ -14,14 +14,14 @@ class RepositoryUpdateMirrorWorker
project
=
Project
.
find
(
project_id
)
raise
UpdateAlreadyInProgressError
if
project
.
import_started?
project
.
import_start
start_mirror
(
project
)
@current_user
=
project
.
mirror_user
||
project
.
creator
result
=
Projects
::
UpdateMirrorService
.
new
(
project
,
@current_user
).
execute
raise
UpdateError
,
result
[
:message
]
if
result
[
:status
]
==
:error
project
.
import_finish
finish_mirror
(
project
)
rescue
UpdateAlreadyInProgressError
raise
rescue
UpdateError
=>
ex
...
...
@@ -38,8 +38,21 @@ class RepositoryUpdateMirrorWorker
private
def
start_mirror
(
project
)
project
.
import_start
Gitlab
::
Mirror
.
increment_metric
(
:mirrors_running
,
'Mirrors running count'
)
end
def
fail_mirror
(
project
,
message
)
Rails
.
logger
.
error
(
message
)
project
.
mark_import_as_failed
(
message
)
Gitlab
::
Mirror
.
increment_metric
(
:mirrors_failed
,
'Mirrors failed count'
)
Rails
.
logger
.
error
(
message
)
end
def
finish_mirror
(
project
)
project
.
import_finish
Gitlab
::
Mirror
.
increment_metric
(
:mirrors_finished
,
'Mirrors successfully finished count'
)
end
end
app/workers/repository_update_remote_mirror_worker.rb
View file @
c7b8b63e
...
...
@@ -41,7 +41,8 @@ class RepositoryUpdateRemoteMirrorWorker
private
def
fail_remote_mirror
(
remote_mirror
,
message
)
Rails
.
logger
.
error
(
message
)
remote_mirror
.
mark_as_failed
(
message
)
Rails
.
logger
.
error
(
message
)
end
end
changelogs/unreleased-ee/mirroring-prometheus-metrics.yml
0 → 100644
View file @
c7b8b63e
---
title
:
Add metrics to both remote and non remote mirroring
merge_request
:
2118
author
:
lib/gitlab/mirror.rb
View file @
c7b8b63e
...
...
@@ -54,6 +54,10 @@ 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