Sha256: 17a988f9177dbde7c2bd292b7e31a0229fbb94c1b3b6c5616427f2baedd0e62a
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
module GovukPrometheusExporter def self.should_configure # Allow us to force the Prometheus Exporter for persistent Rake tasks... if ENV["GOVUK_PROMETHEUS_EXPORTER"] == "force" true elsif File.basename($PROGRAM_NAME) == "rake" || defined?(Rails) && (Rails.const_defined?("Console") || Rails.env == "test") false else ENV["GOVUK_PROMETHEUS_EXPORTER"] == "true" end end def self.configure return unless should_configure require "prometheus_exporter" require "prometheus_exporter/server" require "prometheus_exporter/middleware" if defined?(Sidekiq) Sidekiq.configure_server do |config| require "sidekiq/api" 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 begin server = PrometheusExporter::Server::WebServer.new bind: "0.0.0.0", port: 9394 server.start if defined?(Rails) Rails.application.middleware.unshift PrometheusExporter::Middleware end if defined?(Sinatra) Sinatra.use PrometheusExporter::Middleware end rescue Errno::EADDRINUSE warn "Warning: Could not connect to Prometheus Server" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
govuk_app_config-8.1.0 | lib/govuk_app_config/govuk_prometheus_exporter.rb |
govuk_app_config-8.0.2 | lib/govuk_app_config/govuk_prometheus_exporter.rb |