Search code examples
pythonhttp-proxysentry

How to use the Python Sentry SDK (raven-python) with a HTTP proxy


I have a webapp which uses the raven-python SDK for Sentry for error reporting. I want outbound requests of that SDK to go through a HTTP proxy.

What would be the best way to do this?


Solution

  • You can use an alternative Transport such as the requests one. With the requests transport you can use environment variables to set the proxy: http://docs.python-requests.org/en/master/user/advanced/#proxies

    Example:

    from raven.transport.threaded_requests import ThreadedRequestsHTTPTransport
    
    Client('...', transport=ThreadedRequestsHTTPTransport)
    

    And in your environment, set HTTPS_PROXY=https://localhost:9090 or something like that.