diff --git a/reporter/http/http.go b/reporter/http/http.go index fbbab8a2..a01f6899 100644 --- a/reporter/http/http.go +++ b/reporter/http/http.go @@ -60,7 +60,6 @@ type httpReporter struct { reqCallback RequestCallbackFn reqTimeout time.Duration serializer reporter.SpanSerializer - doNotSample bool } // Send implements reporter @@ -153,9 +152,12 @@ func (r *httpReporter) sendBatch() error { r.logger.Printf("failed when creating the request: %s\n", err.Error()) return err } - if r.doNotSample { - req.Header.Set("b3", "0") - } + + // By default we send b3:0 header to mitigate trace reporting amplification in + // service mesh environments where the sidecar proxies might trace the call + // we do here towards the Zipkin collector. + req.Header.Set("b3", "0") + req.Header.Set("Content-Type", r.serializer.ContentType()) if r.reqCallback != nil { r.reqCallback(req) @@ -241,17 +243,6 @@ func Serializer(serializer reporter.SpanSerializer) ReporterOption { } } -// AllowSamplingReporterCalls if set to true will remove the b3:0 header on -// outgoing calls to the Zipkin collector. -// By default we send b3:0 header to mitigate trace reporting amplification in -// service mesh environments where the sidecar proxies might trace the call -// we do here towards the Zipkin collector. -func AllowSamplingReporterCalls(allow bool) ReporterOption { - return func(r *httpReporter) { - r.doNotSample = !allow - } -} - // NewReporter returns a new HTTP Reporter. // url should be the endpoint to send the spans to, e.g. // http://localhost:9411/api/v2/spans @@ -271,7 +262,6 @@ func NewReporter(url string, opts ...ReporterOption) reporter.Reporter { batchMtx: &sync.Mutex{}, serializer: reporter.JSONSerializer{}, reqTimeout: defaultTimeout, - doNotSample: true, } for _, opt := range opts { diff --git a/reporter/http/http_test.go b/reporter/http/http_test.go index cef83c29..a9618a65 100644 --- a/reporter/http/http_test.go +++ b/reporter/http/http_test.go @@ -217,20 +217,6 @@ func TestB3SamplingHeader(t *testing.T) { rep := zipkinhttp.NewReporter( ts.URL, zipkinhttp.Serializer(serializer), - zipkinhttp.AllowSamplingReporterCalls(true), - ) - for _, span := range spans { - rep.Send(*span) - } - rep.Close() - - if len(haveHeaders["B3"]) > 0 { - t.Errorf("Expected B3 header to not exist, got %v", haveHeaders["B3"]) - } - - rep = zipkinhttp.NewReporter( - ts.URL, - zipkinhttp.Serializer(serializer), ) for _, span := range spans { rep.Send(*span) @@ -240,7 +226,6 @@ func TestB3SamplingHeader(t *testing.T) { if want, have := []string{"0"}, haveHeaders["B3"]; !reflect.DeepEqual(want, have) { t.Errorf("B3 header: want: %v, have %v", want, have) } - } type headerClient struct {