-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Sidekiq Prometheus instrumentation
If Sidekiq is present, add the Sidekiq Prometheus instrumentation. Ref: 1. [trello card](https://trello.com/c/K8aUtwz4/974-graphs-for-sidekiq-queues-in-grafana)
- Loading branch information
1 parent
f63ddb7
commit 57af294
Showing
2 changed files
with
23 additions
and
3 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 |
---|---|---|
@@ -1,14 +1,34 @@ | ||
module GovukPrometheusExporter | ||
def self.configure | ||
unless Rails.env == "test" || (ENV["GOVUK_PROMETHEUS_EXPORTER"]) != "true" | ||
if (ENV["GOVUK_PROMETHEUS_EXPORTER"]) == "true" | ||
return if defined?(Rails) ? Rails.env == "test" : false | ||
|
||
require "prometheus_exporter" | ||
require "prometheus_exporter/server" | ||
require "prometheus_exporter/middleware" | ||
|
||
if defined?(Sidekiq) | ||
Sidekiq.configure_server do |config| | ||
require "prometheus_exporter/instrumentation" | ||
config.server_middleware do |chain| | ||
chain.add PrometheusExporter::Instrumentation::Sidekiq | ||
end | ||
config.death_handlers << PrometheusExporter::Instrumentation::Sidekiq.death_handler | ||
config.on :startup do | ||
PrometheusExporter::Instrumentation::Process.start type: "sidekiq" | ||
PrometheusExporter::Instrumentation::SidekiqProcess.start | ||
PrometheusExporter::Instrumentation::SidekiqQueue.start | ||
PrometheusExporter::Instrumentation::SidekiqStats.start | ||
end | ||
end | ||
end | ||
|
||
server = PrometheusExporter::Server::WebServer.new bind: "0.0.0.0", port: 9394 | ||
server.start | ||
|
||
Rails.application.middleware.unshift PrometheusExporter::Middleware | ||
if defined?(Rails) | ||
Rails.application.middleware.unshift PrometheusExporter::Middleware | ||
end | ||
end | ||
end | ||
end |