Sha256: 2cbc74721dd3469f5d0b91a3b529ee4f41d390308f160ac060cd5e3b58ce8e4c
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require "logger" 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?(program_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 if ::Rails.logger logger = ::Rails.logger else logger = ::Logger.new(STDOUT) end 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: logger ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
prom_multi_proc_rb-0.1.3 | lib/prom_multi_proc/rails.rb |
prom_multi_proc_rb-0.1.2 | lib/prom_multi_proc/rails.rb |