-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - gRPC Plugin framework #1214
Closed
olivierboucher
wants to merge
11
commits into
jaegertracing:master
from
olivierboucher:plugin-framework
Closed
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9e168f8
Add New Storage Plugin Framework
olivierboucher 7ed4b57
Added Memory GRPC Plugin. Renamed packages (#422)
olivierboucher b0bd321
Refactored gRPC storage plugin protos
olivierboucher 5299fa1
Removed .editorconfig file
olivierboucher 530a14a
Added support for gRPC plugin configuration
olivierboucher ac915c0
Added benchmark for noop SpanWriter vs gRPC based noop plugin
olivierboucher e66dbed
Updated gRPC plugin & protos to implement latest SpanReader
olivierboucher 00ffde5
Fixed proto generation introduced when switching to Dep
olivierboucher d2091e2
Fixed issue introduced moving TraceID to model.proto
olivierboucher b5a7007
Added tests for gRPC storage factory and options
olivierboucher 1a1436d
Add empty test files to fix build
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,9 +323,11 @@ 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, \ | ||
|
@@ -386,3 +388,15 @@ proto-install: | |
./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger | ||
# ./vendor/github.com/mwitkow/go-proto-validators/protoc-gen-govalidators \ | ||
# ./vendor/github.com/rakyll/statik | ||
|
||
.PHONY: plugin-proto | ||
plugin-proto: | ||
protoc \ | ||
-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 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we use |
||
-I plugin/storage/grpc/proto \ | ||
--gogo_out=plugins=grpc,$(PROTO_GOGO_MAPPINGS):$(PWD)/plugin/storage/grpc/proto \ | ||
plugin/storage/grpc/proto/storage.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/jaegertracing/jaeger/model" | ||
"github.com/jaegertracing/jaeger/plugin/storage/grpc" | ||
"github.com/spf13/viper" | ||
"github.com/uber/jaeger-lib/metrics/prometheus" | ||
"go.uber.org/zap" | ||
"testing" | ||
"time" | ||
) | ||
|
||
var logger = zap.NewNop() | ||
|
||
func BenchmarkNoopSpanWriter(b *testing.B) { | ||
s := &noopStore{} | ||
|
||
for n := 0; n < b.N; n++ { | ||
s.WriteSpan(&model.Span{ | ||
TraceID:model.NewTraceID(1, 2), | ||
SpanID:model.NewSpanID(1), | ||
OperationName: "test", | ||
StartTime: time.Now(), | ||
Duration: 1 * time.Second, | ||
Process: model.NewProcess("process", []model.KeyValue{ | ||
|
||
}), | ||
ProcessID: "process_id", | ||
Tags: []model.KeyValue{ | ||
{ | ||
Key:"test", | ||
VStr: "", | ||
}, | ||
}, | ||
}) | ||
} | ||
} | ||
|
||
func BenchmarkGRPCNoopSpanWriter(b *testing.B) { | ||
v := viper.New() | ||
|
||
v.Set("grpc-storage-plugin.binary", "noop-grpc-plugin") | ||
|
||
f := grpc.NewFactory() | ||
f.InitFromViper(v) | ||
|
||
metricsFactory := prometheus.New() | ||
|
||
f.Initialize( metricsFactory, logger) | ||
|
||
sw, err := f.CreateSpanWriter() | ||
if err != nil { | ||
b.Fatal(err) | ||
} | ||
|
||
for n := 0; n < b.N; n++ { | ||
sw.WriteSpan(&model.Span{ | ||
TraceID:model.NewTraceID(1, 2), | ||
SpanID:model.NewSpanID(1), | ||
OperationName: "test", | ||
StartTime: time.Now(), | ||
Duration: 1 * time.Second, | ||
Process: model.NewProcess("process", []model.KeyValue{ | ||
|
||
}), | ||
ProcessID: "process_id", | ||
Tags: []model.KeyValue{ | ||
{ | ||
Key:"test", | ||
VStr: "", | ||
}, | ||
}, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// 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 ( | ||
"context" | ||
"flag" | ||
"github.com/hashicorp/go-plugin" | ||
"github.com/jaegertracing/jaeger/model" | ||
"github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" | ||
"github.com/jaegertracing/jaeger/plugin/storage/memory" | ||
"github.com/jaegertracing/jaeger/storage/spanstore" | ||
"github.com/spf13/viper" | ||
"path" | ||
"strings" | ||
"time" | ||
) | ||
|
||
var configPath string | ||
|
||
func main() { | ||
flag.StringVar(&configPath, "config", "", "A path to the plugin's configuration file") | ||
flag.Parse() | ||
|
||
if configPath != "" { | ||
viper.SetConfigFile(path.Base(configPath)) | ||
viper.AddConfigPath(path.Dir(configPath)) | ||
} | ||
|
||
v := viper.New() | ||
v.AutomaticEnv() | ||
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_")) | ||
|
||
opts := memory.Options{} | ||
opts.InitFromViper(v) | ||
|
||
plugin.Serve(&plugin.ServeConfig{ | ||
HandshakeConfig: shared.Handshake, | ||
VersionedPlugins: map[int]plugin.PluginSet{ | ||
1: map[string]plugin.Plugin{ | ||
shared.StoragePluginIdentifier: &shared.StorageGRPCPlugin{ | ||
Impl: &noopStore{}, | ||
}, | ||
}, | ||
}, | ||
GRPCServer: plugin.DefaultGRPCServer, | ||
}) | ||
} | ||
|
||
type noopStore struct { | ||
|
||
} | ||
|
||
func (*noopStore) GetDependencies(endTs time.Time, lookback time.Duration) ([]model.DependencyLink, error) { | ||
return nil, nil | ||
} | ||
|
||
func (*noopStore) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) { | ||
return nil, nil | ||
} | ||
|
||
func (*noopStore) GetServices(ctx context.Context) ([]string, error) { | ||
return nil, nil | ||
} | ||
|
||
func (*noopStore) GetOperations(ctx context.Context, service string) ([]string, error) { | ||
return nil, nil | ||
} | ||
|
||
func (*noopStore) FindTraces(ctx context.Context, query *spanstore.TraceQueryParameters) ([]*model.Trace, error) { | ||
return nil,nil | ||
} | ||
|
||
func (*noopStore) FindTraceIDs(ctx context.Context, query *spanstore.TraceQueryParameters) ([]model.TraceID, error) { | ||
return nil, nil | ||
} | ||
|
||
func (*noopStore) WriteSpan(span *model.Span) error { | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is not an independent model, let's add the compile step to the main
proto
target, e.g. beforemodel/proto/model_test.proto