lib/fluent/plugin/out_newrelic.rb in fluent-plugin-newrelic-1.1.1 vs lib/fluent/plugin/out_newrelic.rb in fluent-plugin-newrelic-1.1.3

- old
+ new

@@ -16,10 +16,11 @@ require 'fluent/plugin/output' require 'net/http' require 'uri' require 'zlib' require 'newrelic-fluentd-output/version' +require 'yajl' module Fluent module Plugin class NewrelicOutput < Fluent::Plugin::Output class ConnectionFailure < StandardError @@ -106,21 +107,21 @@ next if record.empty? payload['logs'].push(package_record(record, ts)) end io = StringIO.new gzip = Zlib::GzipWriter.new(io) - gzip << [payload].to_json + gzip << Yajl.dump([payload]) gzip.close - send(io.string) + send_payload(io.string) end def handle_response(response) if !(200 <= response.code.to_i && response.code.to_i < 300) log.error("Response was " + response.code + " " + response.body) end end - def send(payload) + def send_payload(payload) http = Net::HTTP.new(@end_point.host, 443) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER request = Net::HTTP::Post.new(@end_point.request_uri, @header) request.body = payload