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

Sentry ignore proxy system configuration #2131

Closed
miquelbar opened this issue Oct 6, 2023 · 2 comments · Fixed by #2161
Closed

Sentry ignore proxy system configuration #2131

miquelbar opened this issue Oct 6, 2023 · 2 comments · Fixed by #2161
Assignees

Comments

@miquelbar
Copy link

Issue Description

Sentry Ruby does not appear to utilize the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables when a system configures to use a proxy. This issue is causing Sentry to be unable to communicate with Sentry.io

Reproduction Steps

Our system has been set up with the following environment variables to enable proxy usage:

HTTPS_PROXY=http://proxy.internal:3128
no_proxy=localhost
NO_PROXY=localhost
https_proxy=http://proxy.internal:3128
http_proxy=http://proxy.internal:3128
HTTP_PROXY=http://proxy.internal:3128

When I attempted to validate the Sentry execution, I used the following code:

require 'sentry-ruby'

Sentry.init do |config|
  config.dsn = 'https://[email protected]/zzzz'

  config.breadcrumbs_logger = [:sentry_logger, :http_logger]
  config.debug = true

  # Sync events
  config.background_worker_threads = 0

  # To activate performance monitoring, set one of these options.
  # We recommend adjusting the value in production:
  config.traces_sample_rate = 1.0
  # or
  config.traces_sampler = lambda do |context|
    0.5
  end
end

Sentry.capture_message("test message")

I encountered the following error:

Event capturing failed: Failed to open TCP connection to yyyy.ingest.sentry.io:443 (execution expired)

Nevertheless, when I execute:

uri = URI('https://[email protected]/zzzz')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.get(uri.request_uri)

I'm able to connect to Sentry:

=> #<Net::HTTPNotFound 404 Not Found readbody=true>

So, to be able to connect Sentry I explicitly need to define config.transport.proxy on the initializer:

require 'sentry-ruby'

Sentry.init do |config|
  config.dsn = 'https://[email protected]/zzzz'

  config.breadcrumbs_logger = [:sentry_logger, :http_logger]
  config.debug = true
  config.transport.proxy = "http://proxy.internal:3128"

  # Sync events
  config.background_worker_threads = 0

  # To activate performance monitoring, set one of these options.
  # We recommend adjusting the value in production:
  config.traces_sample_rate = 1.0
  # or
  config.traces_sampler = lambda do |context|
    0.5
  end
end

Sentry.capture_message("test message")

Expected Behavior

When the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables are defined, Sentry Ruby should use these settings to route its network requests through the configured proxy, without having to specify the proxy configuration using config.transport.proxy

Actual Behavior

Currently, Sentry Ruby appears to ignore the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables, which results in Sentry's inability to communicate with Sentry.io due to proxy-related issues.

Ruby Version

3.2.0

SDK Version

5.11.0

Integration and Its Version

No response

Sentry Config

No response

@sl0thentr0py
Copy link
Member

@st0012 the only thing we'd need to do is drop the nil in the third argument p_addr here

::Net::HTTP.new(server.hostname, server.port, nil)

do you see any problems with doing so?

@st0012
Copy link
Collaborator

st0012 commented Oct 9, 2023

@sl0thentr0py Yeah I think that's the right solution here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants