Skip to content

Commit 1dd338d

Browse files
authored
Decouple storage dependencies and bump Go to 1.13.x (#1886)
* Decouple storage dependencies Signed-off-by: Yuri Shkuro <[email protected]> * Bump Go version to 1.13.x Signed-off-by: Yuri Shkuro <[email protected]> * Fix quotes Signed-off-by: Yuri Shkuro <[email protected]> * Force go modules off Signed-off-by: Yuri Shkuro <[email protected]> * Fix data race Signed-off-by: Yuri Shkuro <[email protected]>
1 parent 6887ae4 commit 1dd338d

File tree

4 files changed

+29
-24
lines changed

4 files changed

+29
-24
lines changed

Diff for: .travis.yml

+12-11
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,51 @@ dist: trusty
77

88
jobs:
99
include:
10-
- go: "1.12.1"
10+
- go: "1.13.x"
1111
env:
1212
- TESTS=true
1313
- COVERAGE=true
14-
- go: "1.12.1"
14+
- go: "1.13.x"
1515
env:
1616
- PROTO_GEN_TEST=true
17-
- go: "1.12.1"
17+
- go: "1.13.x"
1818
env:
1919
- ALL_IN_ONE=true
20-
- go: "1.12.1"
20+
- go: "1.13.x"
2121
env:
2222
- CROSSDOCK=true
23-
- go: "1.12.1"
23+
- go: "1.13.x"
2424
env:
2525
- DOCKER=true
2626
- DEPLOY=true
27-
- go: "1.12.1"
27+
- go: "1.13.x"
2828
env:
2929
- ES_INTEGRATION_TEST=true
30-
- go: "1.12.1"
30+
- go: "1.13.x"
3131
env:
3232
- KAFKA_INTEGRATION_TEST=true
33-
- go: "1.12.1"
33+
- go: "1.13.x"
3434
env:
3535
- CASSANDRA_INTEGRATION_TEST=true
36-
- go: "1.12.1"
36+
- go: "1.13.x"
3737
env:
3838
- HOTROD=true
3939
- stage: Fuzz regression
4040
dist: bionic
41-
go: 1.12.x
41+
go: "1.13.x"
4242
script: ./scripts/travis/fuzzit.sh local-regression
4343
- stage: Fuzz
4444
if: branch = master AND type IN (push)
4545
dist: bionic
46-
go: 1.12.x
46+
go: "1.13.x"
4747
script: ./scripts/travis/fuzzit.sh fuzzing
4848

4949
services:
5050
- docker
5151

5252
env:
5353
global:
54+
- GO111MODULE=off
5455
- DOCKER_COMPOSE_VERSION=1.8.0
5556
- COMMIT=${TRAVIS_COMMIT::8}
5657
# DOCKER_USER

Diff for: Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ fmt:
136136

137137
.PHONY: lint-gosec
138138
lint-gosec:
139-
$(GOSEC) ./...
139+
time $(GOSEC) ./...
140140

141141
.PHONY: lint-staticcheck
142142
lint-staticcheck:
143143
@echo Running staticcheck...
144144
@cat /dev/null > $(LINT_LOG)
145-
@$(STATICCHECK) ./... \
145+
@time $(STATICCHECK) ./... \
146146
| grep -v \
147147
-e model/model.pb.go \
148148
-e thrift-gen/ \

Diff for: cmd/flags/flags.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ package flags
1717

1818
import (
1919
"flag"
20-
"fmt"
2120

2221
"github.com/pkg/errors"
2322
"github.com/spf13/viper"
2423
"go.uber.org/zap"
2524
"go.uber.org/zap/zapcore"
26-
27-
"github.com/jaegertracing/jaeger/plugin/storage"
2825
)
2926

3027
const (
@@ -62,7 +59,7 @@ type logging struct {
6259

6360
// AddFlags adds flags for SharedFlags
6461
func AddFlags(flagSet *flag.FlagSet) {
65-
flagSet.String(spanStorageType, "", fmt.Sprintf(`(deprecated) please use %s environment variable. Run this binary with "env" command for help.`, storage.SpanStorageTypeEnvVar))
62+
flagSet.String(spanStorageType, "", "(deprecated) please use SPAN_STORAGE_TYPE environment variable. Run this binary with the 'env' command for help.")
6663
AddLoggingFlag(flagSet)
6764
}
6865

Diff for: plugin/storage/memory/memory.go

+14-7
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,19 @@ func (m *Store) WriteSpan(span *model.Span) error {
150150
func (m *Store) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) {
151151
m.RLock()
152152
defer m.RUnlock()
153-
retMe := m.traces[traceID]
154-
if retMe == nil {
153+
trace, ok := m.traces[traceID]
154+
if !ok {
155155
return nil, spanstore.ErrTraceNotFound
156156
}
157-
return retMe, nil
157+
return m.copyTrace(trace), nil
158+
}
159+
160+
// Spans may still be added to traces after they are returned to user code, so make copies.
161+
func (m *Store) copyTrace(trace *model.Trace) *model.Trace {
162+
return &model.Trace{
163+
Spans: append([]*model.Span(nil), trace.Spans...),
164+
Warnings: append([]string(nil), trace.Warnings...),
165+
}
158166
}
159167

160168
// GetServices returns a list of all known services
@@ -172,14 +180,13 @@ func (m *Store) GetServices(ctx context.Context) ([]string, error) {
172180
func (m *Store) GetOperations(ctx context.Context, service string) ([]string, error) {
173181
m.RLock()
174182
defer m.RUnlock()
183+
var retMe []string
175184
if operations, ok := m.operations[service]; ok {
176-
var retMe []string
177185
for ops := range operations {
178186
retMe = append(retMe, ops)
179187
}
180-
return retMe, nil
181188
}
182-
return []string{}, nil
189+
return retMe, nil
183190
}
184191

185192
// FindTraces returns all traces in the query parameters are satisfied by a trace's span
@@ -189,7 +196,7 @@ func (m *Store) FindTraces(ctx context.Context, query *spanstore.TraceQueryParam
189196
var retMe []*model.Trace
190197
for _, trace := range m.traces {
191198
if m.validTrace(trace, query) {
192-
retMe = append(retMe, trace)
199+
retMe = append(retMe, m.copyTrace(trace))
193200
}
194201
}
195202

0 commit comments

Comments
 (0)