Sha256: ed713850b00ff21566f50855ab6a5081acd1e812d897a23cd851ae36590c5acf

Contents?: true

Size: 1.42 KB

Versions: 13

Compression:

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

class CustomQueueTimeTest < Minitest::Test
  include MultiverseHelpers

  setup_and_teardown_agent

  DummyRequest = Struct.new(:headers, :cookies)

  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

13 entries across 13 versions & 1 rubygems

Version Path
newrelic_rpm-3.10.0.279 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.9.275 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.8.273 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.7.266 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.6.257 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.5.251 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.4.245 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.3.241 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.2.239 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.1.236 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.9.0.229 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.8.1.221 test/multiverse/suites/agent_only/custom_queue_time_test.rb
newrelic_rpm-3.8.0.218 test/multiverse/suites/agent_only/custom_queue_time_test.rb