lib/new_relic/agent/agent.rb in newrelic_rpm-3.0.0.beta2 vs lib/new_relic/agent/agent.rb in newrelic_rpm-3.0.0
- old
+ new
@@ -843,10 +843,11 @@
raise PostTooBigException
end
def send_request(opts)
request = Net::HTTP::Post.new(opts[:uri], 'CONTENT-ENCODING' => opts[:encoding], 'HOST' => opts[:collector].name)
+ request['user-agent'] = user_agent
request.content_type = "application/octet-stream"
request.body = opts[:data]
log.debug "Connect to #{opts[:collector]}#{opts[:uri]}"
@@ -893,9 +894,18 @@
def remote_method_uri(method)
uri = "/agent_listener/#{PROTOCOL_VERSION}/#{control.license_key}/#{method}"
uri << "?run_id=#{@agent_id}" if @agent_id
uri
+ end
+
+ def user_agent
+ ruby_description = ''
+ # note the trailing space!
+ ruby_description << "(ruby #{::RUBY_VERSION} #{::RUBY_PLATFORM}) " if defined?(::RUBY_VERSION) && defined?(::RUBY_PLATFORM)
+ zlib_version = ''
+ zlib_version << "zlib/#{Zlib.zlib_version}" if defined?(::Zlib) && Zlib.respond_to?(:zlib_version)
+ "NewRelic-RubyAgent/#{NewRelic::VERSION::STRING} #{ruby_description}#{zlib_version}"
end
# send a message via post
def invoke_remote(method, *args)
now = Time.now