Skip to content

Commit b98d756

Browse files
authored
breaking(reporter): removes B3 header option for HTTP reporting. (#178)
1 parent f2e3397 commit b98d756

File tree

2 files changed

+6
-31
lines changed

2 files changed

+6
-31
lines changed

reporter/http/http.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ type httpReporter struct {
6060
reqCallback RequestCallbackFn
6161
reqTimeout time.Duration
6262
serializer reporter.SpanSerializer
63-
doNotSample bool
6463
}
6564

6665
// Send implements reporter
@@ -153,9 +152,12 @@ func (r *httpReporter) sendBatch() error {
153152
r.logger.Printf("failed when creating the request: %s\n", err.Error())
154153
return err
155154
}
156-
if r.doNotSample {
157-
req.Header.Set("b3", "0")
158-
}
155+
156+
// By default we send b3:0 header to mitigate trace reporting amplification in
157+
// service mesh environments where the sidecar proxies might trace the call
158+
// we do here towards the Zipkin collector.
159+
req.Header.Set("b3", "0")
160+
159161
req.Header.Set("Content-Type", r.serializer.ContentType())
160162
if r.reqCallback != nil {
161163
r.reqCallback(req)
@@ -241,17 +243,6 @@ func Serializer(serializer reporter.SpanSerializer) ReporterOption {
241243
}
242244
}
243245

244-
// AllowSamplingReporterCalls if set to true will remove the b3:0 header on
245-
// outgoing calls to the Zipkin collector.
246-
// By default we send b3:0 header to mitigate trace reporting amplification in
247-
// service mesh environments where the sidecar proxies might trace the call
248-
// we do here towards the Zipkin collector.
249-
func AllowSamplingReporterCalls(allow bool) ReporterOption {
250-
return func(r *httpReporter) {
251-
r.doNotSample = !allow
252-
}
253-
}
254-
255246
// NewReporter returns a new HTTP Reporter.
256247
// url should be the endpoint to send the spans to, e.g.
257248
// http://localhost:9411/api/v2/spans
@@ -271,7 +262,6 @@ func NewReporter(url string, opts ...ReporterOption) reporter.Reporter {
271262
batchMtx: &sync.Mutex{},
272263
serializer: reporter.JSONSerializer{},
273264
reqTimeout: defaultTimeout,
274-
doNotSample: true,
275265
}
276266

277267
for _, opt := range opts {

reporter/http/http_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,6 @@ func TestB3SamplingHeader(t *testing.T) {
217217
rep := zipkinhttp.NewReporter(
218218
ts.URL,
219219
zipkinhttp.Serializer(serializer),
220-
zipkinhttp.AllowSamplingReporterCalls(true),
221-
)
222-
for _, span := range spans {
223-
rep.Send(*span)
224-
}
225-
rep.Close()
226-
227-
if len(haveHeaders["B3"]) > 0 {
228-
t.Errorf("Expected B3 header to not exist, got %v", haveHeaders["B3"])
229-
}
230-
231-
rep = zipkinhttp.NewReporter(
232-
ts.URL,
233-
zipkinhttp.Serializer(serializer),
234220
)
235221
for _, span := range spans {
236222
rep.Send(*span)
@@ -240,7 +226,6 @@ func TestB3SamplingHeader(t *testing.T) {
240226
if want, have := []string{"0"}, haveHeaders["B3"]; !reflect.DeepEqual(want, have) {
241227
t.Errorf("B3 header: want: %v, have %v", want, have)
242228
}
243-
244229
}
245230

246231
type headerClient struct {

0 commit comments

Comments
 (0)