lib/instana/util.rb in instana-0.14.0 vs lib/instana/util.rb in instana-0.14.2
- old
+ new
@@ -115,8 +115,31 @@
rescue => e
::Instana.logger.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
::Instana.logger.debug e.backtrace.join("\r\n")
return data
end
+
+ # Used in class initialization and after a fork, this method
+ # collects up process information
+ #
+ def collect_process_info
+ process = {}
+ cmdline = ProcTable.ps(Process.pid).cmdline.split("\0")
+ process[:name] = cmdline.shift
+ process[:arguments] = cmdline
+
+ if RUBY_PLATFORM =~ /darwin/i
+ # Handle OSX bug where env vars show up at the end of process name
+ # such as MANPATH etc..
+ process[:name].gsub!(/[_A-Z]+=\S+/, '')
+ process[:name].rstrip!
+ end
+
+ process[:pid] = Process.pid
+ # This is usually Process.pid but in the case of docker, the host agent
+ # will return to us the true host pid in which we use to report data.
+ process[:report_pid] = nil
+ process
+ end
end
end
end