Sha256: 190c60713a17faa102355b0669076f79c9e90f22e4cefeadb46c154cb05648f4

Contents?: true

Size: 1.04 KB

Versions: 96

Compression:

Stored size: 1.04 KB

Contents

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.io/terms.html

require 'sqreen/performance_notifications'

module Sqreen
  module PerformanceNotifications
    # Log performances on the console
    class NewRelic
      @subid = nil

      @nr_name_regexp = %r{/([^/]+)$}

      class << self
        def log(event, start, finish, _meta)
          event_name = "Custom/Sqreen#{event.sub(@nr_name_regexp, '_\1')}"
          ::NewRelic::Agent.record_metric(event_name, finish - start)
        end

        def enable
          return unless @subid.nil?
          return unless defined?(::NewRelic::Agent)
          Sqreen.log.debug('Enabling New Relic reporting')
          @subid = Sqreen::PerformanceNotifications.subscribe(nil,
                                                              &method(:log))
        end

        def disable
          return if @subid.nil?
          Sqreen::PerformanceNotifications.unsubscribe(@subid)
          @subid = nil
        end
      end
    end
  end
end

Version data entries

96 entries across 96 versions & 2 rubygems

Version Path
sqreen-1.10.5-java lib/sqreen/performance_notifications/newrelic.rb
sqreen-alt-1.10.5 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.5 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.4-java lib/sqreen/performance_notifications/newrelic.rb
sqreen-alt-1.10.4 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.4 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.3-java lib/sqreen/performance_notifications/newrelic.rb
sqreen-alt-1.10.3 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.3 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.2-java lib/sqreen/performance_notifications/newrelic.rb
sqreen-alt-1.10.2 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.2 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.1-java lib/sqreen/performance_notifications/newrelic.rb
sqreen-alt-1.10.1 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.1 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.0-java lib/sqreen/performance_notifications/newrelic.rb
sqreen-alt-1.10.0 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.10.0 lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.9.2-java lib/sqreen/performance_notifications/newrelic.rb
sqreen-1.9.2 lib/sqreen/performance_notifications/newrelic.rb