Skip to content

Commit 617aca0

Browse files
committed
Add option to configure command exlusions for OTEL Tracing (#3479)
1 parent 9781710 commit 617aca0

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

extra/redisotel/config.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ type config struct {
1919
tp trace.TracerProvider
2020
tracer trace.Tracer
2121

22-
dbStmtEnabled bool
23-
callerEnabled bool
22+
dbStmtEnabled bool
23+
callerEnabled bool
24+
commandExclusions []string
2425

2526
// Metrics options.
2627

@@ -54,13 +55,13 @@ func (fn option) metrics() {}
5455

5556
func newConfig(opts ...baseOption) *config {
5657
conf := &config{
57-
dbSystem: "redis",
58-
attrs: []attribute.KeyValue{},
59-
60-
tp: otel.GetTracerProvider(),
61-
mp: otel.GetMeterProvider(),
62-
dbStmtEnabled: true,
63-
callerEnabled: true,
58+
dbSystem: "redis",
59+
attrs: []attribute.KeyValue{},
60+
commandExclusions: []string{},
61+
tp: otel.GetTracerProvider(),
62+
mp: otel.GetMeterProvider(),
63+
dbStmtEnabled: true,
64+
callerEnabled: true,
6465
}
6566

6667
for _, opt := range opts {
@@ -124,6 +125,13 @@ func WithCallerEnabled(on bool) TracingOption {
124125
})
125126
}
126127

128+
// WithCommandExclusions tells the tracing hook to exclude the specified redis commands.
129+
func WithCommandExclusions(exclusions []string) TracingOption {
130+
return tracingOption(func(conf *config) {
131+
conf.commandExclusions = exclusions
132+
})
133+
}
134+
127135
//------------------------------------------------------------------------------
128136

129137
type MetricsOption interface {

0 commit comments

Comments
 (0)