class Fluent::RavenOutput

Constants

LOG_LEVELS

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_raven.rb, line 14
def configure(conf)
  super

  @base_configuration = Raven::Configuration.new
  @base_configuration.server = conf['server']
  @base_configuration.public_key = 'not_used'
  @base_configuration.secret_key = 'not_used'
  @base_configuration.ssl_verification = conf['ssl_verification']
  @base_configuration.timeout = conf['timeout']
  @base_configuration.open_timeout = conf['open_timeout']

  if conf['raven_log_path'].nil?
    log.warn("`raven_log_level` is meaningless when `raven_log_path` isn't set")
  end

  Raven.configure do |config|
    config.logger = if conf['raven_log_path'].nil?
                      log
                    else
                      Logger.new(conf['raven_log_path'], log_level(conf['raven_log_level']))
                    end
  end
end
format(tag, time, record) click to toggle source
# File lib/fluent/plugin/out_raven.rb, line 50
def format(tag, time, record)
  [tag, time, record].to_msgpack
end
multi_workers_ready?() click to toggle source
# File lib/fluent/plugin/out_raven.rb, line 38
def multi_workers_ready?
  true
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_raven.rb, line 46
def shutdown
  super
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_raven.rb, line 42
def start
  super
end
write(chunk) click to toggle source
# File lib/fluent/plugin/out_raven.rb, line 54
def write(chunk)
  chunk.msgpack_each do |tag, time, record|
    auth_header = record['auth_header']
    data        = record['data']
    options     = Hash[record['options'].map { |key, value| [key.to_sym, value] }] if record['options']
    project_id  = record['project_id']
    send_to_sentry(auth_header, data, project_id, options)
  end
end

Private Instance Methods

log_level(str) click to toggle source
# File lib/fluent/plugin/out_raven.rb, line 82
def log_level(str)
  LOG_LEVELS.fetch(str, 'info')
end
send_to_sentry(auth_header, data, project_id, options) click to toggle source
# File lib/fluent/plugin/out_raven.rb, line 66
def send_to_sentry(auth_header, data, project_id, options)
  config = @base_configuration.dup
  config.project_id = project_id
  transport = ::Raven::Transports::HTTP.new(config)
  transport.send_event(auth_header, data, options)
end