Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sentry-ruby: 4.8.3 → 5.0.1 (major) #880

Merged
merged 1 commit into from
Jan 28, 2022

Conversation

depfu[bot]
Copy link
Contributor

@depfu depfu bot commented Jan 27, 2022

Here is everything you need to know about this update. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ sentry-ruby (4.8.3 → 5.0.1) · Repo · Changelog

Release Notes

5.0.1

  • Don't reuse Net::HTTP objects in HTTPTransport #1696

5.0.0

Breaking Change - Goodbye faraday 👋

TL;DR: If you are already on version 4.9 and do not use config.transport.http_adapter and config.transport.faraday_builder, you don't need to change anything.

This version removes the dependency of faraday and replaces related implementation with the Net::HTTP standard library.

Why?

Since the old sentry-raven SDK, we've been using faraday as the HTTP client for years (see HTTPTransport). It's an amazing tool that saved us many work and allowed us to focus on SDK features.

But because many users also use faraday themselves and have their own version requirements, managing this dependency has become harder over the past few years. Just to list a few related issues:

And with the release of faraday 2.0, we could only imagine it getting even more difficult (which it kind of did, see #1663).

So we think it's time to say goodbye to it with this release.

What's changed?

By default, the SDK used faraday's net_http adapter, which is also built on top of Net::HTTP. So this change shouldn't impact most of the users.

The only noticeable changes are the removal of 2 faraday-specific transport configurations:

  • config.transport.http_adapter
  • config.transport.faraday_builder

If you are already on version 4.9 and do not use those configuration options, it'll be as simple as bundle update.

What if I still want to use faraday to send my events?

sentry-ruby already allows users to set a custom transport class with:

Sentry.init do |config|
  config.transport.transport_class = MyTransportClass
end

So to use a faraday-based transport, you can:

  1. Build a FaradayTransport like this:
require 'sentry/transport/http_transport'
require 'faraday'

class FaradayTransport < Sentry::HTTPTransport
attr_reader :adapter

def initialize(*args)
@adapter = :net_http
super
end

def send_data(data)
encoding = ""

<span class="pl-k">if</span> <span class="pl-en">should_compress?</span><span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">)</span>
  <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-v">Zlib</span><span class="pl-kos">.</span><span class="pl-en">gzip</span><span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">)</span>
  <span class="pl-s1">encoding</span> <span class="pl-c1">=</span> <span class="pl-c1">GZIP_ENCODING</span>
<span class="pl-k">end</span>

<span class="pl-s1">response</span> <span class="pl-c1">=</span> <span class="pl-en">conn</span><span class="pl-kos">.</span><span class="pl-en">post</span> <span class="pl-c1">@endpoint</span> <span class="pl-k">do</span> |<span class="pl-s1">req</span>|
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-s">'Content-Type'</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-c1">CONTENT_TYPE</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-s">'Content-Encoding'</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">encoding</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-s">'X-Sentry-Auth'</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">generate_auth_header</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">body</span> <span class="pl-c1">=</span> <span class="pl-s1">data</span>
<span class="pl-k">end</span>

<span class="pl-k">if</span> <span class="pl-en">has_rate_limited_header?</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">)</span>
  <span class="pl-en">handle_rate_limited_response</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">)</span>
<span class="pl-k">end</span>

rescue Faraday::Error => e
error_info = e.message

<span class="pl-k">if</span> <span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span>
  <span class="pl-k">if</span> <span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:status</span><span class="pl-kos">]</span> == <span class="pl-c1">429</span>
    <span class="pl-en">handle_rate_limited_response</span><span class="pl-kos">(</span><span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:headers</span><span class="pl-kos">]</span><span class="pl-kos">)</span>
  <span class="pl-k">else</span>
    <span class="pl-s1">error_info</span> += <span class="pl-s">"<span class="pl-cce">\n</span>body: <span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:body</span><span class="pl-kos">]</span><span class="pl-kos">}</span></span>"</span>
    <span class="pl-s1">error_info</span> += <span class="pl-s">" Error in headers is: <span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:headers</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s">'x-sentry-error'</span><span class="pl-kos">]</span><span class="pl-kos">}</span></span>"</span> <span class="pl-k">if</span> <span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:headers</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s">'x-sentry-error'</span><span class="pl-kos">]</span>
  <span class="pl-k">end</span>
<span class="pl-k">end</span>

<span class="pl-en">raise</span> <span class="pl-v">Sentry</span>::<span class="pl-v">ExternalError</span><span class="pl-kos">,</span> <span class="pl-s1">error_info</span>

end

private

def set_conn
server = @dsn.server

<span class="pl-en">log_debug</span><span class="pl-kos">(</span><span class="pl-s">"Sentry HTTP Transport connecting to <span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-s1">server</span><span class="pl-kos">}</span></span>"</span><span class="pl-kos">)</span>

<span class="pl-v">Faraday</span><span class="pl-kos">.</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-s1">server</span><span class="pl-kos">,</span> <span class="pl-pds">:ssl</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">ssl_configuration</span><span class="pl-kos">,</span> <span class="pl-pds">:proxy</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">@transport_configuration</span><span class="pl-kos">.</span><span class="pl-en">proxy</span><span class="pl-kos">)</span> <span class="pl-k">do</span> |<span class="pl-s1">builder</span>|
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">response</span> <span class="pl-pds">:raise_error</span>
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">options</span><span class="pl-kos">.</span><span class="pl-en">merge!</span> <span class="pl-en">faraday_opts</span>
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-pds">:user_agent</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s">"sentry-ruby/<span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-v">Sentry</span>::<span class="pl-c1">VERSION</span><span class="pl-kos">}</span></span>"</span>
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">adapter</span><span class="pl-kos">(</span>*<span class="pl-en">adapter</span><span class="pl-kos">)</span>
<span class="pl-k">end</span>

end

def faraday_opts
[:timeout, :open_timeout].each_with_object({}) do |opt, memo|
memo[opt] = @transport_configuration.public_send(opt) if @transport_configuration.public_send(opt)
end
end

def ssl_configuration
{
verify: @transport_configuration.ssl_verification,
ca_file: @transport_configuration.ssl_ca_file
}.merge(@transport_configuration.ssl || {})
end
end

  1. Set config.transport.transport = FaradayTransport

Please keep in mind that this may not work in the future when the SDK changes its HTTPTransport implementation.

4.9.2

Bug Fixes

  • Directly execute ActionCable's action if the SDK is not initialized #1692

4.9.1

Bug Fixes

  • Add workaround for ConnectionStub's missing interface #1686
  • Don't initialize Event objects when they won't be sent #1687

4.9.0

Features

  • Add Action Cable exception capturing (Rails 6+) #1638
  • Add request body & query string to Net::HTTP breadcrumb #1637

When config.send_default_pii is set as true, :http_logger will include query string and request body in the breadcrumbs it logs.

  • Add tracing support to ActionCable integration #1640

Bug Fixes

  • Fix Net::HTTP breadcrump url when using Net::HTTP.new #1637
  • Fix trace span creation when using Net::HTTP.start #1637
  • Remove incorrect backtrace attribute from Event #1672

Documentation

  • Document Transaction and Span classes #1653
  • Document Client and Scope classes #1659
  • Document Event and interface classes #1675
  • Document TransactionEvent and breadcrumb-related classes #1676
  • Use macro to avoid duplicated documentation #1677

Refactoring

  • Minor improvements on Net::HTTP patch #1651
  • Deprecate unnecessarily exposed attributes #1652
  • Refactor Net::HTTP patch #1656
  • Deprecate Event#configuration #1661
  • Explicitly passing Rack related configurations #1662
  • Refactor RequestInterface #1673

Does any of this look wrong? Please let us know.

✳️ sentry-rails (4.8.3 → 5.0.1) · Repo · Changelog

Release Notes

5.0.1

  • Don't reuse Net::HTTP objects in HTTPTransport #1696

5.0.0

Breaking Change - Goodbye faraday 👋

TL;DR: If you are already on version 4.9 and do not use config.transport.http_adapter and config.transport.faraday_builder, you don't need to change anything.

This version removes the dependency of faraday and replaces related implementation with the Net::HTTP standard library.

Why?

Since the old sentry-raven SDK, we've been using faraday as the HTTP client for years (see HTTPTransport). It's an amazing tool that saved us many work and allowed us to focus on SDK features.

But because many users also use faraday themselves and have their own version requirements, managing this dependency has become harder over the past few years. Just to list a few related issues:

And with the release of faraday 2.0, we could only imagine it getting even more difficult (which it kind of did, see #1663).

So we think it's time to say goodbye to it with this release.

What's changed?

By default, the SDK used faraday's net_http adapter, which is also built on top of Net::HTTP. So this change shouldn't impact most of the users.

The only noticeable changes are the removal of 2 faraday-specific transport configurations:

  • config.transport.http_adapter
  • config.transport.faraday_builder

If you are already on version 4.9 and do not use those configuration options, it'll be as simple as bundle update.

What if I still want to use faraday to send my events?

sentry-ruby already allows users to set a custom transport class with:

Sentry.init do |config|
  config.transport.transport_class = MyTransportClass
end

So to use a faraday-based transport, you can:

  1. Build a FaradayTransport like this:
require 'sentry/transport/http_transport'
require 'faraday'

class FaradayTransport < Sentry::HTTPTransport
attr_reader :adapter

def initialize(*args)
@adapter = :net_http
super
end

def send_data(data)
encoding = ""

<span class="pl-k">if</span> <span class="pl-en">should_compress?</span><span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">)</span>
  <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-v">Zlib</span><span class="pl-kos">.</span><span class="pl-en">gzip</span><span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">)</span>
  <span class="pl-s1">encoding</span> <span class="pl-c1">=</span> <span class="pl-c1">GZIP_ENCODING</span>
<span class="pl-k">end</span>

<span class="pl-s1">response</span> <span class="pl-c1">=</span> <span class="pl-en">conn</span><span class="pl-kos">.</span><span class="pl-en">post</span> <span class="pl-c1">@endpoint</span> <span class="pl-k">do</span> |<span class="pl-s1">req</span>|
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-s">'Content-Type'</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-c1">CONTENT_TYPE</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-s">'Content-Encoding'</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">encoding</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-s">'X-Sentry-Auth'</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">generate_auth_header</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">body</span> <span class="pl-c1">=</span> <span class="pl-s1">data</span>
<span class="pl-k">end</span>

<span class="pl-k">if</span> <span class="pl-en">has_rate_limited_header?</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">)</span>
  <span class="pl-en">handle_rate_limited_response</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">)</span>
<span class="pl-k">end</span>

rescue Faraday::Error => e
error_info = e.message

<span class="pl-k">if</span> <span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span>
  <span class="pl-k">if</span> <span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:status</span><span class="pl-kos">]</span> == <span class="pl-c1">429</span>
    <span class="pl-en">handle_rate_limited_response</span><span class="pl-kos">(</span><span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:headers</span><span class="pl-kos">]</span><span class="pl-kos">)</span>
  <span class="pl-k">else</span>
    <span class="pl-s1">error_info</span> += <span class="pl-s">"<span class="pl-cce">\n</span>body: <span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:body</span><span class="pl-kos">]</span><span class="pl-kos">}</span></span>"</span>
    <span class="pl-s1">error_info</span> += <span class="pl-s">" Error in headers is: <span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:headers</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s">'x-sentry-error'</span><span class="pl-kos">]</span><span class="pl-kos">}</span></span>"</span> <span class="pl-k">if</span> <span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:headers</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s">'x-sentry-error'</span><span class="pl-kos">]</span>
  <span class="pl-k">end</span>
<span class="pl-k">end</span>

<span class="pl-en">raise</span> <span class="pl-v">Sentry</span>::<span class="pl-v">ExternalError</span><span class="pl-kos">,</span> <span class="pl-s1">error_info</span>

end

private

def set_conn
server = @dsn.server

<span class="pl-en">log_debug</span><span class="pl-kos">(</span><span class="pl-s">"Sentry HTTP Transport connecting to <span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-s1">server</span><span class="pl-kos">}</span></span>"</span><span class="pl-kos">)</span>

<span class="pl-v">Faraday</span><span class="pl-kos">.</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-s1">server</span><span class="pl-kos">,</span> <span class="pl-pds">:ssl</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">ssl_configuration</span><span class="pl-kos">,</span> <span class="pl-pds">:proxy</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">@transport_configuration</span><span class="pl-kos">.</span><span class="pl-en">proxy</span><span class="pl-kos">)</span> <span class="pl-k">do</span> |<span class="pl-s1">builder</span>|
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">response</span> <span class="pl-pds">:raise_error</span>
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">options</span><span class="pl-kos">.</span><span class="pl-en">merge!</span> <span class="pl-en">faraday_opts</span>
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-pds">:user_agent</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s">"sentry-ruby/<span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-v">Sentry</span>::<span class="pl-c1">VERSION</span><span class="pl-kos">}</span></span>"</span>
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">adapter</span><span class="pl-kos">(</span>*<span class="pl-en">adapter</span><span class="pl-kos">)</span>
<span class="pl-k">end</span>

end

def faraday_opts
[:timeout, :open_timeout].each_with_object({}) do |opt, memo|
memo[opt] = @transport_configuration.public_send(opt) if @transport_configuration.public_send(opt)
end
end

def ssl_configuration
{
verify: @transport_configuration.ssl_verification,
ca_file: @transport_configuration.ssl_ca_file
}.merge(@transport_configuration.ssl || {})
end
end

  1. Set config.transport.transport = FaradayTransport

Please keep in mind that this may not work in the future when the SDK changes its HTTPTransport implementation.

4.9.2

Bug Fixes

  • Directly execute ActionCable's action if the SDK is not initialized #1692

4.9.1

Bug Fixes

  • Add workaround for ConnectionStub's missing interface #1686
  • Don't initialize Event objects when they won't be sent #1687

4.9.0

Features

  • Add Action Cable exception capturing (Rails 6+) #1638
  • Add request body & query string to Net::HTTP breadcrumb #1637

When config.send_default_pii is set as true, :http_logger will include query string and request body in the breadcrumbs it logs.

  • Add tracing support to ActionCable integration #1640

Bug Fixes

  • Fix Net::HTTP breadcrump url when using Net::HTTP.new #1637
  • Fix trace span creation when using Net::HTTP.start #1637
  • Remove incorrect backtrace attribute from Event #1672

Documentation

  • Document Transaction and Span classes #1653
  • Document Client and Scope classes #1659
  • Document Event and interface classes #1675
  • Document TransactionEvent and breadcrumb-related classes #1676
  • Use macro to avoid duplicated documentation #1677

Refactoring

  • Minor improvements on Net::HTTP patch #1651
  • Deprecate unnecessarily exposed attributes #1652
  • Refactor Net::HTTP patch #1656
  • Deprecate Event#configuration #1661
  • Explicitly passing Rack related configurations #1662
  • Refactor RequestInterface #1673

Does any of this look wrong? Please let us know.

↗️ sentry-ruby-core (indirect, 4.8.3 → 5.0.1) · Repo · Changelog

Release Notes

5.0.1

  • Don't reuse Net::HTTP objects in HTTPTransport #1696

5.0.0

Breaking Change - Goodbye faraday 👋

TL;DR: If you are already on version 4.9 and do not use config.transport.http_adapter and config.transport.faraday_builder, you don't need to change anything.

This version removes the dependency of faraday and replaces related implementation with the Net::HTTP standard library.

Why?

Since the old sentry-raven SDK, we've been using faraday as the HTTP client for years (see HTTPTransport). It's an amazing tool that saved us many work and allowed us to focus on SDK features.

But because many users also use faraday themselves and have their own version requirements, managing this dependency has become harder over the past few years. Just to list a few related issues:

And with the release of faraday 2.0, we could only imagine it getting even more difficult (which it kind of did, see #1663).

So we think it's time to say goodbye to it with this release.

What's changed?

By default, the SDK used faraday's net_http adapter, which is also built on top of Net::HTTP. So this change shouldn't impact most of the users.

The only noticeable changes are the removal of 2 faraday-specific transport configurations:

  • config.transport.http_adapter
  • config.transport.faraday_builder

If you are already on version 4.9 and do not use those configuration options, it'll be as simple as bundle update.

What if I still want to use faraday to send my events?

sentry-ruby already allows users to set a custom transport class with:

Sentry.init do |config|
  config.transport.transport_class = MyTransportClass
end

So to use a faraday-based transport, you can:

  1. Build a FaradayTransport like this:
require 'sentry/transport/http_transport'
require 'faraday'

class FaradayTransport < Sentry::HTTPTransport
attr_reader :adapter

def initialize(*args)
@adapter = :net_http
super
end

def send_data(data)
encoding = ""

<span class="pl-k">if</span> <span class="pl-en">should_compress?</span><span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">)</span>
  <span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-v">Zlib</span><span class="pl-kos">.</span><span class="pl-en">gzip</span><span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">)</span>
  <span class="pl-s1">encoding</span> <span class="pl-c1">=</span> <span class="pl-c1">GZIP_ENCODING</span>
<span class="pl-k">end</span>

<span class="pl-s1">response</span> <span class="pl-c1">=</span> <span class="pl-en">conn</span><span class="pl-kos">.</span><span class="pl-en">post</span> <span class="pl-c1">@endpoint</span> <span class="pl-k">do</span> |<span class="pl-s1">req</span>|
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-s">'Content-Type'</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-c1">CONTENT_TYPE</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-s">'Content-Encoding'</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s1">encoding</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-s">'X-Sentry-Auth'</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-en">generate_auth_header</span>
  <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">body</span> <span class="pl-c1">=</span> <span class="pl-s1">data</span>
<span class="pl-k">end</span>

<span class="pl-k">if</span> <span class="pl-en">has_rate_limited_header?</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">)</span>
  <span class="pl-en">handle_rate_limited_response</span><span class="pl-kos">(</span><span class="pl-s1">response</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">)</span>
<span class="pl-k">end</span>

rescue Faraday::Error => e
error_info = e.message

<span class="pl-k">if</span> <span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span>
  <span class="pl-k">if</span> <span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:status</span><span class="pl-kos">]</span> == <span class="pl-c1">429</span>
    <span class="pl-en">handle_rate_limited_response</span><span class="pl-kos">(</span><span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:headers</span><span class="pl-kos">]</span><span class="pl-kos">)</span>
  <span class="pl-k">else</span>
    <span class="pl-s1">error_info</span> += <span class="pl-s">"<span class="pl-cce">\n</span>body: <span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:body</span><span class="pl-kos">]</span><span class="pl-kos">}</span></span>"</span>
    <span class="pl-s1">error_info</span> += <span class="pl-s">" Error in headers is: <span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:headers</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s">'x-sentry-error'</span><span class="pl-kos">]</span><span class="pl-kos">}</span></span>"</span> <span class="pl-k">if</span> <span class="pl-en">e</span><span class="pl-kos">.</span><span class="pl-s1">response</span><span class="pl-kos">[</span><span class="pl-pds">:headers</span><span class="pl-kos">]</span><span class="pl-kos">[</span><span class="pl-s">'x-sentry-error'</span><span class="pl-kos">]</span>
  <span class="pl-k">end</span>
<span class="pl-k">end</span>

<span class="pl-en">raise</span> <span class="pl-v">Sentry</span>::<span class="pl-v">ExternalError</span><span class="pl-kos">,</span> <span class="pl-s1">error_info</span>

end

private

def set_conn
server = @dsn.server

<span class="pl-en">log_debug</span><span class="pl-kos">(</span><span class="pl-s">"Sentry HTTP Transport connecting to <span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-s1">server</span><span class="pl-kos">}</span></span>"</span><span class="pl-kos">)</span>

<span class="pl-v">Faraday</span><span class="pl-kos">.</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-s1">server</span><span class="pl-kos">,</span> <span class="pl-pds">:ssl</span> <span class="pl-c1">=&gt;</span> <span class="pl-en">ssl_configuration</span><span class="pl-kos">,</span> <span class="pl-pds">:proxy</span> <span class="pl-c1">=&gt;</span> <span class="pl-c1">@transport_configuration</span><span class="pl-kos">.</span><span class="pl-en">proxy</span><span class="pl-kos">)</span> <span class="pl-k">do</span> |<span class="pl-s1">builder</span>|
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">response</span> <span class="pl-pds">:raise_error</span>
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">options</span><span class="pl-kos">.</span><span class="pl-en">merge!</span> <span class="pl-en">faraday_opts</span>
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">headers</span><span class="pl-kos">[</span><span class="pl-pds">:user_agent</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-s">"sentry-ruby/<span class="pl-s1"><span class="pl-kos">#{</span><span class="pl-v">Sentry</span>::<span class="pl-c1">VERSION</span><span class="pl-kos">}</span></span>"</span>
  <span class="pl-s1">builder</span><span class="pl-kos">.</span><span class="pl-en">adapter</span><span class="pl-kos">(</span>*<span class="pl-en">adapter</span><span class="pl-kos">)</span>
<span class="pl-k">end</span>

end

def faraday_opts
[:timeout, :open_timeout].each_with_object({}) do |opt, memo|
memo[opt] = @transport_configuration.public_send(opt) if @transport_configuration.public_send(opt)
end
end

def ssl_configuration
{
verify: @transport_configuration.ssl_verification,
ca_file: @transport_configuration.ssl_ca_file
}.merge(@transport_configuration.ssl || {})
end
end

  1. Set config.transport.transport = FaradayTransport

Please keep in mind that this may not work in the future when the SDK changes its HTTPTransport implementation.

4.9.2

Bug Fixes

  • Directly execute ActionCable's action if the SDK is not initialized #1692

4.9.1

Bug Fixes

  • Add workaround for ConnectionStub's missing interface #1686
  • Don't initialize Event objects when they won't be sent #1687

4.9.0

Features

  • Add Action Cable exception capturing (Rails 6+) #1638
  • Add request body & query string to Net::HTTP breadcrumb #1637

When config.send_default_pii is set as true, :http_logger will include query string and request body in the breadcrumbs it logs.

  • Add tracing support to ActionCable integration #1640

Bug Fixes

  • Fix Net::HTTP breadcrump url when using Net::HTTP.new #1637
  • Fix trace span creation when using Net::HTTP.start #1637
  • Remove incorrect backtrace attribute from Event #1672

Documentation

  • Document Transaction and Span classes #1653
  • Document Client and Scope classes #1659
  • Document Event and interface classes #1675
  • Document TransactionEvent and breadcrumb-related classes #1676
  • Use macro to avoid duplicated documentation #1677

Refactoring

  • Minor improvements on Net::HTTP patch #1651
  • Deprecate unnecessarily exposed attributes #1652
  • Refactor Net::HTTP patch #1656
  • Deprecate Event#configuration #1661
  • Explicitly passing Rack related configurations #1662
  • Refactor RequestInterface #1673

Does any of this look wrong? Please let us know.

↗️ zeitwerk (indirect, 2.5.3 → 2.5.4) · Repo · Changelog

Commits

See the full diff on Github. The new version differs by 7 commits:

🗑️ faraday (removed)

🗑️ faraday-em_http (removed)

🗑️ faraday-em_synchrony (removed)

🗑️ faraday-excon (removed)

🗑️ faraday-httpclient (removed)

🗑️ faraday-multipart (removed)

🗑️ faraday-net_http (removed)

🗑️ faraday-net_http_persistent (removed)

🗑️ faraday-patron (removed)

🗑️ faraday-rack (removed)

🗑️ faraday-retry (removed)

🗑️ multipart-post (removed)

🗑️ ruby2_keywords (removed)


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

@depfu depfu bot added the depfu label Jan 27, 2022
@mitlib mitlib temporarily deployed to thesis-submit-pr-880 January 27, 2022 17:12 Inactive
@coveralls
Copy link

coveralls commented Jan 27, 2022

Coverage Status

Coverage remained the same at 96.8% when pulling 8d6cd9e on depfu/update/sentry-ruby-5.0.1 into 9cd5f92 on main.

@depfu depfu bot changed the title Update sentry-ruby: 4.8.1 → 5.0.1 (major) Update sentry-ruby: 4.8.3 → 5.0.1 (major) Jan 28, 2022
@depfu depfu bot force-pushed the depfu/update/sentry-ruby-5.0.1 branch from 70180d3 to 8d6cd9e Compare January 28, 2022 14:11
@mitlib mitlib temporarily deployed to thesis-submit-pr-880 January 28, 2022 14:11 Inactive
@JPrevost JPrevost merged commit 186eb31 into main Jan 28, 2022
@depfu depfu bot deleted the depfu/update/sentry-ruby-5.0.1 branch January 28, 2022 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants