Sha256: 238757090def3c2040e6d21de18e98a1378ec9c770468a5b415ed608c4297d80
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module PromMultiProc module Rails def self.init(prefix = nil) metrics = ENV.fetch("PROM_MULTI_PROC_DEFINITION_FILE", ::Rails.root.join("config/metrics.json").to_s) socket = ENV.fetch("PROM_MULTI_PROC_SOCKET", ::Rails.root.join("tmp/sockets/metrics.sock").to_s) program_name = File.basename($PROGRAM_NAME) app_name = ::Rails.application.class.name.underscore.split("/").first prefix ||= "#{app_name}_" if ENV.key?("PROM_MULTI_PROC_BATCH_SIZE") batch_size = ENV["PROM_MULTI_PROC_BATCH_SIZE"].to_i elsif %w(rails rake).include?(name) || ::Rails.env.development? || ::Rails.env.test? batch_size = 1 elsif ::Rails.env.production? batch_size = 100 else batch_size = 5 end if ::Rails.env.development? || ::Rails.env.test? validate = true else validate = false end ::Rails.logger.error("Setting up prom_multi_proc for #{app_name}-#{program_name}, batch size: #{batch_size}, validate: #{validate}") Base.new( prefix: prefix, socket: socket, metrics: metrics, batch_size: batch_size, validate: validate, logger: ::Rails.logger ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
prom_multi_proc_rb-0.1.0 | lib/prom_multi_proc/rails.rb |