Sha256: 55642ee7eea93157e92e2ac3b437ebf16189354ba6bc027c0ec699d08ec39a71

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

module Timber
  module Contexts
    module Servers
      # Because this is a sub context we do not extend Server.
      class HerokuSpecific < Context
        ROOT_KEY = :heroku.freeze
        VERSION = 1.freeze
        DELIMITER = ".".freeze

        class << self
          def json_shell(&_block)
            Server.json_shell { super }
          end
        end

        attr_reader :dyno

        def initialize(dyno)
          # Initialize should be as fast as possible since it is executed inline.
          # Hence the lazy methods below.
          @dyno = dyno
          super()
        end

        def process_type
          @process_type ||= parts.first
        end

        def dyno_id
          @dyno_id ||= parts.last
        end

        private
          def parts
            @parts ||= dyno.split(DELIMITER)
          end

          def json_payload
            @json_payload ||= Macros::DeepMerger.merge({
              # order is relevant for logfmt styling
              :process_type => process_type,
              :dyno_id => dyno_id
            }, super).freeze.freeze
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 lib/timber/contexts/servers/heroku_specific.rb