Sha256: 129f6cb9d2e5d000f758c2d8fe86d23fe6f94667cbde7b8aa8b66b379130e75a

Contents?: true

Size: 1.38 KB

Versions: 10

Compression:

Stored size: 1.38 KB

Contents

module LogStats
  module Config
    def self.default_config
      {
        events: {
          requests: {
            # NOTE: matches Heroku router lines. Also matches Papertrails slightly modified lines.
            line_pattern: /\s(heroku\/router)|(heroku\[router\]:)\s/,
            fields: [
              {
                name: :time,
                parse: Proc.new { |line| line[/\b20\d\d-\d\d-\d\dT\d\d:\d\d:\d\d/] }
              },
              {name: :method},
              {name: :host},
              {name: :path},
              {name: :status, numeric: true},
              {name: :code, optional: true},
              {name: :service, numeric: true}
            ],
            top_list_limit: 100,
            apdex: {tolerating: 500, frustrated: 2000},
            apdex_goal: 0.9,
          }
        },
        output_format: "text",
        verbose: true
      }
    end

    def self.env_config
      default_config.keys.reduce({}) do |acc, key|
        value = env_value(key)
        if !value.nil?
          acc[key] = value
        end
        acc
      end
    end

    def self.env_value(key)
      env_key = key.to_s.upcase
      value = ENV[env_key]
      if !value.nil? && boolean?(default_config[key])
        ['1', true, 'true', 't', 'TRUE'].include?(value)
      else
        value
      end
    end

    def self.boolean?(value)
      !!value == value
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
log_stats-0.4.9 lib/log_stats/config.rb
log_stats-0.4.8 lib/log_stats/config.rb
log_stats-0.4.7 lib/log_stats/config.rb
log_stats-0.4.6 lib/log_stats/config.rb
log_stats-0.4.5 lib/log_stats/config.rb
log_stats-0.4.4 lib/log_stats/config.rb
log_stats-0.4.3 lib/log_stats/config.rb
log_stats-0.4.2 lib/log_stats/config.rb
log_stats-0.4.1 lib/log_stats/config.rb
log_stats-0.4.0 lib/log_stats/config.rb