Class: Sentry::HTTPTransport
- Defined in:
- lib/sentry/transport/http_transport.rb
Constant Summary collapse
- GZIP_ENCODING =
"gzip"- GZIP_THRESHOLD =
1024 * 30
- CONTENT_TYPE =
'application/x-sentry-envelope'
Constants inherited from Transport
Transport::PROTOCOL_VERSION, Transport::USER_AGENT
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Attributes inherited from Transport
Instance Method Summary collapse
-
#initialize(*args) ⇒ HTTPTransport
constructor
A new instance of HTTPTransport.
- #send_data(data) ⇒ Object
Methods inherited from Transport
#encode, #generate_auth_header, #send_event
Constructor Details
#initialize(*args) ⇒ HTTPTransport
Returns a new instance of HTTPTransport.
12 13 14 15 16 17 |
# File 'lib/sentry/transport/http_transport.rb', line 12 def initialize(*args) super @adapter = @transport_configuration.http_adapter || Faraday.default_adapter @conn = set_conn @endpoint = @dsn.envelope_endpoint end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
10 11 12 |
# File 'lib/sentry/transport/http_transport.rb', line 10 def adapter @adapter end |
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
10 11 12 |
# File 'lib/sentry/transport/http_transport.rb', line 10 def conn @conn end |
Instance Method Details
#send_data(data) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sentry/transport/http_transport.rb', line 19 def send_data(data) encoding = "" if should_compress?(data) data = Zlib.gzip(data) encoding = GZIP_ENCODING end conn.post @endpoint do |req| req.headers['Content-Type'] = CONTENT_TYPE req.headers['Content-Encoding'] = encoding req.headers['X-Sentry-Auth'] = generate_auth_header req.body = data end rescue Faraday::Error => e error_info = e. if e.response error_info += "\nbody: #{e.response[:body]}" error_info += " Error in headers is: #{e.response[:headers]['x-sentry-error']}" if e.response[:headers]['x-sentry-error'] end raise Sentry::ExternalError, error_info end |