Esempio n. 1
0
// InstrumentedRoundTripper returns a RoundTripper pre-configured to emit
// HTTP client request metrics to AutowiredEmitter.
func InstrumentedRoundTripper(roundTripper http.RoundTripper) http.RoundTripper {
	return instrumented_round_tripper.InstrumentedRoundTripper(roundTripper, DefaultEmitter)
}
Esempio n. 2
0
// InstrumentedRoundTripper returns a RoundTripper pre-configured to emit
// HTTP client request metrics to AutowiredEmitter.
func InstrumentedRoundTripper(roundTripper http.RoundTripper) http.RoundTripper {
	return instrumented_round_tripper.InstrumentedRoundTripper(roundTripper, autowiredEmitter)
}
)

var _ = Describe("InstrumentedRoundTripper", func() {
	var fakeRoundTripper *FakeRoundTripper
	var rt http.RoundTripper
	var req *http.Request
	var fakeEmitter *fake.FakeEventEmitter

	var origin = "testRoundtripper/42"

	BeforeEach(func() {
		var err error
		fakeEmitter = fake.NewFakeEventEmitter(origin)

		fakeRoundTripper = &FakeRoundTripper{}
		rt = instrumented_round_tripper.InstrumentedRoundTripper(fakeRoundTripper, fakeEmitter)

		req, err = http.NewRequest("GET", "http://foo.example.com/", nil)
		Expect(err).ToNot(HaveOccurred())
		req.RemoteAddr = "127.0.0.1"
		req.Header.Set("User-Agent", "our-testing-client")
	})

	Context("when the round tripper is a cancelable round tripper", func() {
		var fcrt *fakeCancelableRoundTripper
		BeforeEach(func() {
			fcrt = &fakeCancelableRoundTripper{}
			rt = instrumented_round_tripper.InstrumentedRoundTripper(fcrt, fakeEmitter)
		})

		It("returns an instrumentedCancelableRoundTripper", func() {