-
-
Notifications
You must be signed in to change notification settings - Fork 395
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2305219
commit 56f7f3a
Showing
7 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class Gitlab::Client | ||
# Defines methods related to sidekiq metrics. | ||
# @see https://docs.gitlab.com/ce/api/sidekiq_metrics.html | ||
module Sidekiq | ||
# Get the current Queue Metrics | ||
# | ||
# @example | ||
# Gitlab.sidekiq_queue_metrics | ||
def sidekiq_queue_metrics | ||
get('/sidekiq/queue_metrics') | ||
end | ||
|
||
# Get the current Process Metrics | ||
# | ||
# @example | ||
# Gitlab.sidekiq_process_metrics | ||
def sidekiq_process_metrics | ||
get('/sidekiq/process_metrics') | ||
end | ||
|
||
# Get the current Job Statistics | ||
# | ||
# @example | ||
# Gitlab.sidekiq_job_stats | ||
def sidekiq_job_stats | ||
get('/sidekiq/job_stats') | ||
end | ||
|
||
# Get a compound response of all the previously mentioned metrics | ||
# | ||
# @example | ||
# Gitlab.sidekiq_compound_metrics | ||
def sidekiq_compound_metrics | ||
get('/sidekiq/compound_metrics') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"queues": { | ||
"default": { | ||
"backlog": 0, | ||
"latency": 0 | ||
} | ||
}, | ||
"processes": [ | ||
{ | ||
"hostname": "gitlab.example.com", | ||
"pid": 5649, | ||
"tag": "gitlab", | ||
"started_at": "2016-06-14T10:45:07.159-05:00", | ||
"queues": [ | ||
"post_receive", | ||
"mailers", | ||
"archive_repo", | ||
"system_hook", | ||
"project_web_hook", | ||
"gitlab_shell", | ||
"incoming_email", | ||
"runner", | ||
"common", | ||
"default" | ||
], | ||
"labels": [], | ||
"concurrency": 25, | ||
"busy": 0 | ||
} | ||
], | ||
"jobs": { | ||
"processed": 2, | ||
"failed": 0, | ||
"enqueued": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"jobs": { | ||
"processed": 2, | ||
"failed": 0, | ||
"enqueued": 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"processes": [ | ||
{ | ||
"hostname": "gitlab.example.com", | ||
"pid": 5649, | ||
"tag": "gitlab", | ||
"started_at": "2016-06-14T10:45:07.159-05:00", | ||
"queues": [ | ||
"post_receive", | ||
"mailers", | ||
"archive_repo", | ||
"system_hook", | ||
"project_web_hook", | ||
"gitlab_shell", | ||
"incoming_email", | ||
"runner", | ||
"common", | ||
"default" | ||
], | ||
"labels": [], | ||
"concurrency": 25, | ||
"busy": 0 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"queues": { | ||
"default": { | ||
"backlog": 0, | ||
"latency": 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require 'spec_helper' | ||
|
||
describe Gitlab::Client do | ||
describe ".sidekiq_queue_metrics" do | ||
before do | ||
stub_get("/sidekiq/queue_metrics", 'sidekiq_queue_metrics') | ||
@sidekiq_queue_metrics = Gitlab.sidekiq_queue_metrics | ||
end | ||
|
||
it "gets the correct resource" do | ||
expect(a_get("/sidekiq/queue_metrics")).to have_been_made | ||
end | ||
|
||
it "returns a information about a sidekiq default queue" do | ||
expect(@sidekiq_queue_metrics.queues.default.backlog).to eq 0 | ||
expect(@sidekiq_queue_metrics.queues.default.latency).to eq 0 | ||
end | ||
end | ||
|
||
describe ".sidekiq_process_metrics" do | ||
before do | ||
stub_get("/sidekiq/process_metrics", 'sidekiq_process_metrics') | ||
@sidekiq_process_metrics = Gitlab.sidekiq_process_metrics | ||
end | ||
|
||
it "gets the correct resource" do | ||
expect(a_get("/sidekiq/process_metrics")).to have_been_made | ||
end | ||
|
||
it "returns a information about a sidekiq process metrics" do | ||
expect(@sidekiq_process_metrics.processes.first['busy']).to eq 0 | ||
end | ||
end | ||
|
||
describe ".sidekiq_job_stats" do | ||
before do | ||
stub_get("/sidekiq/job_stats", 'sidekiq_job_stats') | ||
@sidekiq_job_stats = Gitlab.sidekiq_job_stats | ||
end | ||
|
||
it "gets the correct resource" do | ||
expect(a_get("/sidekiq/job_stats")).to have_been_made | ||
end | ||
|
||
it "returns a information about a sidekiq process metrics" do | ||
expect(@sidekiq_job_stats.jobs.processed).to eq 2 | ||
end | ||
end | ||
|
||
describe ".sidekiq_compound_metrics" do | ||
before do | ||
stub_get("/sidekiq/compound_metrics", 'sidekiq_compound_metrics') | ||
@sidekiq_compound_metrics = Gitlab.sidekiq_compound_metrics | ||
end | ||
|
||
it "gets the correct resource" do | ||
expect(a_get("/sidekiq/compound_metrics")).to have_been_made | ||
end | ||
|
||
it "returns a information about a sidekiq process metrics" do | ||
expect(@sidekiq_compound_metrics.jobs.processed).to eq 2 | ||
end | ||
end | ||
end |