Skip to content

Commit

Permalink
repaces otgrpc with otel
Browse files Browse the repository at this point in the history
Signed-off-by: Afzal <[email protected]>
  • Loading branch information
afzal442 authored and afzalbin64 committed Jul 31, 2023
1 parent e0c83b0 commit 1533288
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions plugin/storage/grpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ grpc.ServeWithGRPCServer(&shared.PluginServices{
ArchiveStore: memStorePlugin,
}, func(options []googleGRPC.ServerOption) *googleGRPC.Server {
return plugin.DefaultGRPCServer([]googleGRPC.ServerOption{
googleGRPC.UnaryInterceptor(otgrpc.OpenTracingServerInterceptor(tracer)),
googleGRPC.StreamInterceptor(otgrpc.OpenTracingStreamServerInterceptor(tracer)),
grpc.UnaryInterceptor(otelgrpc.UnaryServerInterceptor(otelgrpc.WithTracerProvider(tracerProvider))),
grpc.StreamInterceptor(otelgrpc.StreamServerInterceptor(otelgrpc.WithTracerProvider(tracerProvider))),
})
})
```

Refer to `example/memstore-plugin` for more details.
Refer to `example/hotrod` for more details.

Bearer token propagation from the UI
------------------------------------
Expand Down
16 changes: 10 additions & 6 deletions plugin/storage/grpc/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"runtime"
"time"

"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"
"github.com/opentracing/opentracing-go"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/otel"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -84,8 +84,10 @@ func (c *Configuration) Close() error {

func (c *Configuration) buildRemote(logger *zap.Logger) (*ClientPluginServices, error) {
opts := []grpc.DialOption{
grpc.WithUnaryInterceptor(otgrpc.OpenTracingClientInterceptor(opentracing.GlobalTracer())),
grpc.WithStreamInterceptor(otgrpc.OpenTracingStreamClientInterceptor(opentracing.GlobalTracer())),
grpc.WithUnaryInterceptor(
otelgrpc.UnaryClientInterceptor(otelgrpc.WithTracerProvider(otel.GetTracerProvider()))),
grpc.WithStreamInterceptor(
otelgrpc.StreamClientInterceptor(otelgrpc.WithTracerProvider(otel.GetTracerProvider()))),
grpc.WithBlock(),
}
if c.RemoteTLS.Enabled {
Expand Down Expand Up @@ -125,8 +127,10 @@ func (c *Configuration) buildRemote(logger *zap.Logger) (*ClientPluginServices,

func (c *Configuration) buildPlugin(logger *zap.Logger) (*ClientPluginServices, error) {
opts := []grpc.DialOption{
grpc.WithUnaryInterceptor(otgrpc.OpenTracingClientInterceptor(opentracing.GlobalTracer())),
grpc.WithStreamInterceptor(otgrpc.OpenTracingStreamClientInterceptor(opentracing.GlobalTracer())),
grpc.WithUnaryInterceptor(
otelgrpc.UnaryClientInterceptor(otelgrpc.WithTracerProvider(otel.GetTracerProvider()))),
grpc.WithStreamInterceptor(
otelgrpc.StreamClientInterceptor(otelgrpc.WithTracerProvider(otel.GetTracerProvider()))),
}

tenancyMgr := tenancy.NewManager(&c.TenancyOpts)
Expand Down

0 comments on commit 1533288

Please sign in to comment.