Sha256: 57024d632f82d1961e3b4c0adcba9d6e841438ae4a29d303aa6db69c8602bd2a

Contents?: true

Size: 803 Bytes

Versions: 4

Compression:

Stored size: 803 Bytes

Contents

module RailsPerformance
  module Gems
    module CustomExtension
      extend self

      def measure(tag_name, namespace_name = nil)
        return yield unless RailsPerformance.enabled

        begin
          now    = Time.now
          status = 'success'
          result = yield
          result
        rescue Exception => ex
          status = 'error'
          raise(ex)
        ensure
          RailsPerformance::Models::CustomRecord.new(
            tag_name: tag_name,
            namespace_name: namespace_name,
            status: status,
            duration: (Time.now - now) * 1000,
            datetime: now.strftime(RailsPerformance::FORMAT),
            datetimei: now.to_i,
          ).save

          result
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_performance-1.2.0.alpha4 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.2.0.alpha3 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.2.0.alpha2 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.2.0.alpha1 lib/rails_performance/gems/custom_ext.rb