Sha256: 5ff21ae0236fa72faf6dda555c70ec62995ea24bdab546c29284e7033dfb1d18

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

module Yarder
  module ActiveResource
    class LogSubscriber < ::ActiveSupport::LogSubscriber

      def request(event)
        request_entry = {}
        request_entry['method'] = event.payload[:method].to_s.upcase
        request_entry['uri'] = event.payload[:request_uri]

        result = event.payload[:result]

        request_entry['code'] = result.code
        request_entry['message'] = result.message
        request_entry['length'] = result.body.to_s.length
        request_entry['duration'] = event.duration

        entry.fields['rest'] ||= []
        entry.fields['rest'] << request_entry

        entry.fields['duration'] ||= {}
        entry.fields['duration']['rest'] ||= 0
        entry.fields['duration']['rest'] += event.duration.to_f
      end

    private

      def entry
        Yarder.log_entries[Thread.current]
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yarder-0.1.0 lib/yarder/active_resource/log_subscriber.rb