infinite_tracing/test/support/fake_trace_observer_helpers.rb
def generate_and_stream_segments
            NewRelic::Agent::InfiniteTracing::Client.any_instance.stubs(:handle_close).returns(nil)
            unstub_reconnection
            server_context = nil
            with_config fake_server_config do
              # Suppresses intermittent fails from server not ready to accept streaming
              # (the retry loop goes _much_ faster)
              Connection.instance.stubs(:retry_connection_period).returns(0.01)
              nr_freeze_time
              nr_freeze_process_time

              simulate_connect_to_collector fake_server_config do |simulator|
                # starts server and simulated agent connection
                server_context = ServerContext.new FAKE_SERVER_PORT, InfiniteTracer
                simulator.join

                yield

                # ensures all segments consumed
                NewRelic::Agent.agent.infinite_tracer.flush
                server_context.flush
                server_context.stop

                return server_context.spans
              ensure
                Connection.instance.unstub(:retry_connection_period)
                NewRelic::Agent.agent.infinite_tracer.stop
                server_context.stop unless server_context.nil?
                reset_infinite_tracer
                nr_unfreeze_time
                nr_unfreeze_process_time
              end
            end
          end
# This helper is used to setup and teardown streaming to the fake trace observer
# A block that generates segments is expected and yielded to by this methd
# The spans collected by the server are returned for further inspection
This helper is used to setup and teardown streaming to the fake trace observer
A block that generates segments is expected and yielded to by this methd
The spans collected by the server are returned for further inspection
This helper is used to setup and teardown streaming to the fake trace observer A block that generates segments is expected and yielded to by this methd The spans collected by the server are returned for further inspection
def generate_and_stream_segments
            NewRelic::Agent::InfiniteTracing::Client.any_instance.stubs(:handle_close).returns(nil)
            unstub_reconnection
            server_context = nil
            with_config fake_server_config do
              Connection.instance.stubs(:retry_connection_period).returns(0.01)
              nr_freeze_time
              nr_freeze_process_time
              simulate_connect_to_collector fake_server_config do |simulator|
                server_context = ServerContext.new FAKE_SERVER_PORT, InfiniteTracer
                simulator.join
                yield
                NewRelic::Agent.agent.infinite_tracer.flush
                server_context.flush
                server_context.stop
                return server_context.spans
              ensure
                Connection.instance.unstub(:retry_connection_period)
                NewRelic::Agent.agent.infinite_tracer.stop
                server_context.stop unless server_context.nil?
                reset_infinite_tracer
                nr_unfreeze_time
                nr_unfreeze_process_time
              end
            end
          end
def generate_and_stream_segments NewRelic :: Agent :: InfiniteTracing :: Client . any_instance . stubs ( :handle_close ) . returns ( nil ) unstub_reconnection server_context = nil with_config fake_server_config do Connection . instance . stubs ( :retry_connection_period ) . returns ( 0.01 ) nr_freeze_time nr_freeze_process_time simulate_connect_to_collector fake_server_config do | simulator | server_context = ServerContext . new FAKE_SERVER_PORT , InfiniteTracer simulator . join yield NewRelic :: Agent . agent . infinite_tracer . flush server_context . flush server_context . stop return server_context . spans ensure Connection . instance . unstub ( :retry_connection_period ) NewRelic :: Agent . agent . infinite_tracer . stop server_context . stop unless server_context . nil? reset_infinite_tracer nr_unfreeze_time nr_unfreeze_process_time end end end
This helper is used to setup and teardown streaming to the fake trace observer
A block that generates segments is expected and yielded to by this methd
The spans collected by the server are returned for further inspection
This helper is used to setup and teardown streaming to the fake trace observer A block that generates segments is expected and yielded to by this methd The spans collected by the server are returned for further inspection
# Suppresses intermittent fails from server not ready to accept streaming # (the retry loop goes _much_ faster) # starts server and simulated agent connection # ensures all segments consumed