Sha256: 2ea6d44989c45fb68c14f4c6991bb8151f883e161aa48fff9a48ac3d54a89850

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

#!/usr/bin/env ruby
# 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 'net/http'
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
require 'new_relic/agent/cross_app_tracing'

class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Minitest::Test
  def setup
    NewRelic::Agent.manual_start(
      :"cross_application_tracer.enabled" => false,
      :"transaction_tracer.enabled"       => true,
      :cross_process_id                   => '269975#22824',
      :encoding_key                       => 'gringletoes'
    )

    @response ||= nil

    @socket = fixture_tcp_socket( @response )

    NewRelic::Agent.instance.stats_engine.clear_stats
  end

  def teardown
    NewRelic::Agent.shutdown
  end

  def test_scope_stack_integrity_maintained_on_request_failure
    @socket.stubs(:write).raises('fake network error')
    with_config(:"cross_application_tracer.enabled" => true) do
      state    = NewRelic::Agent::TransactionState.tl_get
      stack    = state.traced_method_stack
      expected = stack.push_frame(state, 'dummy')
      Net::HTTP.get(URI.parse('http://www.google.com/index.html')) rescue nil
      stack.pop_frame(state, expected, 42, Time.now.to_f)
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
newrelic_rpm-4.1.0.333 test/new_relic/agent/instrumentation/net_instrumentation_test.rb
newrelic_rpm-4.0.0.332 test/new_relic/agent/instrumentation/net_instrumentation_test.rb
newrelic_rpm-3.18.1.330 test/new_relic/agent/instrumentation/net_instrumentation_test.rb
newrelic_rpm-3.18.0.329 test/new_relic/agent/instrumentation/net_instrumentation_test.rb