Skip to content

Commit

Permalink
Remove Traceparent Extension Handling (#2873)
Browse files Browse the repository at this point in the history
* Remove reference to B3 and OpenTracing in channel doc

Also fix the config-tracing link.

* Replace B3 and OpenTracing headers with Traceparent header in tests

* Use the DistributedTracingExtension type in traceparent_transformer

* Remove traceparent handling from pkg/tracing

* Remove OpenCensus SetSpanID patch

* Remove deprecated NewDefaultClientGivenHttpTransport function.

This function breaks tracing by setting the transport HTTP
client. Users of this function should already be migrated to
NewDefaultHTTPClient.
  • Loading branch information
ian-mi authored Apr 1, 2020
1 parent 2b255b9 commit 71a9588
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 359 deletions.
2 changes: 1 addition & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/spec/channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ If a Channel receives an event queueing request and is unable to parse a valid
CloudEvent, then it MUST reject the request.

The Channel MUST pass through all tracing information as CloudEvents attributes.
In particular, it MUST translate any incoming OpenTracing or B3 headers to the
In particular, it MUST translate any incoming W3C Tracecontext headers to the
[Distributed Tracing Extension](https://github.com/cloudevents/spec/blob/v1.0/extensions/distributed-tracing.md).
The Channel SHOULD sample and write traces to the location specified in
[`config-tracing`](https://github.com/cloudevents/spec/blob/v1.0/extensions/distributed-tracing.md).
[`config-tracing`](https://github.com/knative/eventing/blob/master/config/config-tracing.yaml).

##### HTTP

Expand Down
18 changes: 0 additions & 18 deletions hack/set-span-id.patch

This file was deleted.

7 changes: 0 additions & 7 deletions hack/update-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,3 @@ rm -rf $(find vendor/ -name 'BUILD.bazel')

update_licenses third_party/VENDOR-LICENSE \
$(find . -name "*.go" | grep -v vendor | xargs grep "package main" | cut -d: -f1 | xargs -n1 dirname | uniq)

# HACK HACK HACK
# The only way we found to create a consistent Trace tree without any missing Spans is to
# artificially set the SpanId. See pkg/tracing/traceparent.go for more details.
# Produced with:
# git diff origin/master HEAD -- vendor/go.opencensus.io/trace/trace.go > ./hack/set-span-id.patch
git apply ${REPO_ROOT_DIR}/hack/set-span-id.patch
8 changes: 2 additions & 6 deletions pkg/broker/filter/filter_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,8 @@ func TestReceiver(t *testing.T) {
Header: http.Header{
// foo won't pass filtering.
"foo": []string{"bar"},
// b3 will not pass filtering.
"B3": []string{"0"},
// X-B3-Foo will not pass filtering.
"X-B3-Foo": []string{"abc"},
// X-Ot-Foo will not pass filtering.
"X-Ot-Foo": []string{"haden"},
// traceparent will not pass filtering.
"Traceparent": []string{"0"},
// Knative-Foo will pass as a prefix match.
"Knative-Foo": []string{"baz", "qux"},
// X-Request-Id will pass as an exact header match.
Expand Down
3 changes: 1 addition & 2 deletions pkg/channel/event_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ func TestEventReceiver_ServeHTTP(t *testing.T) {
// Ce headers won't pass through our header filtering as they should actually be set in the CloudEvent itself,
// as extensions. The SDK then sets them as as Ce- headers when sending them through HTTP.
"cE-not-pass-through": {"true"},
"x-B3-pass": {"will not pass"},
"x-ot-pass": {"will not pass"},
"Traceparent": {"will not pass"},
},
body: "event-body",
host: "test-name.test-namespace.svc." + utils.GetClusterDomainName(),
Expand Down
3 changes: 1 addition & 2 deletions pkg/channel/message_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ func TestMessageReceiver_ServeHTTP(t *testing.T) {
// Ce headers won't pass through our header filtering as they should actually be set in the CloudEvent itself,
// as extensions. The SDK then sets them as as Ce- headers when sending them through HTTP.
"cE-not-pass-through": {"true"},
"x-B3-pass": {"will not pass"},
"x-ot-pass": {"will not pass"},
"Traceparent": {"will not pass"},
},
host: "test-name.test-namespace.svc." + utils.GetClusterDomainName(),
receiverFunc: func(ctx context.Context, r ChannelReference, m binding.Message, transformers []binding.TransformerFactory, additionalHeaders nethttp.Header) error {
Expand Down
23 changes: 0 additions & 23 deletions pkg/kncloudevents/good_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,6 @@ func NewDefaultClient(target ...string) (cloudevents.Client, error) {
return NewDefaultHTTPClient(t)
}

// NewDefaultClientGivenHttpTransport is deprecated: use NewDefaultHTTPClient instead.
func NewDefaultClientGivenHttpTransport(t *cloudevents.HTTPTransport, connectionArgs *ConnectionArgs, opts ...client.Option) (cloudevents.Client, error) {
// Add connection options to the default transport.
var base = nethttp.DefaultTransport.(*nethttp.Transport).Clone()
connectionArgs.ConfigureTransport(base)
t.Client = &nethttp.Client{
Transport: base,
}

if opts == nil {
opts = make([]client.Option, 0)
}
opts = append(opts, cloudevents.WithUUIDs(), cloudevents.WithTimeNow())

// Use the transport to make a new CloudEvents client.
c, err := cloudevents.NewClient(t, opts...)

if err != nil {
return nil, err
}
return c, nil
}

// NewDefaultHTTPClient creates a new client from an HTTP transport.
func NewDefaultHTTPClient(t *cloudevents.HTTPTransport, opts ...client.Option) (cloudevents.Client, error) {
if opts == nil {
Expand Down
8 changes: 2 additions & 6 deletions pkg/mtbroker/filter/filter_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,8 @@ func TestReceiver(t *testing.T) {
Header: http.Header{
// foo won't pass filtering.
"foo": []string{"bar"},
// b3 will not pass filtering.
"B3": []string{"0"},
// X-B3-Foo will not pass filtering.
"X-B3-Foo": []string{"abc"},
// X-Ot-Foo will not pass filtering.
"X-Ot-Foo": []string{"haden"},
// Traceparent will not pass filtering.
"Traceparent": []string{"0"},
// Knative-Foo will pass as a prefix match.
"Knative-Foo": []string{"baz", "qux"},
// X-Request-Id will pass as an exact header match.
Expand Down
111 changes: 0 additions & 111 deletions pkg/tracing/traceparent.go

This file was deleted.

Loading

0 comments on commit 71a9588

Please sign in to comment.