From 23b2a3072238546da2a2f8e48ce09db85a59feef Mon Sep 17 00:00:00 2001 From: Gauvain Pocentek Date: Thu, 11 Aug 2016 19:31:39 +0200 Subject: Add sidekiq metrics support --- gitlab/objects.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'gitlab/objects.py') 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 -- cgit v1.2.1