Skip to content

Commit

Permalink
Add gRPC plugin proto changes (#1323)
Browse files Browse the repository at this point in the history
* Add gRPC plugin proto changes

Relating to issue #422 and review #1214, add proto changes
to later allow for gRPC plugins to be used.

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Change FindTraces signature to return a stream.

FindTraces can hit grpc message size limits if a large number of
spans are requested, using a stream mitigates this issue.

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Satisfy gofmt tool

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Change proto package and service names

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Delete commented out spanstorage

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Change FindTraces response to be a stream of spans

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Change from EmptyMessage to google.protobuf.Empty

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Move from using StoragePluginError to google.rpc.Status

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Remove commented code and clean up proto formatting

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Remove protobuf responses and only return successes, rely on Status
for errors

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Update Gopkg lockfile

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Update Span type to come from model.proto

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Update storage proto file

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Add generated storage plugin file to lint ignores

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Lint ignore grpc plugin generated code by name not path

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Rename FindTracesResponseChunk to SpansResponseChunk

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Add marshal/unmarshal tests for DependencyLink

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Add tests for storage protos with custom types

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Run fmt and ignore storage_test for linting

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Remove DependencyLinkSource and use string

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Update headers

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Add SpansChunkResponse test

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Update makefile protoc calls

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Update proto generated files and update license script

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Update generated storage file to new proto layout

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Add storage generated files to import order cleanup ignores

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Move storage generated file to proto-gen dir

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Remove generated plugin storage file from script ignores

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Fix copyright headers

Signed-off-by: Charles Dixon <chvckd@gmail.com>

* Update storage_test generated file

Signed-off-by: Charles Dixon <chvckd@gmail.com>
  • Loading branch information
chvck authored and yurishkuro committed Apr 3, 2019
1 parent 65a499a commit c770640
Show file tree
Hide file tree
Showing 15 changed files with 4,377 additions and 79 deletions.
12 changes: 6 additions & 6 deletions Gopkg.lock

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

12 changes: 12 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ required = [
[prune]
go-tests = true
unused-packages = true
[[prune.project]]
name = "github.com/gogo/protobuf"
non-go = false
unused-packages = false
[[prune.project]]
name = "github.com/grpc-ecosystem/grpc-gateway"
non-go = false
unused-packages = false
[[prune.project]]
name = "github.com/gogo/googleapis"
non-go = false
unused-packages = false

[[constraint]]
name = "github.com/Shopify/sarama"
Expand Down
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ALL_SRC := $(shell find . -name '*.go' \
-not -name '*_test.go' \
-not -name 'model.pb.go' \
-not -name 'model_test.pb.go' \
-not -name 'storage_test.pb.go' \
-not -path './examples/*' \
-not -path './vendor/*' \
-not -path '*/mocks/*' \
Expand Down Expand Up @@ -337,19 +338,22 @@ PROTO_INCLUDES := \
-I model/proto \
-I vendor/github.com/grpc-ecosystem/grpc-gateway \
-I vendor/github.com/gogo/googleapis \
-I vendor/github.com/gogo/protobuf/protobuf \
-I vendor/github.com/gogo/protobuf
# Remapping of std types to gogo types (must not contain spaces)
PROTO_GOGO_MAPPINGS := $(shell echo \
Mgoogle/protobuf/descriptor.proto=github.com/gogo/protobuf/types, \
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types, \
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types, \
Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types, \
Mgoogle/api/annotations.proto=github.com/gogo/googleapis/google/api, \
Mmodel.proto=github.com/jaegertracing/jaeger/model \
| sed 's/ //g')


.PHONY: proto
proto:
# Generate gogo, gRPC-Gateway, swagger, go-validators output.
# Generate gogo, gRPC-Gateway, swagger, go-validators, gRPC-storage-plugin output.
#
# -I declares import folders, in order of importance
# This is how proto resolves the protofile imports.
Expand Down Expand Up @@ -385,11 +389,23 @@ proto:
--swagger_out=allow_merge=true:$(PWD)/proto-gen/openapi/ \
model/proto/api_v2/*.proto

$(PROTOC) \
$(PROTO_INCLUDES) \
-I plugin/storage/grpc/proto \
--gogo_out=plugins=grpc,$(PROTO_GOGO_MAPPINGS):$(PWD)/proto-gen/storage_v1 \
plugin/storage/grpc/proto/storage.proto

$(PROTOC) \
-I model/proto \
--go_out=$(PWD)/model/prototest/ \
model/proto/model_test.proto

$(PROTOC) \
-I plugin/storage/grpc/proto \
--go_out=$(PWD)/plugin/storage/grpc/proto/storageprototest/ \
plugin/storage/grpc/proto/storage_test.proto


.PHONY: proto-install
proto-install:
go get -u github.com/golang/glog
Expand Down
13 changes: 1 addition & 12 deletions model/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,11 @@

package model

// DependencyLinkSource is the source of data used to generate the dependencies.
type DependencyLinkSource string

const (
// JaegerDependencyLinkSource describes a dependency diagram that was generated from Jaeger traces.
JaegerDependencyLinkSource = DependencyLinkSource("jaeger")
JaegerDependencyLinkSource = "jaeger"
)

// DependencyLink shows dependencies between services
type DependencyLink struct {
Parent string `json:"parent"`
Child string `json:"child"`
CallCount uint64 `json:"callCount"`
Source DependencyLinkSource `json:"source"`
}

// ApplyDefaults applies defaults to the DependencyLink.
func (d DependencyLink) ApplyDefaults() DependencyLink {
if d.Source == "" {
Expand Down
2 changes: 1 addition & 1 deletion model/dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestDependencyLinkApplyDefaults(t *testing.T) {
dl := DependencyLink{}.ApplyDefaults()
assert.Equal(t, JaegerDependencyLinkSource, dl.Source)

networkSource := DependencyLinkSource("network")
networkSource := "network"
dl = DependencyLink{Source: networkSource}.ApplyDefaults()
assert.Equal(t, networkSource, dl.Source)
}
Loading

0 comments on commit c770640

Please sign in to comment.