Class: Raven::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/raven/client.rb

Overview

Encodes events and sends them to the Sentry server.

Constant Summary collapse

PROTOCOL_VERSION =
'5'
USER_AGENT =
"raven-ruby/#{Raven::VERSION}"
CONTENT_TYPE =
'application/json'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
# File 'lib/raven/client.rb', line 18

def initialize(configuration)
  @configuration = configuration
  @processors = configuration.processors.map { |v| v.new(self) }
  @state = ClientState.new
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



16
17
18
# File 'lib/raven/client.rb', line 16

def configuration
  @configuration
end

Instance Method Details

#send(event) ⇒ Object



52
53
54
55
56
# File 'lib/raven/client.rb', line 52

def send(event)
  Raven.logger.warn "DEPRECATION WARNING: Calling #send on a Client will be \
    removed in Raven-Ruby 0.14! Use #send_event instead!"
  send_event(event)
end

#send_event(event) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 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