Skip to content

Commit

Permalink
apply set-id patch to vendored dependency
Browse files Browse the repository at this point in the history
We know this is ugly, but there is currently no other way
see knative/eventing#2052
  • Loading branch information
k15r committed Nov 5, 2019
1 parent 6aa0b9c commit 6e9a926
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
13 changes: 10 additions & 3 deletions components/event-sources/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ APP_NAME = event-sources
APP_PATH = components/event-sources
BUILDPACK = eu.gcr.io/kyma-project/test-infra/buildpack-golang:go1.12
SCRIPTS_DIR = ../../common/makefiles

patched_trace = vendor/go.opencensus.io/trace/trace.go
include $(SCRIPTS_DIR)/generic-make-go.mk

.DEFAULT_GOAL := all
Expand All @@ -29,6 +31,7 @@ include $(SCRIPTS_DIR)/generic-make-go.mk

PKG := github.com/kyma-project/kyma/components/event-sources

REPO_ROOT_DIR := $(shell git rev-parse --show-toplevel)

cmds := $(wildcard cmd/*)

Expand All @@ -37,7 +40,7 @@ cmds := $(wildcard cmd/*)
all: clean $(cmds)

GOBUILD_FLAGS := -v
$(cmds): vendor
$(cmds): $(patched_trace)
@echo "+ Building $(notdir $@)"
@CGO_ENABLED=0 go build -o $(notdir $@) \
$(GOBUILD_FLAGS) \
Expand All @@ -53,13 +56,17 @@ vendor: Gopkg.lock
@echo '+ Pulling vendored dependencies'
@dep ensure -v --vendor-only

$(patched_trace): hack/set-span-id.patch vendor
@echo '+ Patching opencensus dependency'
@git apply ${REPO_ROOT_DIR}/components/event-sources/hack/set-span-id.patch


.PHONY: test

testpkgs := $(shell go list ./... | grep -vE '/apis/|/client/|/cmd/|/testing')

GOTEST_FLAGS := -cover
test: vendor
test: $(patched_trace)
@echo "+ Performing unit tests"
@go test \
$(GOTEST_FLAGS) \
Expand Down Expand Up @@ -135,7 +142,7 @@ injection: bin/injection-gen
--versioned-clientset-package $(PKG)/client/generated/clientset/internalclientset \
--external-versions-informers-package $(PKG)/client/generated/informer/externalversions

$(generators_bin): vendor
$(generators_bin): $(patched_trace)
@if [ -d ./vendor/k8s.io/code-generator/cmd/$(notdir $@) ]; then \
go build -o bin/$(notdir $@) ./vendor/k8s.io/code-generator/cmd/$(notdir $@); \
else \
Expand Down
19 changes: 19 additions & 0 deletions components/event-sources/hack/set-span-id.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This patch is directly copied from https://github.com/knative/eventing/blob/master/hack/set-span-id.patch and was originally introduced in PR-1972
There is currently an open issue to remove this patch again: https://github.com/knative/eventing/issues/2052

diff --git a/vendor/go.opencensus.io/trace/trace.go b/vendor/go.opencensus.io/trace/trace.go
index 38ead7bf..9e6fe483 100644
--- a/components/event-sources/vendor/go.opencensus.io/trace/trace.go
+++ b/components/event-sources/vendor/go.opencensus.io/trace/trace.go
@@ -261,6 +261,11 @@ func startSpanInternal(name string, hasParent bool, parent SpanContext, remotePa
return span
}

+func (s *Span) SetSpanID(spanID SpanID) {
+ s.data.SpanID = spanID
+ s.spanContext.SpanID = spanID
+}
+
// End ends the span.
func (s *Span) End() {
if s == nil {

0 comments on commit 6e9a926

Please sign in to comment.