module NewRelic::Agent

This file is distributed under New Relic's license terms. See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. frozen_string_literal: true

This file is distributed under New Relic's license terms. See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. frozen_string_literal: true

This file is distributed under New Relic's license terms. See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. frozen_string_literal: true

The Client class manages the streaming buffer with respect to the gRPC Connection.

Restarting the client will cause a new connection to the gRPC server. When the client is restarted, a new streaming buffer is started and contents of old buffer are transferred to the new buffer.

Suspending the client will prevent the client from attempting to reconnect to the gRPC server, but will still continue to record the span events `seen` metric.

This file is distributed under New Relic's license terms. See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. frozen_string_literal: true

The connection class manages the channel and connection to the gRPC server.

Calls to the gRPC server are blocked until the agent connects to the collector and obtains a license_key and agent_run_token from the server side configuration.

If the agent is instructed to reconnect by the collector, that event triggers server_source_configuration_added, which this connection is subscribed to and will also notify the client to restart and re-establish its bi-directional streaming with the gRPC server.

NOTE: Connection is implemented as a Singleton and it also only ever expects one client instance by design.

This file is distributed under New Relic's license terms. See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. frozen_string_literal: true

This file is distributed under New Relic's license terms. See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. frozen_string_literal: true

The StreamingBuffer class provides an Enumerator to the standard Ruby Queue class. The enumerator is blocking while the queue is empty.

The SuspendedStreamingBuffer class discards pushed segments and records the seen metric. This buffer is installed when the gRPC server returns UNIMPLEMENTED (status 12) code as a signal to not reconnect to the server.

This file is distributed under New Relic's license terms. See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. frozen_string_literal: true

The Worker class makes it easy to stop and start a thread at will. Some basic error handling/capture is wrapped around the Thread to help propagate the exceptions arising from the threaded processes to the main process where the main agent code lives.

Public Instance Methods

close_infinite_tracer() click to toggle source
# File lib/infinite_tracing/agent_integrations/agent.rb, line 22
def close_infinite_tracer
  return unless @infinite_tracer_thread
  @infinite_tracer_thread.join
  @infinite_tracer_thread.stop
  @infinite_tracer_thread = nil
end
infinite_tracer() click to toggle source
# File lib/infinite_tracing/agent_integrations/agent.rb, line 29
def infinite_tracer
  @infinite_tracer ||= new_infinite_tracer
end
new_infinite_tracer() click to toggle source
# File lib/infinite_tracing/agent_integrations/agent.rb, line 11
def new_infinite_tracer
  # We must start streaming in a thread or we block/deadlock the
  # entire start up process for the Agent.
  InfiniteTracing::Client.new.tap do |client| 
    @infinite_tracer_thread = InfiniteTracing::Worker.new(:infinite_tracer) do 
      NewRelic::Agent.logger.debug "Opening Infinite Tracer Stream with gRPC server"
      client.start_streaming
    end
  end
end