summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/api-objects.rst1
-rw-r--r--docs/gl_objects/sidekiq.rst16
-rw-r--r--gitlab/__init__.py1
-rw-r--r--gitlab/objects.py36
4 files changed, 54 insertions, 0 deletions
diff --git a/docs/api-objects.rst b/docs/api-objects.rst
index 31f9da9..4050a51 100644
--- a/docs/api-objects.rst
+++ b/docs/api-objects.rst
@@ -23,3 +23,4 @@ API objects manipulation
gl_objects/system_hooks
gl_objects/todos
gl_objects/users
+ gl_objects/sidekiq
diff --git a/docs/gl_objects/sidekiq.rst b/docs/gl_objects/sidekiq.rst
new file mode 100644
index 0000000..a75a02d
--- /dev/null
+++ b/docs/gl_objects/sidekiq.rst
@@ -0,0 +1,16 @@
+###############
+Sidekiq metrics
+###############
+
+Use the :attr:`gitlab.Gitlab.sideqik` manager object to access Gitlab Sidekiq
+server metrics.
+
+Examples
+--------
+
+.. code-block:: python
+
+ gl.sidekiq.queue_metrics()
+ gl.sidekiq.process_metrics()
+ gl.sidekiq.job_stats()
+ gl.sidekiq.compound_metrics()
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index d70cea0..c672c23 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -193,6 +193,7 @@ class Gitlab(object):
self.team_projects = TeamProjectManager(self)
self.teams = TeamManager(self)
self.todos = TodoManager(self)
+ self.sidekiq = SidekiqManager(self)
@staticmethod
def from_config(gitlab_id=None, config_files=None):
diff --git a/gitlab/objects.py b/gitlab/objects.py
index 0e9c75f..d537d6a 100644
--- a/gitlab/objects.py
+++ b/gitlab/objects.py
@@ -495,6 +495,42 @@ class GitlabObject(object):
return not self.__eq__(other)
+class SidekiqManager(object):
+ """Manager for the Sidekiq methods.
+
+ This manager doesn't actually manage objects but provides helper fonction
+ for the sidekiq metrics API.
+ """
+ def __init__(self, gl):
+ """Constructs a Sidekiq manager.
+
+ Args:
+ gl (gitlab.Gitlab): Gitlab object referencing the GitLab server.
+ """
+ self.gitlab = gl
+
+ def _simple_get(self, url, **kwargs):
+ r = self.gitlab._raw_get(url, **kwargs)
+ raise_error_from_response(r, GitlabGetError)
+ return r.json()
+
+ def queue_metrics(self, **kwargs):
+ """Returns the registred queues information."""
+ return self._simple_get('/sidekiq/queue_metrics', **kwargs)
+
+ def process_metrics(self, **kwargs):
+ """Returns the registred sidekiq workers."""
+ return self._simple_get('/sidekiq/process_metrics', **kwargs)
+
+ def job_stats(self, **kwargs):
+ """Returns statistics about the jobs performed."""
+ return self._simple_get('/sidekiq/job_stats', **kwargs)
+
+ def compound_metrics(self, **kwargs):
+ """Returns all available metrics and statistics."""
+ return self._simple_get('/sidekiq/compound_metrics', **kwargs)
+
+
class UserEmail(GitlabObject):
_url = '/users/%(user_id)s/emails'
canUpdate = False