@@ -83,14 +83,14 @@ func ReportFuncCallAndTimingCtxWithErr(ctx context.Context, tags ...Tags) func(e
8383 }
8484}
8585
86- func ReportFuncCallAndTimingWithErr (tags ... Tags ) func (err * error ) {
86+ func ReportFuncCallAndTimingWithErr (tags ... Tags ) func (err * error , tags ... Tags ) {
8787 fn := CallerFuncName (1 )
8888 reportFunc (fn , "called" , tags ... )
8989 _ , stop := reportTiming (context .Background (), tags ... )
90- return func (err * error ) {
91- stop ()
90+ return func (err * error , stopTags ... Tags ) {
91+ stop (stopTags ... )
9292 if err != nil && * err != nil {
93- ReportClosureFuncError (fn , tags ... )
93+ ReportClosureFuncError (fn , MergeTags ( MergeTags ( nil , tags ... ), stopTags ... ) )
9494 }
9595 }
9696}
@@ -111,7 +111,7 @@ func reportFunc(fn, action string, tags ...Tags) {
111111 client .Incr (fmt .Sprintf ("func.%v" , action ), tagArray , 0.77 )
112112}
113113
114- type StopTimerFunc func ()
114+ type StopTimerFunc func (tags ... Tags )
115115
116116func ReportFuncTiming (tags ... Tags ) StopTimerFunc {
117117 _ , stopFn := reportTiming (context .Background (), tags ... )
@@ -127,7 +127,7 @@ func reportTiming(ctx context.Context, tags ...Tags) (context.Context, StopTimer
127127 defer clientMux .RUnlock ()
128128
129129 if client == nil {
130- return ctx , func () {}
130+ return ctx , func (... Tags ) {}
131131 }
132132 t := time .Now ()
133133 fn := CallerFuncName (2 )
@@ -170,13 +170,15 @@ func reportTiming(ctx context.Context, tags ...Tags) (context.Context, StopTimer
170170 }
171171 }(fn , t )
172172
173- return spanCtx , func () {
173+ return spanCtx , func (stopTags ... Tags ) {
174174 d := time .Since (t )
175175 close (doneC )
176176
177+ stopTagArray := append (tagArray , JoinTags (stopTags ... )... )
178+
177179 clientMux .RLock ()
178180 defer clientMux .RUnlock ()
179- client .Timing ("func.timing" , d , tagArray , 1 )
181+ client .Timing ("func.timing" , d , stopTagArray , 1 )
180182 if span != nil {
181183 span .End ()
182184 }
@@ -187,7 +189,7 @@ func ReportClosureFuncTiming(name string, tags ...Tags) StopTimerFunc {
187189 clientMux .RLock ()
188190 defer clientMux .RUnlock ()
189191 if client == nil {
190- return func () {}
192+ return func (... Tags ) {}
191193 }
192194 t := time .Now ()
193195 tagArray := JoinTags (tags ... )
@@ -212,13 +214,14 @@ func ReportClosureFuncTiming(name string, tags ...Tags) StopTimerFunc {
212214 }
213215 }(name , t )
214216
215- return func () {
217+ return func (stopTags ... Tags ) {
216218 d := time .Since (t )
217219 close (doneC )
220+ stopTagArray := append (tagArray , JoinTags (stopTags ... )... )
218221
219222 clientMux .RLock ()
220223 defer clientMux .RUnlock ()
221- client .Timing ("func.timing" , d , tagArray , 1 )
224+ client .Timing ("func.timing" , d , stopTagArray , 1 )
222225 }
223226}
224227
0 commit comments