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


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

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


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

def adapter
  @adapter
end

#connObject

Returns the value of attribute conn


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

def conn
  @conn
end

Instance Method Details

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


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

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::Error => ex
  error_info = ex.message
  if ex.response && ex.response[:headers]['x-sentry-error']
    error_info += " Error in headers is: #{ex.response[:headers]['x-sentry-error']}"
  end
  raise Raven::Error, error_info
end