Sha256: 382eeb463be0bac7ba84e579d4d5716e5120453d05070fff497a87b1626135bb

Contents?: true

Size: 1.95 KB

Versions: 9

Compression:

Stored size: 1.95 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.

require File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper')
require 'multiverse_helpers'

class KeyTransactionsTest < MiniTest::Unit::TestCase

  include MultiverseHelpers

  setup_and_teardown_agent do |collector|
    key_txn_name = 'Controller/KeyTransactionsTest::TestWidget/key_txn'
    collector.stub('connect',
                   {
      'web_transactions_apdex' => { key_txn_name => 1 },
      'apdex_t' => 10
    })
  end

  def after_setup
    freeze_time
  end

  class TestWidget
    include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation

    def key_txn
      advance_time(5)
    end
    add_transaction_tracer :key_txn

    def other_txn
      advance_time(5)
    end
    add_transaction_tracer :other_txn
  end

  SATISFYING = 0
  TOLERATING = 1
  FAILING    = 2

  def test_applied_correct_apdex_t_to_key_txn
    TestWidget.new.key_txn
    NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)

    stats = $collector.reported_stats_for_metric('Apdex')[0]
    assert_equal(1.0, stats[FAILING],
                 "Expected stats (#{stats}) to be apdex failing")
  end

  def test_applied_correct_apdex_t_to_regular_txn
    TestWidget.new.other_txn
    NewRelic::Agent.instance.send(:harvest_and_send_timeslice_data)

    stats = $collector.reported_stats_for_metric('Apdex')[0]
    assert_equal(1.0, stats[SATISFYING],
                 "Expected stats (#{stats}) to be apdex satisfying")
  end

  def test_applied_correct_tt_theshold
    TestWidget.new.key_txn
    TestWidget.new.other_txn

    NewRelic::Agent.instance.send(:harvest_and_send_transaction_traces)

    traces = $collector.calls_for('transaction_sample_data')
    assert_equal 1, traces.size
    assert_equal('Controller/KeyTransactionsTest::TestWidget/key_txn',
                 traces[0].metric_name)
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
newrelic_rpm-3.7.2.195 test/multiverse/suites/agent_only/key_transactions_test.rb
newrelic_rpm-3.7.2.192 test/multiverse/suites/agent_only/key_transactions_test.rb
newrelic_rpm-3.7.2.190.beta test/multiverse/suites/agent_only/key_transactions_test.rb
newrelic_rpm-3.7.1.188 test/multiverse/suites/agent_only/key_transactions_test.rb
newrelic_rpm-3.7.1.182 test/multiverse/suites/agent_only/key_transactions_test.rb
newrelic_rpm-3.7.1.180 test/multiverse/suites/agent_only/key_transactions_test.rb
newrelic_rpm-3.7.0.177 test/multiverse/suites/agent_only/key_transactions_test.rb
newrelic_rpm-3.7.0.174.beta test/multiverse/suites/agent_only/key_transactions_test.rb
newrelic_rpm-3.6.9.171 test/multiverse/suites/agent_only/key_transactions_test.rb