Sha256: 0949e29f7851386ea5f92b07f3416992ed9d32f2d539c4159add83789feb6040

Contents?: true

Size: 861 Bytes

Versions: 7

Compression:

Stored size: 861 Bytes

Contents

module RailsPerformance
  module Gems
    module CustomExtension
      extend self

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

        begin
          now = Time.current
          status = "success"
          result = yield
          result
        rescue Exception => ex # rubocop:disable Lint/RescueException
          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
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_performance-1.4.0.alpha3 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.4.0.alpha2 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.4.0.alpha1 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.3.3 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.3.2 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.3.1 lib/rails_performance/gems/custom_ext.rb
rails_performance-1.3.0 lib/rails_performance/gems/custom_ext.rb