From d8c8ff38c766b38da4c0c39fb5c46f46e5fb7337 Mon Sep 17 00:00:00 2001 From: Sam Xie Date: Tue, 23 Apr 2024 16:48:58 -0700 Subject: [PATCH 1/2] Remove skipping span creation by checking parent spans --- extra/redisotel/tracing.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/extra/redisotel/tracing.go b/extra/redisotel/tracing.go index 2c6c1b0b5..3d5f3426c 100644 --- a/extra/redisotel/tracing.go +++ b/extra/redisotel/tracing.go @@ -91,10 +91,6 @@ func newTracingHook(connString string, opts ...TracingOption) *tracingHook { func (th *tracingHook) DialHook(hook redis.DialHook) redis.DialHook { return func(ctx context.Context, network, addr string) (net.Conn, error) { - if !trace.SpanFromContext(ctx).IsRecording() { - return hook(ctx, network, addr) - } - ctx, span := th.conf.tracer.Start(ctx, "redis.dial", th.spanOpts...) defer span.End() @@ -109,10 +105,6 @@ func (th *tracingHook) DialHook(hook redis.DialHook) redis.DialHook { func (th *tracingHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook { return func(ctx context.Context, cmd redis.Cmder) error { - if !trace.SpanFromContext(ctx).IsRecording() { - return hook(ctx, cmd) - } - fn, file, line := funcFileLine("github.com/redis/go-redis") attrs := make([]attribute.KeyValue, 0, 8) @@ -145,10 +137,6 @@ func (th *tracingHook) ProcessPipelineHook( hook redis.ProcessPipelineHook, ) redis.ProcessPipelineHook { return func(ctx context.Context, cmds []redis.Cmder) error { - if !trace.SpanFromContext(ctx).IsRecording() { - return hook(ctx, cmds) - } - fn, file, line := funcFileLine("github.com/redis/go-redis") attrs := make([]attribute.KeyValue, 0, 8) From 08940e44192b0cf6ecceb6067fe062de08ad164a Mon Sep 17 00:00:00 2001 From: Sam Xie Date: Tue, 23 Apr 2024 17:07:19 -0700 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 297438a9f..e1652b179 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## Unreleased + +### Changed + +* `go-redis` won't skip span creation if the parent spans is not recording. ([#2980](https://github.com/redis/go-redis/issues/2980)) + Users can use the OpenTelemetry sampler to control the sampling behavior. + For instance, you can use the `ParentBased(NeverSample())` sampler from `go.opentelemetry.io/otel/sdk/trace` to keep + a similar behavior (drop orphan spans) of `go-redis` as before. + ## [9.0.5](https://github.com/redis/go-redis/compare/v9.0.4...v9.0.5) (2023-05-29)