Sha256: 2b24bb8991adb1d6fc776e162b827c1e4093221793f5767ed7380f63b49ab0dd

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 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 'multiverse_helpers'

# These tests are intended to exercise the basic marshalling functionality of
# the agent in it's different permutations (Ruby and JSON)
class MarshallingTest < Minitest::Test

  include MultiverseHelpers

  setup_and_teardown_agent

  def test_sends_metrics
    NewRelic::Agent.record_metric('Boo', 42)

    transmit_data

    result = $collector.calls_for('metric_data')
    assert_equal 1, result.length
    assert_includes result.first.metric_names, 'Boo'
  end

  def test_sends_errors
    NewRelic::Agent.notice_error(StandardError.new("Boom"))

    transmit_data

    result = $collector.calls_for('error_data')
    assert_equal 1, result.length
    assert_equal 1, result.first.errors.length
    assert_equal "StandardError", result.first.errors.first.exception_class_name
  end

  def test_sends_transaction_traces
    with_config(:'transaction_tracer.transaction_threshold' => -1.0) do
      Transactioner.new.do_it
    end

    transmit_data

    result = $collector.calls_for('transaction_sample_data')
    assert_equal 1, result.length
    assert_equal "Controller/MarshallingTest::Transactioner/do_it", result.first.metric_name
  end

  class Transactioner
    include NewRelic::Agent::Instrumentation::ControllerInstrumentation

    def do_it
    end

    add_transaction_tracer :do_it
  end

  def transmit_data
    NewRelic::Agent.instance.send(:transmit_data)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
newrelic_rpm-3.9.5.251 test/multiverse/suites/marshalling/marshalling_test.rb
newrelic_rpm-3.9.4.245 test/multiverse/suites/marshalling/marshalling_test.rb
newrelic_rpm-3.9.3.241 test/multiverse/suites/marshalling/marshalling_test.rb
newrelic_rpm-3.9.2.239 test/multiverse/suites/marshalling/marshalling_test.rb