Skip to content

Commit 0f0a284

Browse files
authored
Remove skipping span creation by checking parent spans (#2980)
* Remove skipping span creation by checking parent spans * Update CHANGELOG
1 parent b64d9de commit 0f0a284

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Unreleased
2+
3+
### Changed
4+
5+
* `go-redis` won't skip span creation if the parent spans is not recording. ([#2980](https://github.com/redis/go-redis/issues/2980))
6+
Users can use the OpenTelemetry sampler to control the sampling behavior.
7+
For instance, you can use the `ParentBased(NeverSample())` sampler from `go.opentelemetry.io/otel/sdk/trace` to keep
8+
a similar behavior (drop orphan spans) of `go-redis` as before.
9+
110
## [9.0.5](https://github.com/redis/go-redis/compare/v9.0.4...v9.0.5) (2023-05-29)
211

312

extra/redisotel/tracing.go

-12
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ func newTracingHook(connString string, opts ...TracingOption) *tracingHook {
9191

9292
func (th *tracingHook) DialHook(hook redis.DialHook) redis.DialHook {
9393
return func(ctx context.Context, network, addr string) (net.Conn, error) {
94-
if !trace.SpanFromContext(ctx).IsRecording() {
95-
return hook(ctx, network, addr)
96-
}
97-
9894
ctx, span := th.conf.tracer.Start(ctx, "redis.dial", th.spanOpts...)
9995
defer span.End()
10096

@@ -109,10 +105,6 @@ func (th *tracingHook) DialHook(hook redis.DialHook) redis.DialHook {
109105

110106
func (th *tracingHook) ProcessHook(hook redis.ProcessHook) redis.ProcessHook {
111107
return func(ctx context.Context, cmd redis.Cmder) error {
112-
if !trace.SpanFromContext(ctx).IsRecording() {
113-
return hook(ctx, cmd)
114-
}
115-
116108
fn, file, line := funcFileLine("github.com/redis/go-redis")
117109

118110
attrs := make([]attribute.KeyValue, 0, 8)
@@ -145,10 +137,6 @@ func (th *tracingHook) ProcessPipelineHook(
145137
hook redis.ProcessPipelineHook,
146138
) redis.ProcessPipelineHook {
147139
return func(ctx context.Context, cmds []redis.Cmder) error {
148-
if !trace.SpanFromContext(ctx).IsRecording() {
149-
return hook(ctx, cmds)
150-
}
151-
152140
fn, file, line := funcFileLine("github.com/redis/go-redis")
153141

154142
attrs := make([]attribute.KeyValue, 0, 8)

0 commit comments

Comments
 (0)