Skip to content

Commit 17f0397

Browse files
author
Yuri Shkuro
committed
Use proto-generated types as domain model
Signed-off-by: Yuri Shkuro <ys@uber.com>
1 parent b99fb5a commit 17f0397

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2001
-2095
lines changed

.codecov.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ codecov:
77
notify:
88
require_ci_to_pass: yes
99

10+
# see https://docs.codecov.io/docs/ignoring-paths
11+
ignore:
12+
- "jaeger.pb*.go"

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ cover: nocover
9292
@echo pre-compiling tests
9393
@time go test -i $(ALL_PKGS)
9494
@./scripts/cover.sh $(shell go list $(TOP_PKGS))
95+
grep -E -v 'jaeger.pb.*.go' cover.out > cover-nogen.out
96+
mv cover-nogen.out cover.out
9597
go tool cover -html=cover.out -o cover.html
9698

9799
.PHONY: nocover
@@ -338,4 +340,4 @@ $$GOPATH/src/ \
338340
model/proto/jaeger.proto
339341

340342
# Workaround for https://github.com/grpc-ecosystem/grpc-gateway/issues/229.
341-
sed -i '' "s/empty.Empty/types.Empty/g" model/proto/jaeger.pb.gw.go
343+
sed -i '' "s/empty.Empty/types.Empty/g" model/jaeger.pb.gw.go

cmd/collector/app/sanitizer/utf8_sanitizer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ func (s *utf8Sanitizer) Sanitize(span *model.Span) *model.Span {
6464
func (s *utf8Sanitizer) logSpan(span *model.Span, message string, field zapcore.Field) {
6565
s.logger.Info(
6666
message,
67-
zap.String("traceId", span.TraceID.String()),
68-
zap.String("spanID", span.SpanID.String()), field)
67+
zap.String("trace_id", span.TraceID.String()),
68+
zap.String("span_id", span.SpanID.String()), field)
6969
}
7070

7171
func sanitizeKV(keyValues model.KeyValues) {

cmd/query/app/handler_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"testing"
2727
"time"
2828

29+
"github.com/gogo/protobuf/jsonpb"
2930
"github.com/stretchr/testify/assert"
3031
"github.com/stretchr/testify/mock"
3132
"github.com/stretchr/testify/require"
@@ -183,14 +184,15 @@ func TestGetTrace(t *testing.T) {
183184
}
184185

185186
makeMockTrace := func(t *testing.T) *model.Trace {
186-
bytes, err := json.Marshal(mockTrace)
187+
out := new(bytes.Buffer)
188+
err := new(jsonpb.Marshaler).Marshal(out, mockTrace)
187189
require.NoError(t, err)
188-
var trace *model.Trace
189-
require.NoError(t, json.Unmarshal(bytes, &trace))
190+
var trace model.Trace
191+
require.NoError(t, jsonpb.Unmarshal(out, &trace))
190192
trace.Spans[1].References = []model.SpanRef{
191193
{TraceID: model.TraceID{High: 0, Low: 0}},
192194
}
193-
return trace
195+
return &trace
194196
}
195197

196198
extractTraces := func(t *testing.T, response *structuredResponse) []ui.Trace {

examples/proto/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright (c) 2018 The Jaeger Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package main
216

317
import (

examples/proto/server/server.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright (c) 2018 The Jaeger Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package server
216

317
import (

glide.lock

Lines changed: 2 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

model/adjuster/bad_span_references_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ func TestSpanReferencesAdjuster(t *testing.T) {
4343
assert.Len(t, trace.Spans[0].References, 0)
4444
assert.Len(t, trace.Spans[1].References, 0)
4545
assert.Len(t, trace.Spans[2].References, 2)
46-
assert.Equal(t, []string{"Invalid span reference removed {RefType:child-of TraceID:0 SpanID:0}"}, trace.Spans[2].Warnings)
46+
assert.Contains(t, trace.Spans[2].Warnings[0], "Invalid span reference removed")
4747
}

model/converter/json/fixtures/domain_01.json

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"Spans": [
2+
"spans": [
33
{
44
"traceID": "1",
55
"spanID": "2",
66
"operationName": "test-general-conversion",
77
"startTime": "2017-01-26T16:46:31.639875139-05:00",
8-
"duration": 5000,
8+
"duration": "5000ns",
99
"process": {
1010
"serviceName": "service-x"
1111
},
@@ -35,32 +35,32 @@
3535
"spanID": "2",
3636
"operationName": "some-operation",
3737
"startTime": "2017-01-26T16:46:31.639875139-05:00",
38-
"duration": 5000,
38+
"duration": "5000ns",
3939
"tags": [
4040
{
4141
"key": "peer.service",
42-
"vType": "string",
42+
"vType": "STRING",
4343
"vStr": "service-y"
4444
},
4545
{
4646
"key": "peer.ipv4",
47-
"vType": "int64",
48-
"vNum": 23456
47+
"vType": "INT64",
48+
"vInt64": 23456
4949
},
5050
{
5151
"key": "error",
52-
"vType": "bool",
53-
"vNum": 1
52+
"vType": "BOOL",
53+
"vBool": true
5454
},
5555
{
5656
"key": "temperature",
57-
"vType": "float64",
58-
"vNum": 4634802150889750528
57+
"vType": "FLOAT64",
58+
"vFloat64": 72.5
5959
},
6060
{
6161
"key": "blob",
62-
"vType": "binary",
63-
"vBlob": "AAAwOQ=="
62+
"vType": "BINARY",
63+
"vBinary": "AAAwOQ=="
6464
}
6565
],
6666
"process": {
@@ -71,15 +71,15 @@
7171
"traceID": "1",
7272
"spanID": "3",
7373
"references": [
74-
{
75-
"refType": "child-of",
76-
"traceID": "1",
77-
"spanID": "2"
78-
}
74+
{
75+
"refType": "CHILD_OF",
76+
"traceID": "1",
77+
"spanID": "2"
78+
}
7979
],
8080
"operationName": "some-operation",
8181
"startTime": "2017-01-26T16:46:31.639875139-05:00",
82-
"duration": 5000,
82+
"duration": "5000ns",
8383
"process": {
8484
"serviceName": "service-y"
8585
}
@@ -89,24 +89,24 @@
8989
"spanID": "4",
9090
"operationName": "reference-test",
9191
"references": [
92-
{
93-
"refType": "child-of",
94-
"traceID": "ff",
95-
"spanID": "ff"
96-
},
97-
{
98-
"refType": "child-of",
99-
"traceID": "1",
100-
"spanID": "2"
101-
},
102-
{
103-
"refType": "follows-from",
104-
"traceID": "1",
105-
"spanID": "2"
106-
}
92+
{
93+
"refType": "CHILD_OF",
94+
"traceID": "ff",
95+
"spanID": "ff"
96+
},
97+
{
98+
"refType": "CHILD_OF",
99+
"traceID": "1",
100+
"spanID": "2"
101+
},
102+
{
103+
"refType": "FOLLOWS_FROM",
104+
"traceID": "1",
105+
"spanID": "2"
106+
}
107107
],
108108
"startTime": "2017-01-26T16:46:31.639875139-05:00",
109-
"duration": 5000,
109+
"duration": "5000ns",
110110
"process": {
111111
"serviceName": "service-y"
112112
},
@@ -120,13 +120,13 @@
120120
"operationName": "preserveParentID-test",
121121
"references": [
122122
{
123-
"refType": "child-of",
123+
"refType": "CHILD_OF",
124124
"traceID": "1",
125125
"spanID": "4"
126126
}
127127
],
128128
"startTime": "2017-01-26T16:46:31.639875139-05:00",
129-
"duration": 4000,
129+
"duration": "4000ns",
130130
"process": {
131131
"serviceName": "service-y"
132132
},
@@ -135,6 +135,7 @@
135135
]
136136
}
137137
],
138+
"processMap": [],
138139
"warnings": [
139140
"some trace warning"
140141
]

model/converter/json/fixtures/domain_es_01.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,49 @@
44
"operationName": "test-general-conversion",
55
"references": [
66
{
7-
"refType": "child-of",
7+
"refType": "CHILD_OF",
88
"traceID": "1",
99
"spanID": "3"
1010
},
1111
{
12-
"refType": "follows-from",
12+
"refType": "FOLLOWS_FROM",
1313
"traceID": "1",
1414
"spanID": "4"
1515
},
1616
{
17-
"refType": "child-of",
17+
"refType": "CHILD_OF",
1818
"traceID": "ff",
1919
"spanID": "ff"
2020
}
2121
],
2222
"flags": 1,
2323
"startTime": "2017-01-26T16:46:31.639875-05:00",
24-
"duration": 5000,
24+
"duration": "5000ns",
2525
"tags": [
2626
{
2727
"key": "peer.service",
28-
"vType": "string",
28+
"vType": "STRING",
2929
"vStr": "service-y"
3030
},
3131
{
3232
"key": "peer.ipv4",
33-
"vType": "int64",
34-
"vNum": 23456
33+
"vType": "INT64",
34+
"vInt64": 23456
3535
},
3636
{
3737
"key": "error",
38-
"vType": "bool",
39-
"vNum": 1
38+
"vType": "BOOL",
39+
"vBool": true
4040
},
4141
{
4242
"key": "temperature",
43-
"vType": "float64",
44-
"vNum": 4634802150889750528
43+
"vType": "FLOAT64",
44+
"vFloat64": 72.5
4545
},
4646
{
4747
"key": "blob",
48-
"vType": "binary",
49-
"vBlob": "AAAwOQ=="
48+
"vType": "BINARY",
49+
"vBinary": "AAAwOQ=="
5050
}
5151
],
5252
"logs": [
@@ -55,8 +55,8 @@
5555
"fields": [
5656
{
5757
"key": "event",
58-
"vType": "int64",
59-
"vNum": 123415
58+
"vType": "INT64",
59+
"vInt64": 123415
6060
}
6161
]
6262
},
@@ -65,7 +65,7 @@
6565
"fields": [
6666
{
6767
"key": "x",
68-
"vType": "string",
68+
"vType": "STRING",
6969
"vStr": "y"
7070
}
7171
]
@@ -76,13 +76,13 @@
7676
"tags": [
7777
{
7878
"key": "peer.ipv4",
79-
"vType": "int64",
80-
"vNum": 23456
79+
"vType": "INT64",
80+
"vInt64": 23456
8181
},
8282
{
8383
"key": "error",
84-
"vType": "bool",
85-
"vNum": 1
84+
"vType": "BOOL",
85+
"vBool": true
8686
}
8787
]
8888
}

0 commit comments

Comments
 (0)