From 6b970bb5ec88d5e6b57992cf6006dc165f143248 Mon Sep 17 00:00:00 2001 From: Afzal <94980910+afzalbin64@users.noreply.github.com> Date: Fri, 11 Aug 2023 06:38:15 +0000 Subject: [PATCH 1/4] replace otgrpc with otel Signed-off-by: Afzal <94980910+afzalbin64@users.noreply.github.com> --- examples/memstore-plugin/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/memstore-plugin/main.go b/examples/memstore-plugin/main.go index 12b519693a4..97df74689c0 100644 --- a/examples/memstore-plugin/main.go +++ b/examples/memstore-plugin/main.go @@ -18,11 +18,11 @@ import ( "flag" "strings" - "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc" "github.com/hashicorp/go-plugin" "github.com/opentracing/opentracing-go" "github.com/spf13/viper" jaegerClientConfig "github.com/uber/jaeger-client-go/config" + "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" googleGRPC "google.golang.org/grpc" "github.com/jaegertracing/jaeger/plugin/storage/grpc" @@ -81,8 +81,8 @@ func main() { } grpc.ServeWithGRPCServer(service, func(options []googleGRPC.ServerOption) *googleGRPC.Server { return plugin.DefaultGRPCServer([]googleGRPC.ServerOption{ - googleGRPC.UnaryInterceptor(otgrpc.OpenTracingServerInterceptor(tracer)), - googleGRPC.StreamInterceptor(otgrpc.OpenTracingStreamServerInterceptor(tracer)), + googleGRPC.UnaryInterceptor(otelgrpc.UnaryServerInterceptor(otelgrpc.WithTracerProvider(tracerProvider))), + googleGRPC.StreamInterceptor(otelgrpc.StreamServerInterceptor(otelgrpc.WithTracerProvider(tracerProvider))), }) }) } From 274c998fc6ca79ba6558e9ee95439a8a1b171169 Mon Sep 17 00:00:00 2001 From: Afzal <94980910+afzalbin64@users.noreply.github.com> Date: Fri, 11 Aug 2023 10:37:31 +0000 Subject: [PATCH 2/4] rmvs deprecated jaeger-client go Signed-off-by: Afzal <94980910+afzalbin64@users.noreply.github.com> --- examples/memstore-plugin/main.go | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/examples/memstore-plugin/main.go b/examples/memstore-plugin/main.go index 97df74689c0..4cd15ae4ecb 100644 --- a/examples/memstore-plugin/main.go +++ b/examples/memstore-plugin/main.go @@ -16,25 +16,23 @@ package main import ( "flag" + "log" "strings" "github.com/hashicorp/go-plugin" - "github.com/opentracing/opentracing-go" "github.com/spf13/viper" - jaegerClientConfig "github.com/uber/jaeger-client-go/config" "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" + "go.opentelemetry.io/otel" + "go.uber.org/zap" googleGRPC "google.golang.org/grpc" + "github.com/jaegertracing/jaeger/pkg/jtracer" "github.com/jaegertracing/jaeger/plugin/storage/grpc" grpcMemory "github.com/jaegertracing/jaeger/plugin/storage/grpc/memory" "github.com/jaegertracing/jaeger/plugin/storage/grpc/shared" "github.com/jaegertracing/jaeger/plugin/storage/memory" ) -const ( - serviceName = "mem-store" -) - var configPath string func main() { @@ -55,21 +53,11 @@ func main() { opts := memory.Options{} opts.InitFromViper(v) - traceCfg := &jaegerClientConfig.Configuration{ - ServiceName: serviceName, - Sampler: &jaegerClientConfig.SamplerConfig{ - Type: "const", - Param: 1.0, - }, - RPCMetrics: true, - } - - tracer, closer, err := traceCfg.NewTracer() + tracer, err := jtracer.New("mem-store") if err != nil { - panic("Failed to initialize tracer") + log.Fatal("Failed to initialize tracer", zap.Error(err)) } - defer closer.Close() - opentracing.SetGlobalTracer(tracer) + otel.SetTracerProvider(tracer.OTEL) memStorePlugin := grpcMemory.NewStoragePlugin(memory.NewStore(), memory.NewStore()) service := &shared.PluginServices{ @@ -81,8 +69,8 @@ func main() { } grpc.ServeWithGRPCServer(service, func(options []googleGRPC.ServerOption) *googleGRPC.Server { return plugin.DefaultGRPCServer([]googleGRPC.ServerOption{ - googleGRPC.UnaryInterceptor(otelgrpc.UnaryServerInterceptor(otelgrpc.WithTracerProvider(tracerProvider))), - googleGRPC.StreamInterceptor(otelgrpc.StreamServerInterceptor(otelgrpc.WithTracerProvider(tracerProvider))), + googleGRPC.UnaryInterceptor(otelgrpc.UnaryServerInterceptor(otelgrpc.WithTracerProvider(tracer.OTEL))), + googleGRPC.StreamInterceptor(otelgrpc.StreamServerInterceptor(otelgrpc.WithTracerProvider(tracer.OTEL))), }) }) } From 1ffaae93bb143fc8209352098f12319c07a524a5 Mon Sep 17 00:00:00 2001 From: Afzal <94980910+afzalbin64@users.noreply.github.com> Date: Sat, 12 Aug 2023 06:59:21 +0000 Subject: [PATCH 3/4] replaces log fatal with panic Signed-off-by: Afzal <94980910+afzalbin64@users.noreply.github.com> --- examples/memstore-plugin/main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/memstore-plugin/main.go b/examples/memstore-plugin/main.go index 4cd15ae4ecb..d67ce23012f 100644 --- a/examples/memstore-plugin/main.go +++ b/examples/memstore-plugin/main.go @@ -16,14 +16,13 @@ package main import ( "flag" - "log" + "fmt" "strings" "github.com/hashicorp/go-plugin" "github.com/spf13/viper" "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" "go.opentelemetry.io/otel" - "go.uber.org/zap" googleGRPC "google.golang.org/grpc" "github.com/jaegertracing/jaeger/pkg/jtracer" @@ -55,7 +54,7 @@ func main() { tracer, err := jtracer.New("mem-store") if err != nil { - log.Fatal("Failed to initialize tracer", zap.Error(err)) + panic(fmt.Errorf("failed to initialize tracer: %w", err)) } otel.SetTracerProvider(tracer.OTEL) From b0efb11c909f6a59c41153e73f12995f68d4c9fe Mon Sep 17 00:00:00 2001 From: Afzal <94980910+afzalbin64@users.noreply.github.com> Date: Sat, 12 Aug 2023 07:21:37 +0000 Subject: [PATCH 4/4] redeclare const for svc name Signed-off-by: Afzal <94980910+afzalbin64@users.noreply.github.com> --- examples/memstore-plugin/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/memstore-plugin/main.go b/examples/memstore-plugin/main.go index d67ce23012f..36a9b31bb07 100644 --- a/examples/memstore-plugin/main.go +++ b/examples/memstore-plugin/main.go @@ -15,6 +15,7 @@ package main import ( + "context" "flag" "fmt" "strings" @@ -32,6 +33,10 @@ import ( "github.com/jaegertracing/jaeger/plugin/storage/memory" ) +const ( + serviceName = "mem-store" +) + var configPath string func main() { @@ -52,10 +57,11 @@ func main() { opts := memory.Options{} opts.InitFromViper(v) - tracer, err := jtracer.New("mem-store") + tracer, err := jtracer.New(serviceName) if err != nil { panic(fmt.Errorf("failed to initialize tracer: %w", err)) } + defer tracer.Close(context.Background()) otel.SetTracerProvider(tracer.OTEL) memStorePlugin := grpcMemory.NewStoragePlugin(memory.NewStore(), memory.NewStore())