Sha256: e34ffa05b4e609c6d015e266ef32e38cf524fedf5979c1a584f5224b3c67a9ec

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 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 'rack/test'
require 'fake_collector'
require './testing_app'
require 'multiverse_helpers'

class CrossApplicationTracingTest < Minitest::Test

  # Important because the hooks are global that we only wire one AgentHooks up
  @@app = TestingApp.new
  @@wrapper_app = NewRelic::Rack::AgentHooks.new(@@app)

  include MultiverseHelpers
  setup_and_teardown_agent(:cross_process_id => "boo",
                           :encoding_key => "\0",
                           :trusted_account_ids => [1]) \
  do |collector|
    collector.stub('connect', {
      'agent_run_id' => 666,
      'transaction_name_rules' => [{"match_expression" => "ignored_transaction",
                                    "ignore"           => true}]})
  end

  def after_setup
    @@app.reset_headers
    @@app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
  end

  include Rack::Test::Methods

  def app
    @@wrapper_app
  end

  def test_cross_app_doesnt_modify_without_header
    get '/'
    assert_nil last_response.headers["X-NewRelic-App-Data"]
  end

  def test_cross_app_doesnt_modify_with_invalid_header
    get '/', nil, {'X-NewRelic-ID' => Base64.encode64('otherjunk')}
    assert_nil last_response.headers["X-NewRelic-App-Data"]
  end

  def test_cross_app_writes_out_information
    get '/', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
    refute_nil last_response.headers["X-NewRelic-App-Data"]
    assert_metrics_recorded(['ClientApplication/1#234/all'])
  end

  def test_cross_app_doesnt_modify_if_txn_is_ignored
    get '/', {'transaction_name' => 'ignored_transaction'}, {'X-NewRelic-ID' => Base64.encode64('1#234')}
    assert_nil last_response.headers["X-NewRelic-App-Data"]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
newrelic_rpm-3.8.1.221 test/multiverse/suites/agent_only/cross_application_tracing_test.rb