class Raven::Client

Encodes events and sends them to the Sentry server.

Constants

CONTENT_TYPE
PROTOCOL_VERSION
USER_AGENT

Attributes

configuration[RW]

Public Class Methods

new(configuration) click to toggle source
# File lib/raven/client.rb, line 14
def initialize(configuration)
  @configuration = configuration
  @processors = configuration.processors.map { |v| v.new(self) }
  @state = ClientState.new
end

Public Instance Methods

send_event(event) click to toggle source
# File lib/raven/client.rb, line 20
def send_event(event)
  return false unless configuration.sending_allowed?(event)

  # Convert to hash
  event = event.to_hash

  unless @state.should_try?
    failed_send(nil, event)
    return
  end

  configuration.logger.info "Sending event #{event[:event_id]} to Sentry"

  content_type, encoded_data = encode(event)

  begin
    transport.send_event(generate_auth_header, encoded_data,
                         :content_type => content_type)
    successful_send
  rescue => e
    failed_send(e, event)
    return
  end

  event
end
transport() click to toggle source
# File lib/raven/client.rb, line 47
def transport
  @transport ||=
    case configuration.scheme
    when 'http', 'https'
      Transports::HTTP.new(configuration)
    when 'dummy'
      Transports::Dummy.new(configuration)
    else
      fail "Unknown transport scheme '#{configuration.scheme}'"
    end
end