Sha256: c56c25a5be0aa87d1d7ed2ab6dd9a4db6fdf13ab09d99288ce0db6bae50a7832

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 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 AgentRunIdHandlingTest < Minitest::Test
  include MultiverseHelpers

  NON_NUMERIC_RUN_ID = 'some-crazy-non-integer-thing'

  setup_and_teardown_agent do
    $collector.stub('connect', { "agent_run_id" => NON_NUMERIC_RUN_ID })
  end

  # This test verifies that the Ruby agent is able to accept non-numeric values
  # of the agent run ID handed down by the collector in response to the connect
  # method. This is required for agent protocol version 14.
  def test_handles_non_numeric_agent_run_ids
    NewRelic::Agent.agent.send(:transmit_data)
    metric_data_post = $collector.calls_for('metric_data').last
    assert_equal(NON_NUMERIC_RUN_ID, metric_data_post[0])
  end

  # The sql_data endpoint sends the agent run ID as a query string parameter,
  # rather than embedded within the body, so make sure we handle that.
  def test_handles_non_numeric_agent_run_id_on_slow_sql_traces
    simulate_slow_sql_trace
    sql_data_post = $collector.calls_for('sql_trace_data').last
    assert_equal(NON_NUMERIC_RUN_ID, sql_data_post.query_params['run_id'])
  end

  def simulate_slow_sql_trace
    in_transaction do
      agent.sql_sampler.notice_sql("select * from test", "Database/test/select", nil, 1.5)
    end
    NewRelic::Agent.agent.send(:harvest_and_send_slowest_sql)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
newrelic_rpm-3.10.0.279 test/multiverse/suites/agent_only/agent_run_id_handling_test.rb
newrelic_rpm-3.9.9.275 test/multiverse/suites/agent_only/agent_run_id_handling_test.rb
newrelic_rpm-3.9.8.273 test/multiverse/suites/agent_only/agent_run_id_handling_test.rb
newrelic_rpm-3.9.7.266 test/multiverse/suites/agent_only/agent_run_id_handling_test.rb
newrelic_rpm-3.9.6.257 test/multiverse/suites/agent_only/agent_run_id_handling_test.rb
newrelic_rpm-3.9.5.251 test/multiverse/suites/agent_only/agent_run_id_handling_test.rb