Sha256: 3a1ba2595af28e2989907059dcb8768f62f2b67e670d9c0832d87391bd5b9913

Contents?: true

Size: 1.97 KB

Versions: 23

Compression:

Stored size: 1.97 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

class TransactionTracingPerfTests < Performance::TestCase
  FAILURE_MESSAGE = "O_o"

  BOO = "boo"
  HOO = "hoo"
  OH  = "oh"
  NO  = "no"

  def klass(instrument)
    Class.new do
      def self.name
        "CustomClass#{object_id}"
      end

      def short_transaction
        method_4
      end

      def transaction_with_attributes
        method_4
        NewRelic::Agent.add_custom_attributes(BOO => HOO, OH => NO)
      end

      def long_transaction(n)
        n.times do
          method_1
        end
      end


      def failure
        raise FAILURE_MESSAGE
      end

      def method_1
        method_2
        method_3
      end

      def method_2
      end

      def method_3
      end

      def method_4
      end

      if instrument
        include NewRelic::Agent::Instrumentation::ControllerInstrumentation
        include NewRelic::Agent::MethodTracer

        add_method_tracer :method_1
        add_method_tracer :method_2
        add_method_tracer :method_3
        add_method_tracer :method_4

        add_transaction_tracer :short_transaction
        add_transaction_tracer :long_transaction
        add_transaction_tracer :transaction_with_attributes
        add_transaction_tracer :failure
      end

    end
  end

  def setup
    @dummy = klass(true).new
    NewRelic::Agent.manual_start(
      :developer_mode => false,
      :monitor_mode   => false
    )
  end

  def teardown
    NewRelic::Agent.shutdown
  end

  def test_short_transactions
    measure { @dummy.short_transaction }
  end

  def test_long_transactions
    measure do
      @dummy.long_transaction(10000)
    end
  end

  def test_with_custom_attributes
    measure { @dummy.transaction_with_attributes }
  end

  def test_failure
    measure do
      begin
        @dummy.failure
      rescue
        # Whatever...
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
newrelic_rpm-4.0.0.332 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.18.1.330 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.18.0.329 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.17.2.327 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.17.1.326 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.17.0.325 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.16.3.323 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.16.2.321 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.16.1.320 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.16.0.318 test/performance/suites/transaction_tracing.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.15.2.317 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.15.1.316 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.15.0.314 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.14.3.313 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.14.2.312 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.14.1.311 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.14.0.305 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.13.2.302 test/performance/suites/transaction_tracing.rb
newrelic_rpm-3.13.1.300 test/performance/suites/transaction_tracing.rb