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

[memstore-plugin]Replace ot with otel sdk #4643

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions examples/memstore-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,22 @@ package main

import (
"flag"
"fmt"
"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"
"go.opentelemetry.io/otel"
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"
afzal442 marked this conversation as resolved.
Show resolved Hide resolved
)

var configPath string

func main() {
Expand All @@ -55,21 +52,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")
panic(fmt.Errorf("failed to initialize tracer: %w", err))
}
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
defer closer.Close()
opentracing.SetGlobalTracer(tracer)
otel.SetTracerProvider(tracer.OTEL)

memStorePlugin := grpcMemory.NewStoragePlugin(memory.NewStore(), memory.NewStore())
service := &shared.PluginServices{
Expand All @@ -81,8 +68,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(tracer.OTEL))),
googleGRPC.StreamInterceptor(otelgrpc.StreamServerInterceptor(otelgrpc.WithTracerProvider(tracer.OTEL))),
})
})
}