lib/appsignal/transmitter.rb in appsignal-1.3.6 vs lib/appsignal/transmitter.rb in appsignal-1.4.0.alpha.1

- old
+ new

@@ -6,10 +6,11 @@ module Appsignal class Transmitter CONTENT_TYPE = 'application/json; charset=UTF-8'.freeze CONTENT_ENCODING = 'gzip'.freeze + CA_FILE_PATH = File.expand_path(File.join(__FILE__, '../../../resources/cacert.pem')) HTTP_ERRORS = [ EOFError, Errno::ECONNREFUSED, Errno::ECONNRESET, @@ -39,22 +40,24 @@ }) end end def transmit(payload) - config.logger.debug "Transmitting payload to #{uri}" + Appsignal.logger.debug "Transmitting payload to #{uri}" http_client.request(http_post(payload)).code end protected def http_post(payload) Net::HTTP::Post.new(uri.request_uri).tap do |request| request['Content-Type'] = CONTENT_TYPE request['Content-Encoding'] = CONTENT_ENCODING - request.body = Appsignal::Utils::Gzip.compress \ - Appsignal::Utils::JSON.generate(payload) + request.body = Zlib::Deflate.deflate( + Appsignal::Utils.json_generate(payload), + Zlib::BEST_SPEED + ) end end def http_client client = if config[:http_proxy] @@ -66,17 +69,10 @@ client.tap do |http| if uri.scheme == 'https' http.use_ssl = true http.ssl_version = :TLSv1 http.verify_mode = OpenSSL::SSL::VERIFY_PEER - - ca_file = config[:ca_file_path] - if ca_file && File.exist?(ca_file) && File.readable?(ca_file) - http.ca_file = ca_file - else - config.logger.warn "Ignoring non-existing or unreadable "\ - "`ca_file_path`: #{ca_file}" - end + http.ca_file = CA_FILE_PATH end end end def proxy_uri