Sha256: 18c5be2eb300dc68d3f355acb38e7fe8a815484e76248a48c3ef71fd263038ec

Contents?: true

Size: 801 Bytes

Versions: 15

Compression:

Stored size: 801 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

15 entries across 15 versions & 1 rubygems

Version Path
rails_performance-1.1.0 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.5.3 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.5.2 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.5.1 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.5 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.4 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.3 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.2 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.1 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.0 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.0.beta5 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.0.beta4 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.0.beta3 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.0.beta2 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.0.0.beta1 lib/rails_performance/gems/custom_ext.rb