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 18
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 24
def send_event(event)
  return false unless configuration_allows_sending

  # Convert to hash
  event = event.to_hash

  if !@state.should_try?
    Raven.logger.error("Not sending event due to previous failure(s): #{get_log_message(event)}")
    return
  end

  Raven.logger.debug "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)
  rescue => e
    failed_send(e, event)
    return
  end

  successful_send

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