Sha256: 12f1dbb84179c11247531d7fe2710db724076f1064ace968e666a8fdd5fd8357

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 Bytes

Contents

# frozen_string_literal: true

module PlainApm
  class Config
    DEFAULT_EVENT_ENDPOINT = "https://ingest.plainapm.com/"

    attr_accessor :endpoint, :app_key, :enabled

    def initialize
      @enabled = enabled?
      @endpoint = ENV["PLAIN_APM_ENDPOINT"] || DEFAULT_EVENT_ENDPOINT
      @app_key = ENV["PLAIN_APM_APP_KEY"] || warn("Missing PLAIN_APM_APP_KEY environment variable, plain_apm agent won't start.")
    end

    private

    def enabled?
      force = ENV["PLAIN_APM_ENABLED"] == "1"
      key_present = ENV["PLAIN_APM_APP_KEY"] != ""
      production = (ENV["RAILS_ENV"] || ENV["RACK_ENV"]) == "production"

      key_present && (production || force)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
plain_apm-0.2.9 lib/plain_apm/config.rb
plain_apm-0.2.8 lib/plain_apm/config.rb
plain_apm-0.2.6 lib/plain_apm/config.rb