Skip to content

Commit

Permalink
Merge branch 'master' into bump-go-plugin-1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
yurishkuro authored Oct 29, 2020
2 parents ca1d89f + ee3bbee commit 149fbed
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 21 deletions.
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 8 additions & 2 deletions cmd/agent/app/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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++ {
Expand Down
6 changes: 5 additions & 1 deletion cmd/collector/app/zipkin/jsonv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions cmd/collector/app/zipkin/jsonv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion cmd/opentelemetry/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,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=
Expand Down
7 changes: 7 additions & 0 deletions empty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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".
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,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=
Expand Down
18 changes: 15 additions & 3 deletions pkg/testutils/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"strings"
"sync"
"testing"

"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand All @@ -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",
Expand All @@ -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
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/testutils/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 0 additions & 1 deletion tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 149fbed

Please sign in to comment.