Skip to content

Commit

Permalink
Merge branch 'main' into fix-2614
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Feb 23, 2022
2 parents ea16740 + 94b1848 commit 0affa8a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Changed

- For tracestate's members, prepend the new element and remove the oldest one, which is over capacity (#2592)
- Add event and link drop counts to the exported data from the `oltptrace` exporter. (#2601)

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions exporters/otlp/otlpmetric/otlpmetricgrpc/client_test.go
Expand Up @@ -93,7 +93,7 @@ func newGRPCExporter(t *testing.T, ctx context.Context, endpoint string, additio
}

func newExporterEndToEndTest(t *testing.T, additionalOpts []otlpmetricgrpc.Option) {
mc := runMockCollectorAtEndpoint(t, "localhost:56561")
mc := runMockCollector(t)

defer func() {
_ = mc.stop()
Expand All @@ -115,7 +115,7 @@ func newExporterEndToEndTest(t *testing.T, additionalOpts []otlpmetricgrpc.Optio
}

func TestExporterShutdown(t *testing.T) {
mc := runMockCollectorAtEndpoint(t, "localhost:56561")
mc := runMockCollector(t)
defer func() {
_ = mc.Stop()
}()
Expand Down Expand Up @@ -296,7 +296,7 @@ func TestStartErrorInvalidAddress(t *testing.T) {
}

func TestEmptyData(t *testing.T) {
mc := runMockCollectorAtEndpoint(t, "localhost:56561")
mc := runMockCollector(t)

defer func() {
_ = mc.stop()
Expand All @@ -314,7 +314,7 @@ func TestEmptyData(t *testing.T) {
}

func TestFailedMetricTransform(t *testing.T) {
mc := runMockCollectorAtEndpoint(t, "localhost:56561")
mc := runMockCollector(t)

defer func() {
_ = mc.stop()
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlptrace/otlptracegrpc/client_test.go
Expand Up @@ -374,7 +374,7 @@ func TestStartErrorInvalidAddress(t *testing.T) {
}

func TestEmptyData(t *testing.T) {
mc := runMockCollectorAtEndpoint(t, "localhost:56561")
mc := runMockCollector(t)
t.Cleanup(func() { require.NoError(t, mc.stop()) })

<-time.After(5 * time.Millisecond)
Expand Down
2 changes: 1 addition & 1 deletion internal/tools/go.mod
Expand Up @@ -5,7 +5,7 @@ go 1.16
require (
github.com/client9/misspell v0.3.4
github.com/gogo/protobuf v1.3.2
github.com/golangci/golangci-lint v1.44.1
github.com/golangci/golangci-lint v1.44.2
github.com/itchyny/gojq v0.12.6
github.com/jcchavezs/porto v0.4.0
github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad
Expand Down
12 changes: 6 additions & 6 deletions internal/tools/go.sum
Expand Up @@ -172,8 +172,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsr
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/daixiang0/gci v0.3.0 h1:6x2xp99la0TfGmdDJ6T2VrLtCoZwYUVp4/5zT8J7+Go=
github.com/daixiang0/gci v0.3.0/go.mod h1:jaASoJmv/ykO9dAAPy31iJnreV19248qKDdVWf3QgC4=
github.com/daixiang0/gci v0.3.1-0.20220208004058-76d765e3ab48 h1:9rJGqaC5do9zkvKrtRdx0HJoxj7Jd6vDa0O2eBU0AbU=
github.com/daixiang0/gci v0.3.1-0.20220208004058-76d765e3ab48/go.mod h1:jaASoJmv/ykO9dAAPy31iJnreV19248qKDdVWf3QgC4=
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -318,8 +318,8 @@ github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613 h1:9kfjN3AdxcbsZB
github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613/go.mod h1:SyvUF2NxV+sN8upjjeVYr5W7tyxaT1JVtvhKhOn2ii8=
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a h1:iR3fYXUjHCR97qWS8ch1y9zPNsgXThGwjKPrYfqMPks=
github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU=
github.com/golangci/golangci-lint v1.44.1 h1:/jcmjp9715WazPIu4oZz8KaV9xSq5HTuedjpWm/RVvc=
github.com/golangci/golangci-lint v1.44.1/go.mod h1:s0UbBHNNBlEPt8OcPsJV7IPONwQ+WEVywSk+FPpLV18=
github.com/golangci/golangci-lint v1.44.2 h1:MzvkDt1j1OHkv42/feNJVNNXRFACPp7aAWBWDo5aYQw=
github.com/golangci/golangci-lint v1.44.2/go.mod h1:KjBgkLvsTWDkhfu12iCrv0gwL1kON5KNhbyjQ6qN7Jo=
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 h1:MfyDlzVjl1hoaPzPD4Gpb/QgoRfSBR0jdhwGyAWwMSA=
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg=
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca h1:kNY3/svz5T29MYHubXix4aDDuE3RWHkPvopM/EDv/MA=
Expand Down Expand Up @@ -842,8 +842,8 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqri
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/ultraware/funlen v0.0.3 h1:5ylVWm8wsNwH5aWo9438pwvsK0QiqVuUrt9bn7S/iLA=
github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
github.com/ultraware/whitespace v0.0.4 h1:If7Va4cM03mpgrNH9k49/VOicWpGoG70XPBFFODYDsg=
github.com/ultraware/whitespace v0.0.4/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
github.com/ultraware/whitespace v0.0.5 h1:hh+/cpIcopyMYbZNVov9iSxvJU3OYQg78Sfaqzi/CzI=
github.com/ultraware/whitespace v0.0.5/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/uudashr/gocognit v1.0.5 h1:rrSex7oHr3/pPLQ0xoWq108XMU8s678FJcQ+aSfOHa4=
Expand Down
16 changes: 5 additions & 11 deletions trace/tracestate.go
Expand Up @@ -171,25 +171,19 @@ func (ts TraceState) Get(key string) string {
// specification an error is returned with the original TraceState.
//
// If adding a new list-member means the TraceState would have more members
// than is allowed an error is returned instead with the original TraceState.
// then is allowed, the new list-member will be inserted and the right-most
// list-member will be dropped in the returned TraceState.
func (ts TraceState) Insert(key, value string) (TraceState, error) {
m, err := newMember(key, value)
if err != nil {
return ts, err
}

cTS := ts.Delete(key)
if cTS.Len()+1 > maxListMembers {
// TODO (MrAlias): When the second version of the Trace Context
// specification is published this needs to not return an error.
// Instead it should drop the "right-most" member and insert the new
// member at the front.
//
// https://github.com/w3c/trace-context/pull/448
return ts, fmt.Errorf("failed to insert: %w", errMemberNumber)
if cTS.Len()+1 <= maxListMembers {
cTS.list = append(cTS.list, member{})
}

cTS.list = append(cTS.list, member{})
// When the number of members exceeds capacity, drop the "right-most".
copy(cTS.list[1:], cTS.list)
cTS.list[0] = m

Expand Down
16 changes: 11 additions & 5 deletions trace/tracestate_test.go
Expand Up @@ -482,14 +482,20 @@ func TestTraceStateInsert(t *testing.T) {
err: errInvalidKey,
},
{
name: "too many entries",
name: "drop the right-most member(oldest) in queue",
tracestate: maxMembers,
key: "keyx",
value: "valx",
expected: maxMembers,
err: errMemberNumber,
},
}
expected: func() TraceState {
// Prepend the new element and remove the oldest one, which is over capacity.
return TraceState{
list: append(
[]member{{Key: "keyx", Value: "valx"}},
maxMembers.list[:len(maxMembers.list)-1]...,
),
}
}(),
}}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit 0affa8a

Please sign in to comment.