lib/instana/agent.rb in instana-1.4.4 vs lib/instana/agent.rb in instana-1.4.5

- old
+ new

@@ -42,16 +42,17 @@ @default_gateway = `/sbin/ip route | awk '/default/ { print $3 }'`.chomp else @default_gateway = nil end + # Collect initial process info - repeat prior to announce + # in `announce_sensor` in case of process rename, after fork etc. + @process = ::Instana::Util.collect_process_info + # The agent UUID returned from the host agent @agent_uuid = nil - # Collect process information - @process = ::Instana::Util.collect_process_info - # This will hold info on the discovered agent host @discovered = nil end # Used post fork to re-initialize state and restart communications with @@ -62,13 +63,10 @@ # Reseed the random number generator for this # new thread. srand - # Re-collect process information post fork - @process = ::Instana::Util.collect_process_info - transition_to(:unannounced) setup spawn_background_thread end @@ -100,11 +98,11 @@ # def setup # The announce timer # We attempt to announce this ruby sensor to the host agent. # In case of failure, we try again in 30 seconds. - @announce_timer = @timers.now_and_every(30) do + @announce_timer = @timers.every(30) do if host_agent_ready? && announce_sensor ::Instana.logger.warn "Host agent available. We're in business." transition_to(:announced) end end @@ -167,9 +165,13 @@ def announce_sensor unless @discovered ::Instana.logger.agent("#{__method__} called but discovery hasn't run yet!") return false end + + # Always re-collect process info before announce in case the process name has been + # re-written (looking at you puma!) + @process = ::Instana::Util.collect_process_info announce_payload = {} announce_payload[:pid] = pid_namespace? ? get_real_pid : Process.pid announce_payload[:name] = @process[:name] announce_payload[:args] = @process[:arguments]