Sha256: 45a5ba8c25a35d9c12845df28dcb8659f43b13f9504cbce839da30834556761d

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

module RailsPerformance
  module Models
    class Record
      attr_reader :controller, :action, :format, :status, :datetime, :datetimei, :method, :path, :request_id

      # key = performance|
      # controller|HomeController|
      # action|index|
      # format|html|
      # status|200|
      # datetime|20200124T0523|
      # datetimei|1579861423|
      # method|GET|
      # path|/|
      # request_id|454545454545454545|
      # END
      # = {"view_runtime":8.444603008683771,"db_runtime":0,"duration":9.216095000000001}
      # value = JSON
      def initialize(key, value)
        @json = value

        items = key.split("|")

        @controller = items[2]
        @action     = items[4]
        @format     = items[6]
        @status     = items[8]
        @datetime   = items[10]
        @datetimei  = items[12]
        @method     = items[14]
        @path       = items[16]
        @request_id = items[18]
      end

      def value
        @value ||= JSON.parse(@json || "{}")
      end

      def controller_action
        "#{controller}##{action}"
      end

      def controller_action_format
        "#{controller}##{action}|#{format}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_performance-0.0.1.19 lib/rails_performance/models/record.rb
rails_performance-0.0.1.18 lib/rails_performance/models/record.rb
rails_performance-0.0.1.17 lib/rails_performance/models/record.rb
rails_performance-0.0.1.16 lib/rails_performance/models/record.rb