Skip to content

Commit

Permalink
Merge branch 'master' into fix-#1723
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Apr 9, 2022
2 parents f9a6501 + 72396ce commit 42308ad
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
- Fixes [#1745](https://github.com/getsentry/sentry-ruby/issues/1745)
- Fix `sentry-rails`'s tracing spans not nesting issue - [#1784](https://github.com/getsentry/sentry-ruby/pull/1784)
- Fixes [#1723](https://github.com/getsentry/sentry-ruby/issues/1723)
- Update `config.transport.proxy` to allow String and URI values as previously supported by `sentry-ruby` versions <= 4.8 using Faraday
- Fixes [#1782](https://github.com/getsentry/sentry-ruby/issues/1782)

### Refactoring

Expand Down Expand Up @@ -81,8 +83,8 @@

<img width="80%" src="https://user-images.githubusercontent.com/6536764/157057827-2893527e-7973-4901-a070-bd78a720574a.png">

The SDK now supports [automatic session tracking / release health](https://docs.sentry.io/product/releases/health/) by default in Rack based applications.
Aggregate statistics on successful / errored requests are collected and sent to the server every minute.
The SDK now supports [automatic session tracking / release health](https://docs.sentry.io/product/releases/health/) by default in Rack based applications.
Aggregate statistics on successful / errored requests are collected and sent to the server every minute.
To use this feature, make sure the SDK can detect your app's release. Or you have set it with:

```ruby
Expand Down
16 changes: 15 additions & 1 deletion sentry-ruby/lib/sentry/transport/http_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def conn
server = URI(@dsn.server)

connection =
if proxy = @transport_configuration.proxy
if proxy = normalize_proxy(@transport_configuration.proxy)
::Net::HTTP.new(server.hostname, server.port, proxy[:uri].hostname, proxy[:uri].port, proxy[:user], proxy[:password])
else
::Net::HTTP.new(server.hostname, server.port, nil)
Expand All @@ -148,6 +148,20 @@ def conn
connection
end

def normalize_proxy(proxy)
return proxy unless proxy

case proxy
when String
uri = URI(proxy)
{ uri: uri, user: uri.user, password: uri.password }
when URI
{ uri: proxy, user: proxy.user, password: proxy.password }
when Hash
proxy
end
end

def ssl_configuration
configuration = {
verify: @transport_configuration.ssl_verification,
Expand Down
26 changes: 26 additions & 0 deletions sentry-ruby/spec/sentry/transport/http_transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,32 @@
subject.send_data(data)
end

it "accepts a custom proxy string" do
configuration.transport.proxy = "https://stan:foobar@example.com:8080"

stub_request(fake_response) do |_, http_obj|
expect(http_obj.proxy_address).to eq("example.com")
expect(http_obj.proxy_user).to eq("stan")
expect(http_obj.proxy_pass).to eq("foobar")
expect(http_obj.proxy_port).to eq(8080)
end

subject.send_data(data)
end

it "accepts a custom proxy URI" do
configuration.transport.proxy = URI("https://stan:foobar@example.com:8080")

stub_request(fake_response) do |_, http_obj|
expect(http_obj.proxy_address).to eq("example.com")
expect(http_obj.proxy_user).to eq("stan")
expect(http_obj.proxy_pass).to eq("foobar")
expect(http_obj.proxy_port).to eq(8080)
end

subject.send_data(data)
end

it "accepts custom timeout" do
configuration.transport.timeout = 10

Expand Down
3 changes: 3 additions & 0 deletions sentry-sidekiq/lib/sentry-sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class Railtie < ::Rails::Railtie
config.server_middleware do |chain|
chain.add Sentry::Sidekiq::SentryContextServerMiddleware
end
config.client_middleware do |chain|
chain.add Sentry::Sidekiq::SentryContextClientMiddleware
end
end

Sidekiq.configure_client do |config|
Expand Down
1 change: 1 addition & 0 deletions sentry-sidekiq/spec/sentry/sidekiq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
it "registers error handlers and middlewares" do
expect(Sidekiq.error_handlers).to include(described_class::ErrorHandler)
expect(Sidekiq.server_middleware.entries.first.klass).to eq(described_class::SentryContextServerMiddleware)
expect(Sidekiq.client_middleware.entries.first.klass).to eq(described_class::SentryContextClientMiddleware)
end

it "captues exception raised in the worker" do
Expand Down

0 comments on commit 42308ad

Please sign in to comment.