Skip to content

Commit

Permalink
Use proto-generated types as domain model
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <ys@uber.com>
  • Loading branch information
Yuri Shkuro committed Jun 6, 2018
1 parent b99fb5a commit 17f0397
Show file tree
Hide file tree
Showing 68 changed files with 2,001 additions and 2,095 deletions.
3 changes: 3 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ codecov:
notify:
require_ci_to_pass: yes

# see https://docs.codecov.io/docs/ignoring-paths
ignore:
- "jaeger.pb*.go"
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ cover: nocover
@echo pre-compiling tests
@time go test -i $(ALL_PKGS)
@./scripts/cover.sh $(shell go list $(TOP_PKGS))
grep -E -v 'jaeger.pb.*.go' cover.out > cover-nogen.out
mv cover-nogen.out cover.out
go tool cover -html=cover.out -o cover.html

.PHONY: nocover
Expand Down Expand Up @@ -338,4 +340,4 @@ $$GOPATH/src/ \
model/proto/jaeger.proto

# Workaround for https://github.com/grpc-ecosystem/grpc-gateway/issues/229.
sed -i '' "s/empty.Empty/types.Empty/g" model/proto/jaeger.pb.gw.go
sed -i '' "s/empty.Empty/types.Empty/g" model/jaeger.pb.gw.go
4 changes: 2 additions & 2 deletions cmd/collector/app/sanitizer/utf8_sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func (s *utf8Sanitizer) Sanitize(span *model.Span) *model.Span {
func (s *utf8Sanitizer) logSpan(span *model.Span, message string, field zapcore.Field) {
s.logger.Info(
message,
zap.String("traceId", span.TraceID.String()),
zap.String("spanID", span.SpanID.String()), field)
zap.String("trace_id", span.TraceID.String()),
zap.String("span_id", span.SpanID.String()), field)
}

func sanitizeKV(keyValues model.KeyValues) {
Expand Down
10 changes: 6 additions & 4 deletions cmd/query/app/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"testing"
"time"

"github.com/gogo/protobuf/jsonpb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -183,14 +184,15 @@ func TestGetTrace(t *testing.T) {
}

makeMockTrace := func(t *testing.T) *model.Trace {
bytes, err := json.Marshal(mockTrace)
out := new(bytes.Buffer)
err := new(jsonpb.Marshaler).Marshal(out, mockTrace)
require.NoError(t, err)
var trace *model.Trace
require.NoError(t, json.Unmarshal(bytes, &trace))
var trace model.Trace
require.NoError(t, jsonpb.Unmarshal(out, &trace))
trace.Spans[1].References = []model.SpanRef{
{TraceID: model.TraceID{High: 0, Low: 0}},
}
return trace
return &trace
}

extractTraces := func(t *testing.T, response *structuredResponse) []ui.Trace {
Expand Down
14 changes: 14 additions & 0 deletions examples/proto/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (c) 2018 The Jaeger Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
Expand Down
14 changes: 14 additions & 0 deletions examples/proto/server/server.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (c) 2018 The Jaeger Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package server

import (
Expand Down
13 changes: 2 additions & 11 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion model/adjuster/bad_span_references_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ func TestSpanReferencesAdjuster(t *testing.T) {
assert.Len(t, trace.Spans[0].References, 0)
assert.Len(t, trace.Spans[1].References, 0)
assert.Len(t, trace.Spans[2].References, 2)
assert.Equal(t, []string{"Invalid span reference removed {RefType:child-of TraceID:0 SpanID:0}"}, trace.Spans[2].Warnings)
assert.Contains(t, trace.Spans[2].Warnings[0], "Invalid span reference removed")
}
73 changes: 37 additions & 36 deletions model/converter/json/fixtures/domain_01.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"Spans": [
"spans": [
{
"traceID": "1",
"spanID": "2",
"operationName": "test-general-conversion",
"startTime": "2017-01-26T16:46:31.639875139-05:00",
"duration": 5000,
"duration": "5000ns",
"process": {
"serviceName": "service-x"
},
Expand Down Expand Up @@ -35,32 +35,32 @@
"spanID": "2",
"operationName": "some-operation",
"startTime": "2017-01-26T16:46:31.639875139-05:00",
"duration": 5000,
"duration": "5000ns",
"tags": [
{
"key": "peer.service",
"vType": "string",
"vType": "STRING",
"vStr": "service-y"
},
{
"key": "peer.ipv4",
"vType": "int64",
"vNum": 23456
"vType": "INT64",
"vInt64": 23456
},
{
"key": "error",
"vType": "bool",
"vNum": 1
"vType": "BOOL",
"vBool": true
},
{
"key": "temperature",
"vType": "float64",
"vNum": 4634802150889750528
"vType": "FLOAT64",
"vFloat64": 72.5
},
{
"key": "blob",
"vType": "binary",
"vBlob": "AAAwOQ=="
"vType": "BINARY",
"vBinary": "AAAwOQ=="
}
],
"process": {
Expand All @@ -71,15 +71,15 @@
"traceID": "1",
"spanID": "3",
"references": [
{
"refType": "child-of",
"traceID": "1",
"spanID": "2"
}
{
"refType": "CHILD_OF",
"traceID": "1",
"spanID": "2"
}
],
"operationName": "some-operation",
"startTime": "2017-01-26T16:46:31.639875139-05:00",
"duration": 5000,
"duration": "5000ns",
"process": {
"serviceName": "service-y"
}
Expand All @@ -89,24 +89,24 @@
"spanID": "4",
"operationName": "reference-test",
"references": [
{
"refType": "child-of",
"traceID": "ff",
"spanID": "ff"
},
{
"refType": "child-of",
"traceID": "1",
"spanID": "2"
},
{
"refType": "follows-from",
"traceID": "1",
"spanID": "2"
}
{
"refType": "CHILD_OF",
"traceID": "ff",
"spanID": "ff"
},
{
"refType": "CHILD_OF",
"traceID": "1",
"spanID": "2"
},
{
"refType": "FOLLOWS_FROM",
"traceID": "1",
"spanID": "2"
}
],
"startTime": "2017-01-26T16:46:31.639875139-05:00",
"duration": 5000,
"duration": "5000ns",
"process": {
"serviceName": "service-y"
},
Expand All @@ -120,13 +120,13 @@
"operationName": "preserveParentID-test",
"references": [
{
"refType": "child-of",
"refType": "CHILD_OF",
"traceID": "1",
"spanID": "4"
}
],
"startTime": "2017-01-26T16:46:31.639875139-05:00",
"duration": 4000,
"duration": "4000ns",
"process": {
"serviceName": "service-y"
},
Expand All @@ -135,6 +135,7 @@
]
}
],
"processMap": [],
"warnings": [
"some trace warning"
]
Expand Down
40 changes: 20 additions & 20 deletions model/converter/json/fixtures/domain_es_01.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,49 @@
"operationName": "test-general-conversion",
"references": [
{
"refType": "child-of",
"refType": "CHILD_OF",
"traceID": "1",
"spanID": "3"
},
{
"refType": "follows-from",
"refType": "FOLLOWS_FROM",
"traceID": "1",
"spanID": "4"
},
{
"refType": "child-of",
"refType": "CHILD_OF",
"traceID": "ff",
"spanID": "ff"
}
],
"flags": 1,
"startTime": "2017-01-26T16:46:31.639875-05:00",
"duration": 5000,
"duration": "5000ns",
"tags": [
{
"key": "peer.service",
"vType": "string",
"vType": "STRING",
"vStr": "service-y"
},
{
"key": "peer.ipv4",
"vType": "int64",
"vNum": 23456
"vType": "INT64",
"vInt64": 23456
},
{
"key": "error",
"vType": "bool",
"vNum": 1
"vType": "BOOL",
"vBool": true
},
{
"key": "temperature",
"vType": "float64",
"vNum": 4634802150889750528
"vType": "FLOAT64",
"vFloat64": 72.5
},
{
"key": "blob",
"vType": "binary",
"vBlob": "AAAwOQ=="
"vType": "BINARY",
"vBinary": "AAAwOQ=="
}
],
"logs": [
Expand All @@ -55,8 +55,8 @@
"fields": [
{
"key": "event",
"vType": "int64",
"vNum": 123415
"vType": "INT64",
"vInt64": 123415
}
]
},
Expand All @@ -65,7 +65,7 @@
"fields": [
{
"key": "x",
"vType": "string",
"vType": "STRING",
"vStr": "y"
}
]
Expand All @@ -76,13 +76,13 @@
"tags": [
{
"key": "peer.ipv4",
"vType": "int64",
"vNum": 23456
"vType": "INT64",
"vInt64": 23456
},
{
"key": "error",
"vType": "bool",
"vNum": 1
"vType": "BOOL",
"vBool": true
}
]
}
Expand Down
Loading

0 comments on commit 17f0397

Please sign in to comment.