From c4a3b28cf51b9b116190bc42bf79353324a3e59b Mon Sep 17 00:00:00 2001 From: Marian Zagoruiko Date: Wed, 28 Oct 2020 23:58:02 +0200 Subject: [PATCH 1/2] fix: don't create tags w/ empty name for internal zipkin spans (#2596) https://github.com/jaegertracing/jaeger/issues/2595 Signed-off-by: Marian Zagoruiko --- cmd/collector/app/zipkin/jsonv2.go | 6 +++++- cmd/collector/app/zipkin/jsonv2_test.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/collector/app/zipkin/jsonv2.go b/cmd/collector/app/zipkin/jsonv2.go index a89f269429e..35a15f70073 100644 --- a/cmd/collector/app/zipkin/jsonv2.go +++ b/cmd/collector/app/zipkin/jsonv2.go @@ -84,7 +84,9 @@ func spanV2ToThrift(s *models.Span) (*zipkincore.Span, error) { if err != nil { return nil, err } - tSpan.BinaryAnnotations = append(tSpan.BinaryAnnotations, rAddrAnno) + if rAddrAnno != nil { + tSpan.BinaryAnnotations = append(tSpan.BinaryAnnotations, rAddrAnno) + } } // add local component to represent service name @@ -112,6 +114,8 @@ func remoteEndpToThrift(e *models.Endpoint, kind string) (*zipkincore.BinaryAnno key = zipkincore.CLIENT_ADDR case models.SpanKindCONSUMER, models.SpanKindPRODUCER: key = zipkincore.MESSAGE_ADDR + default: + return nil, nil } return &zipkincore.BinaryAnnotation{ diff --git a/cmd/collector/app/zipkin/jsonv2_test.go b/cmd/collector/app/zipkin/jsonv2_test.go index c7e4420a016..2c53c18d8bf 100644 --- a/cmd/collector/app/zipkin/jsonv2_test.go +++ b/cmd/collector/app/zipkin/jsonv2_test.go @@ -94,6 +94,7 @@ func TestRemoteEndpToThrift(t *testing.T) { {kind: models.SpanKindSERVER, expected: &zipkincore.BinaryAnnotation{Key: zipkincore.CLIENT_ADDR, AnnotationType: zipkincore.AnnotationType_BOOL}}, {kind: models.SpanKindPRODUCER, expected: &zipkincore.BinaryAnnotation{Key: zipkincore.MESSAGE_ADDR, AnnotationType: zipkincore.AnnotationType_BOOL}}, {kind: models.SpanKindCONSUMER, expected: &zipkincore.BinaryAnnotation{Key: zipkincore.MESSAGE_ADDR, AnnotationType: zipkincore.AnnotationType_BOOL}}, + {kind: "", expected: nil}, } for _, test := range tests { banns, err := remoteEndpToThrift(nil, test.kind) From ee3bbee410fd5aafba70e428f2e2e319de02d006 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Thu, 29 Oct 2020 01:10:22 -0400 Subject: [PATCH 2/2] Remove md-to-godoc and fix some tests (#2598) * Remove md-to-godoc We have not used it actively. Addresses report https://groups.google.com/d/msgid/jaeger-tracing/020db716-6bbc-4aed-a61c-35715f0a5c1fn%40googlegroups.com Signed-off-by: Yuri Shkuro * Add travis_wait Signed-off-by: Yuri Shkuro * Make agent test more verbose Signed-off-by: Yuri Shkuro * Remove travis_wait, make test timeout shorter than Travis timeout Signed-off-by: Yuri Shkuro * Add sleep Signed-off-by: Yuri Shkuro --- Makefile | 9 +-------- README.md | 2 -- cmd/agent/app/agent_test.go | 10 ++++++++-- cmd/opentelemetry/go.sum | 1 - empty_test.go | 7 +++++++ go.mod | 1 - go.sum | 2 -- pkg/testutils/logger.go | 18 +++++++++++++++--- pkg/testutils/logger_test.go | 5 +++++ tools.go | 1 - 10 files changed, 36 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 1b1c42b1c89..61bc175cd59 100644 --- a/Makefile +++ b/Makefile @@ -81,12 +81,6 @@ test-and-lint: test fmt lint go-gen: @echo skipping go generate ./... -.PHONY: md-to-godoc-gen -md-to-godoc-gen: - find . -name README.md -not -path "./vendor/*" -not -path "./_site/*" -not -path "./idl/*" \ - | grep -v '^./README.md' \ - | xargs -I% md-to-godoc -license -licenseFile LICENSE -input=% - .PHONY: clean clean: rm -rf cover.out .cover/ cover.html lint.log fmt.log \ @@ -153,7 +147,7 @@ all-srcs: .PHONY: cover cover: nocover - $(GOTEST) -coverprofile cover.out ./... + $(GOTEST) -timeout 5m -coverprofile cover.out ./... grep -E -v 'model.pb.*.go' cover.out > cover-nogen.out mv cover-nogen.out cover.out go tool cover -html=cover.out -o cover.html @@ -421,7 +415,6 @@ changelog: install-tools: go install github.com/wadey/gocovmerge go install golang.org/x/lint/golint - go install github.com/sectioneight/md-to-godoc go install github.com/mjibson/esc go install github.com/securego/gosec/cmd/gosec go install honnef.co/go/tools/cmd/staticcheck diff --git a/README.md b/README.md index 1cb79d7c6b8..3e3ad63e791 100644 --- a/README.md +++ b/README.md @@ -186,5 +186,3 @@ If you would like to add your organization to the list, please comment on our [hotrod-tutorial]: https://medium.com/@YuriShkuro/take-opentracing-for-a-hotrod-ride-f6e3141f7941 [gitter]: https://gitter.im/jaegertracing/Lobby [gitter-img]: https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg - -[//]: # (md-to-godoc-ignore) diff --git a/cmd/agent/app/agent_test.go b/cmd/agent/app/agent_test.go index b31346feb53..4c080e68aab 100644 --- a/cmd/agent/app/agent_test.go +++ b/cmd/agent/app/agent_test.go @@ -156,13 +156,14 @@ func TestStartStopRace(t *testing.T) { { Model: jaegerModel, Protocol: compactProtocol, + Workers: 1, Server: ServerConfiguration{ HostPort: "127.0.0.1:0", }, }, }, } - logger, logBuf := testutils.NewLogger() + logger, logBuf := testutils.NewEchoLogger(t) mBldr := &jmetrics.Builder{HTTPRoute: "/metrics", Backend: "prometheus"} metricsFactory, err := mBldr.CreateMetricsFactory("jaeger") mFactory := fork.New("internal", metrics.NullFactory, metricsFactory) @@ -177,9 +178,14 @@ func TestStartStopRace(t *testing.T) { // run with -race flag. if err := agent.Run(); err != nil { - t.Errorf("error from agent.Run(): %s", err) + t.Fatalf("error from agent.Run(): %s", err) } + // FIXME https://github.com/jaegertracing/jaeger/issues/2601 + t.Log("give some time for processors to start") + time.Sleep(500 * time.Millisecond) + + t.Log("stopping agent") agent.Stop() for i := 0; i < 1000; i++ { diff --git a/cmd/opentelemetry/go.sum b/cmd/opentelemetry/go.sum index 031e2b07ab4..a127a1d938e 100644 --- a/cmd/opentelemetry/go.sum +++ b/cmd/opentelemetry/go.sum @@ -1015,7 +1015,6 @@ github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b/go.mod h1:dA0hQrY github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sectioneight/md-to-godoc v0.0.0-20161108233149-55e43be6c335/go.mod h1:lPZq22klO8la1kyImIDhrGytugMV0TsrsZB55a+xxI0= github.com/securego/gosec v0.0.0-20200203094520-d13bb6d2420c h1:pThusIwnQVcKbuZSds3HgB/ODEqxMqZf/SgVp89JXY0= github.com/securego/gosec v0.0.0-20200203094520-d13bb6d2420c/go.mod h1:gp0gaHj0WlmPh9BdsTmo1aq6C27yIPWdxCKGFGdVKBE= github.com/securego/gosec/v2 v2.4.0 h1:ivAoWcY5DMs9n04Abc1VkqZBO0FL0h4ShTcVsC53lCE= diff --git a/empty_test.go b/empty_test.go index fbab884ec62..6becea9a8cb 100644 --- a/empty_test.go +++ b/empty_test.go @@ -13,3 +13,10 @@ // limitations under the License. package jaeger + +import "testing" + +func TestDummy(t *testing.T) { + // This is a dummy test in the root package. + // Without it `go test -v .` prints "testing: warning: no tests to run". +} diff --git a/go.mod b/go.mod index df7c029612e..670b909dcbf 100644 --- a/go.mod +++ b/go.mod @@ -56,7 +56,6 @@ require ( github.com/prometheus/procfs v0.1.3 // indirect github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 // indirect github.com/rs/cors v1.7.0 - github.com/sectioneight/md-to-godoc v0.0.0-20161108233149-55e43be6c335 github.com/securego/gosec v0.0.0-20200203094520-d13bb6d2420c github.com/soheilhy/cmux v0.1.4 github.com/spf13/afero v1.2.2 // indirect diff --git a/go.sum b/go.sum index 62214b83bda..741d510dc92 100644 --- a/go.sum +++ b/go.sum @@ -507,8 +507,6 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sectioneight/md-to-godoc v0.0.0-20161108233149-55e43be6c335 h1:ADCqR7DvFHzNHavPBA0fbYpsQk7wlA83vHJrTCYoNm8= -github.com/sectioneight/md-to-godoc v0.0.0-20161108233149-55e43be6c335/go.mod h1:lPZq22klO8la1kyImIDhrGytugMV0TsrsZB55a+xxI0= github.com/securego/gosec v0.0.0-20200203094520-d13bb6d2420c h1:pThusIwnQVcKbuZSds3HgB/ODEqxMqZf/SgVp89JXY0= github.com/securego/gosec v0.0.0-20200203094520-d13bb6d2420c/go.mod h1:gp0gaHj0WlmPh9BdsTmo1aq6C27yIPWdxCKGFGdVKBE= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= diff --git a/pkg/testutils/logger.go b/pkg/testutils/logger.go index 86cb75f3498..00fe2b63969 100644 --- a/pkg/testutils/logger.go +++ b/pkg/testutils/logger.go @@ -20,6 +20,7 @@ import ( "fmt" "strings" "sync" + "testing" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -28,6 +29,12 @@ import ( // NewLogger creates a new zap.Logger backed by a zaptest.Buffer, which is also returned. func NewLogger() (*zap.Logger, *Buffer) { + core, buf := newRecordingCore() + logger := zap.New(core) + return logger, buf +} + +func newRecordingCore() (zapcore.Core, *Buffer) { encoder := zapcore.NewJSONEncoder(zapcore.EncoderConfig{ MessageKey: "msg", LevelKey: "level", @@ -36,9 +43,14 @@ func NewLogger() (*zap.Logger, *Buffer) { EncodeDuration: zapcore.StringDurationEncoder, }) buf := &Buffer{} - logger := zap.New( - zapcore.NewCore(encoder, buf, zapcore.DebugLevel), - ) + return zapcore.NewCore(encoder, buf, zapcore.DebugLevel), buf +} + +// NewEchoLogger is similar to NewLogger, but the logs are also echoed to t.Log. +func NewEchoLogger(t *testing.T) (*zap.Logger, *Buffer) { + core, buf := newRecordingCore() + echo := zaptest.NewLogger(t).Core() + logger := zap.New(zapcore.NewTee(core, echo)) return logger, buf } diff --git a/pkg/testutils/logger_test.go b/pkg/testutils/logger_test.go index 24964d2e2aa..d36d96fdcc9 100644 --- a/pkg/testutils/logger_test.go +++ b/pkg/testutils/logger_test.go @@ -36,6 +36,11 @@ func TestNewLogger(t *testing.T) { }, log.JSONLine(0)) } +func TestNewEchoLogger(t *testing.T) { + logger, _ := NewEchoLogger(t) + logger.Warn("hello", zap.String("x", "y")) +} + func TestJSONLineError(t *testing.T) { log := &Buffer{} log.WriteString("bad-json\n") diff --git a/tools.go b/tools.go index ffb45d2b492..f949bce3e8e 100644 --- a/tools.go +++ b/tools.go @@ -22,7 +22,6 @@ import ( _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger" _ "github.com/mjibson/esc" - _ "github.com/sectioneight/md-to-godoc" _ "github.com/securego/gosec/cmd/gosec" _ "github.com/vektra/mockery/cmd/mockery" _ "github.com/wadey/gocovmerge"