lib/fluent/plugin/out_newrelic.rb in fluent-plugin-newrelic-1.2.1 vs lib/fluent/plugin/out_newrelic.rb in fluent-plugin-newrelic-1.2.2

- old
+ new

@@ -73,15 +73,12 @@ }.merge(auth) .freeze end def package_record(record, timestamp) - if defined? timestamp.nsec - timestamp = timestamp * 1000 + timestamp.nsec / 1_000_000 - end packaged = { - 'timestamp' => timestamp, + 'timestamp' => resolveTimestamp(record['timestamp'], timestamp), # non-intrinsic attributes get put into 'attributes' 'attributes' => record } # intrinsic attributes go at the top level @@ -178,9 +175,20 @@ # internally, so it is installed by default with td-agent. # See https://github.com/fluent/fluentd/issues/215 gzip << Yajl.dump([payload]) gzip.close io.string + end + + def resolveTimestamp(recordTimestamp, fluentdTimestamp) + if recordTimestamp + recordTimestamp + else + if defined? fluentdTimestamp.nsec + fluentdTimestamp = fluentdTimestamp * 1000 + fluentdTimestamp.nsec / 1_000_000 + end + fluentdTimestamp + end end end end end