go-redis
go-redis copied to clipboard
redisotel does not write to Jaeger
Expected Behavior
My application should send a trace to Jaeger.
Current Behavior
Nothing happens. No error in the log, no crash of the app, no trace in Jaeger.
Steps to Reproduce
var Client *redis.Client
func main() {
connect()
exp, err := newExporter(context.Background())
if err != nil {
logger.Errorf("error creating exporter")
}
tp := newTraceProvider(exp)
tracingOption := redisotel.WithTracerProvider(tp)
if err := redisotel.InstrumentTracing(Client, tracingOption); err != nil {
logger.Errorf("error instrumenting redis client for tracing:\n%v", err)
}
Client.Set(context.TODO(), "key", "value", 0).Result()
}
func connect() error {
Client = redis.NewClient(&redis.Options{
PoolSize: configs.ModuleConfig.Redis.PoolSize,
MinIdleConns: configs.ModuleConfig.Redis.MinIdleConns,
MaxRetries: configs.ModuleConfig.Redis.MaxRetries,
Addr: configs.ModuleConfig.Redis.Hosts[0],
Username: configs.ModuleConfig.Redis.Credentials.Username,
Password: configs.ModuleConfig.Redis.Credentials.Password,
DB: configs.ModuleConfig.Redis.Database,
})
}
func newExporter(ctx context.Context) (*otlptrace.Exporter, error) {
client := otlptracehttp.NewClient(
otlptracehttp.WithEndpoint("http:11.0.0.1:4318"),
otlptracehttp.WithInsecure(),
)
return otlptrace.New(ctx, client)
}
func newTraceProvider(exp sdktrace.SpanExporter) *sdktrace.TracerProvider {
r, err := resource.Merge(
resource.Default(),
resource.NewWithAttributes(
semconv.SchemaURL,
semconv.ServiceName("serviceName"),
),
)
if err != nil {
panic(err)
}
return sdktrace.NewTracerProvider(
sdktrace.WithBatcher(exp),
sdktrace.WithResource(r),
)
}
Context (Environment)
The application is a small service running in Kubernetes with a standalone installation of Redis and Jaeger besides Kubernetes. The service is able to communicate with Redis and Jaeger, but the combination of both via redisotel does not work.
Detailed Description
Jaeger does not receive any traces from redis operations.
I can take the TraceProvider in the example, create a Tracer from it and send a trace to Jaeger with no problems, but it does not work with redisotel.
Both the configuration of the TraceProvider via redisotel.WithTracerProvider()
and otel.SetTracerProvider()
does not work.