Class: Raven::Client

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

Constant Summary collapse

PROTOCOL_VERSION =
'3'
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.



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

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

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



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

def configuration
  @configuration
end

Instance Method Details

#send(event) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/raven/client.rb', line 24

def send(event)
  if !configuration.send_in_current_environment?
    Raven.logger.debug "Event not sent due to excluded environment: #{configuration.current_environment}"
    return
  end

  # Set the project ID correctly
  event.project = self.configuration.project_id
  Raven.logger.debug "Sending event #{event.id} to Sentry"

  content_type, encoded_data = encode(event)
  begin
    transport.send(generate_auth_header(encoded_data), encoded_data,
                 :content_type => content_type)
  rescue => e
    Raven.logger.error "Unable to record event with remote Sentry server (#{e.class} - #{e.message})"
    return
  end

  return event
end