honeycombio / libhoney-rb

Ruby library for sending data to Honeycomb
Apache License 2.0
11 stars 30 forks source link

Add proxy support #46

Closed tredman closed 5 years ago

tredman commented 5 years ago

I tested this locally with mitmproxy to verify that requests were being proxied. I can't seem to use mocks to verify the proxying though, so I'm at a loss for how to write tests for this right now.

tredman commented 5 years ago

There doesn't seem to be an easy way to test that a request went through a proxy with webmock. I tested this locally with mitmproxy and a simple script:

libhoney = Libhoney::Client.new(:writekey => "YOUR_API_KEY",
                                :dataset => "honeycomb-ruby-example",
                                :api_host => 'http://api.honeycomb.io',
                                :proxy_config => ['localhost', 8080])

ev = libhoney.event
ev.add({
    "duration_ms": 153.12,
    "method": "get",
    "hostname": "appserver15",
    "payload_length": 27
})
ev.send

Then verified this going through my local mitmproxy, so the proxy code works.

Screen Shot 2019-09-05 at 8 20 51 AM