Skip to content
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
347 changes: 197 additions & 150 deletions Gopkg.lock

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,17 @@
[prune]
go-tests = true
unused-packages = true
non-go = 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
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down Expand Up @@ -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 \
Copy link
Member

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. before model/proto/model_test.proto

-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 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use $(PROTO_INCLUDES)?

-I plugin/storage/grpc/proto \
--gogo_out=plugins=grpc,$(PROTO_GOGO_MAPPINGS):$(PWD)/plugin/storage/grpc/proto \
plugin/storage/grpc/proto/storage.proto
75 changes: 75 additions & 0 deletions cmd/noop-grpc-plugin/load_test.go
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: "",
},
},
})
}
}
92 changes: 92 additions & 0 deletions cmd/noop-grpc-plugin/main.go
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
}
22 changes: 0 additions & 22 deletions model/dependencies.go

This file was deleted.

Loading