Sha256: 7b5f20ddf7f139efd19bdd872eb90d5b8018be7a2e1ba21335bfa897002d9b36

Contents?: true

Size: 918 Bytes

Versions: 5

Compression:

Stored size: 918 Bytes

Contents

module RailsPerformance
  class CurrentRequest
    attr_reader :request_id, :tracings, :ignore
    attr_accessor :data
    attr_accessor :record

    def CurrentRequest.init
      Thread.current[:rp_current_request] ||= CurrentRequest.new(SecureRandom.hex(16))
    end

    def CurrentRequest.current
      CurrentRequest.init
    end

    def CurrentRequest.cleanup
      RailsPerformance.log "----------------------------------------------------> CurrentRequest.cleanup !!!!!!!!!!!! -------------------------\n\n"
      RailsPerformance.skip = false
      Thread.current[:rp_current_request] = nil
    end

    def initialize(request_id)
      @request_id = request_id
      @tracings   = []
      @ignore     = Set.new
      @data       = nil
      @record     = nil
    end

    def trace(options = {})
      @tracings << options.merge(time: Time.current.to_i)
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_performance-1.2.3 lib/rails_performance/thread/current_request.rb
rails_performance-1.2.2 lib/rails_performance/thread/current_request.rb
rails_performance-1.2.1 lib/rails_performance/thread/current_request.rb
rails_performance-1.2.0 lib/rails_performance/thread/current_request.rb
rails_performance-1.2.0.alpha5 lib/rails_performance/thread/current_request.rb