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 15 def initialize(configuration) @configuration = configuration @processors = configuration.processors.map { |v| v.new(self) } @state = ClientState.new end
Public Instance Methods
send_event(event, hint = nil)
click to toggle source
# File lib/raven/client.rb, line 21 def send_event(event, hint = nil) return false unless configuration.sending_allowed?(event) event = configuration.before_send.call(event, hint) if configuration.before_send if event.nil? configuration.logger.info "Discarded event because before_send returned nil" return end # Convert to hash event = event.to_hash unless @state.should_try? failed_send(nil, event) return end event_id = event[:event_id] || event['event_id'] configuration.logger.info "Sending 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 55 def transport @transport ||= case configuration.scheme when 'http', 'https' Transports::HTTP.new(configuration) when 'stdout' Transports::Stdout.new(configuration) when 'dummy' Transports::Dummy.new(configuration) else fail "Unknown transport scheme '#{configuration.scheme}'" end end