Sha256: 34b24c213d5a283c903717d828f530480e5674f1a2bc622d1f4ca91c86481497

Contents?: true

Size: 811 Bytes

Versions: 3

Compression:

Stored size: 811 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.current
          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.current - now) * 1000,
            datetime: now.strftime(RailsPerformance::FORMAT),
            datetimei: now.to_i,
          ).save

          result
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_performance-1.2.1 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.2.0 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.2.0.alpha5 lib/rails_performance/gems/custom_ext.rb