Sha256: fa92fd2f2b6870971545e0892ab11059f9363ec83d8d8b0d5c7f4110e316cdee

Contents?: true

Size: 1.43 KB

Versions: 24

Compression:

Stored size: 1.43 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 'newrelic_rpm'

class CustomQueueTimeTest < Minitest::Test
  include MultiverseHelpers

  setup_and_teardown_agent

  DummyRequest = Struct.new(:headers, :cookies) do
    def path
      "/"
    end
  end

  class DummyApp
    include NewRelic::Agent::Instrumentation::ControllerInstrumentation

    def run_transaction(request, simulated_queue_time)
      opts = { :name => 'run_transaction', :class_name => 'DummyApp', :request => request }

      advance_time(simulated_queue_time)

      perform_action_with_newrelic_trace(opts) do
        # nothing
      end
    end
  end

  def setup
    freeze_time
    @headers = { 'HTTP_X_REQUEST_START' => "t=#{Time.now.to_f}" }
  end

  def test_pulls_request_headers_from_passed_in_rack_request
    request = Rack::Request.new(@headers)
    DummyApp.new.run_transaction(request, 10)

    assert_metrics_recorded(
      'WebFrontend/QueueTime' => {
        :call_count      => 1,
        :total_call_time => 10
      }
    )
  end

  def test_pulls_request_headers_from_passed_in_request_responding_to_headers
    request = DummyRequest.new(@headers, {})
    DummyApp.new.run_transaction(request, 10)

    assert_metrics_recorded(
      'WebFrontend/QueueTime' => {
        :call_count      => 1,
        :total_call_time => 10
      }
    )
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

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