@@ -101,14 +101,16 @@ func (th *tracingHook) DialHook(hook redis.DialHook) redis.DialHook {
101101
102102func (th * tracingHook ) ProcessHook (hook redis.ProcessHook ) redis.ProcessHook {
103103 return func (ctx context.Context , cmd redis.Cmder ) error {
104- fn , file , line := funcFileLine ("github.com/redis/go-redis" )
105104
106105 attrs := make ([]attribute.KeyValue , 0 , 8 )
107- attrs = append (attrs ,
108- semconv .CodeFunction (fn ),
109- semconv .CodeFilepath (file ),
110- semconv .CodeLineNumber (line ),
111- )
106+ if th .conf .callerEnabled {
107+ fn , file , line := funcFileLine ("github.com/redis/go-redis" )
108+ attrs = append (attrs ,
109+ semconv .CodeFunction (fn ),
110+ semconv .CodeFilepath (file ),
111+ semconv .CodeLineNumber (line ),
112+ )
113+ }
112114
113115 if th .conf .dbStmtEnabled {
114116 cmdString := rediscmd .CmdString (cmd )
@@ -133,16 +135,20 @@ func (th *tracingHook) ProcessPipelineHook(
133135 hook redis.ProcessPipelineHook ,
134136) redis.ProcessPipelineHook {
135137 return func (ctx context.Context , cmds []redis.Cmder ) error {
136- fn , file , line := funcFileLine ("github.com/redis/go-redis" )
137-
138138 attrs := make ([]attribute.KeyValue , 0 , 8 )
139139 attrs = append (attrs ,
140- semconv .CodeFunction (fn ),
141- semconv .CodeFilepath (file ),
142- semconv .CodeLineNumber (line ),
143140 attribute .Int ("db.redis.num_cmd" , len (cmds )),
144141 )
145142
143+ if th .conf .callerEnabled {
144+ fn , file , line := funcFileLine ("github.com/redis/go-redis" )
145+ attrs = append (attrs ,
146+ semconv .CodeFunction (fn ),
147+ semconv .CodeFilepath (file ),
148+ semconv .CodeLineNumber (line ),
149+ )
150+ }
151+
146152 summary , cmdsString := rediscmd .CmdsString (cmds )
147153 if th .conf .dbStmtEnabled {
148154 attrs = append (attrs , semconv .DBStatement (cmdsString ))
0 commit comments