Sha256: 07493d7ac71535d3c67e94ca1b3c31864b62b4af7976764edd8b1e5bf4d687f1

Contents?: true

Size: 845 Bytes

Versions: 2

Compression:

Stored size: 845 Bytes

Contents

require 'base64'
require 'zlib'
require 'oj'

module Fluent
  class TextParser
    class SentryHttpParser < Parser
      Plugin.register_parser('sentry_http', self)

      config_param :json_parse, :bool, :default => true
      config_param :field_name, :string, :default => 'message'

      def initialize
        super
      end
 
      def configure(conf)
        super
      end

      def parse(text)
        message = Zlib::Inflate.inflate(Base64.decode64(text))
        record = Oj.load(message, :mode => :compat)

        record_time = record['timestamp']
        time = record_time.nil? ? Engine.now : Time.parse(record_time).to_i

        record = {@field_name => message} unless @json_parse

        yield time, record
      rescue => e
        $log.warn "parse error: #{e.message}"
        yield nil, nil
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fluent-plugin-sentry-http-0.1.1 lib/fluent/plugin/parser_sentry_http.rb
fluent-plugin-sentry-http-0.1.0 lib/fluent/plugin/parser_sentry_http.rb