lib/new_relic/agent/agent.rb in newrelic_rpm-3.5.0.1 vs lib/new_relic/agent/agent.rb in newrelic_rpm-3.5.1.alpha

- old
+ new

@@ -83,12 +83,21 @@ attr_reader :url_rules # a configuration for the Real User Monitoring system - # handles things like static setup of the header for inclusion # into pages attr_reader :beacon_configuration + attr_reader :cross_process_id attr_accessor :service + def cross_process_encoding_bytes + if @cross_process_encoding_key && @cross_process_encoding_bytes.nil? + @cross_process_encoding_bytes = [] + @cross_process_encoding_key.each_byte {|byte| @cross_process_encoding_bytes << byte} + end + @cross_process_encoding_bytes + end + # Returns the length of the unsent errors array, if it exists, # otherwise nil def unsent_errors_size @unsent_errors.length if @unsent_errors end @@ -298,11 +307,11 @@ def log NewRelic::Agent.logger end # Herein lies the corpse of the former 'start' method. May - # it's unmatched flog score rest in pieces. + # its unmatched flog score rest in pieces. module Start # Check whether we have already started, which is an error condition def already_started? if started? control.log!("Agent Started Already!", :error) @@ -752,10 +761,13 @@ log.debug "Server provided config: #{config_data.inspect}" server_config = NewRelic::Agent::Configuration::ServerSource.new(config_data) Agent.config.apply_config(server_config, 1) log_connection!(config_data) if @service + @cross_process_id = Agent.config[:cross_process_id] + @cross_process_encoding_key = Agent.config[:encoding_key] + @beacon_configuration = BeaconConfiguration.new end # Logs when we connect to the server, for debugging purposes # - makes sure we know if an agent has not connected @@ -884,13 +896,26 @@ # this creates timeslices that are harvested below NewRelic::Agent::BusyCalculator.harvest_busy @unsent_timeslice_data ||= {} @unsent_timeslice_data = @stats_engine.harvest_timeslice_data(@unsent_timeslice_data, @metric_ids) + + warn_if_no_unicorn_metrics + @unsent_timeslice_data end + # this is just a support band-aid until we get a chance to + # overhaul the Unicorn instrumentation properly + def warn_if_no_unicorn_metrics + if Agent.config[:dispatcher].to_s == 'unicorn' + if @stats_engine.get_stats_no_scope('HttpDispatcher').call_count == 0 + NewRelic::Control.instance.log.warn('Unicorn detected but no metric send, please see https://newrelic.com/docs/troubleshooting/im-using-unicorn-and-i-dont-see-any-data') + end + end + end + # takes an array of arrays of spec and id, adds it into the # metric cache so we can save the collector some work by # sending integers instead of strings def fill_metric_id_cache(pairs_of_specs_and_ids) Array(pairs_of_specs_and_ids).each do |metric_spec, metric_id| @@ -1059,8 +1084,9 @@ end extend ClassMethods include InstanceMethods include BrowserMonitoring + include CrossProcessMonitoring end end end