Skip to content

Commit

Permalink
Lazy load prometheus_exporter for GovukPrometheusExporter
Browse files Browse the repository at this point in the history
This delays the require of prometheus_exporter until the configure
method is called. This prevents the library from being required by apps
the don't need it.
  • Loading branch information
theseanything committed Mar 4, 2022
1 parent c48028b commit 8102852
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/govuk_app_config/govuk_prometheus_exporter.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require "prometheus_exporter"
require "prometheus_exporter/server"
require "prometheus_exporter/middleware"

module GovukPrometheusExporter
def self.configure
unless Rails.env == "test"
require "prometheus_exporter"
require "prometheus_exporter/server"
require "prometheus_exporter/middleware"

server = PrometheusExporter::Server::WebServer.new bind: "localhost", port: 9394
server.start

Expand Down

0 comments on commit 8102852

Please sign in to comment.