From b4d33f04357cd7ad7fd7c324c55e128beda12ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Ch=C3=A1vez?= Date: Mon, 21 Oct 2019 15:10:27 +0200 Subject: [PATCH] feat(reporter/http): uses an interface for http client so users can plug other clients. --- reporter/http/http.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/reporter/http/http.go b/reporter/http/http.go index fe3df45..0260df3 100644 --- a/reporter/http/http.go +++ b/reporter/http/http.go @@ -37,10 +37,15 @@ const ( defaultMaxBacklog = 1000 ) +// Client will do a request to the Zipkin HTTP Collector +type Client interface { + Do(req *http.Request) (*http.Response, error) +} + // httpReporter will send spans to a Zipkin HTTP Collector using Zipkin V2 API. type httpReporter struct { url string - client *http.Client + client Client logger *log.Logger batchInterval time.Duration batchSize int @@ -200,7 +205,7 @@ func BatchInterval(d time.Duration) ReporterOption { } // Client sets a custom http client to use. -func Client(client *http.Client) ReporterOption { +func Client(client Client) ReporterOption { return func(r *httpReporter) { r.client = client } }