Class: Raven::Transports::HTTP

Inherits:
Transport show all
Defined in:
lib/raven/transports/http.rb

Instance Attribute Summary collapse

Attributes inherited from Transport

#configuration

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ HTTP

Returns a new instance of HTTP.



11
12
13
14
15
# File 'lib/raven/transports/http.rb', line 11

def initialize(*args)
  super
  self.adapter = configuration.http_adapter || Faraday.default_adapter
  self.conn = set_conn
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



9
10
11
# File 'lib/raven/transports/http.rb', line 9

def adapter
  @adapter
end

#connObject

Returns the value of attribute conn.



9
10
11
# File 'lib/raven/transports/http.rb', line 9

def conn
  @conn
end

Instance Method Details

#send_event(auth_header, data, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/raven/transports/http.rb', line 17

def send_event(auth_header, data, options = {})
  unless configuration.sending_allowed?
    logger.debug("Event not sent: #{configuration.error_messages}")
  end

  project_id = configuration[:project_id]
  path = configuration[:path] + "/"

  conn.post "#{path}api/#{project_id}/store/" do |req|
    req.headers['Content-Type'] = options[:content_type]
    req.headers['X-Sentry-Auth'] = auth_header
    req.body = data
  end
rescue Faraday::ClientError => ex
  error_info = ex.message
  error_info += " Error in headers is: #{ex.response[:headers]['x-sentry-error']}" if ex.response[:headers]['x-sentry-error']
  raise Raven::Error, error_info
end