@@ -103,12 +103,14 @@ func (action actionCommit) handleSingleBatch(c *twoPhaseCommitter, bo *retry.Bac
103103 c .resourceGroupTagger (req )
104104 }
105105
106- trace .TraceEvent (bo .GetCtx (), trace .CategoryTxn2PC , "commit.batch.start" ,
107- zap .Uint64 ("startTS" , c .startTS ),
108- zap .Uint64 ("commitTS" , c .commitTS ),
109- zap .Uint64 ("regionID" , batch .region .GetID ()),
110- zap .Bool ("isPrimary" , batch .isPrimary ),
111- zap .Int ("keyCount" , len (keys )))
106+ if trace .IsCategoryEnabled (trace .CategoryTxn2PC ) {
107+ trace .TraceEvent (bo .GetCtx (), trace .CategoryTxn2PC , "commit.batch.start" ,
108+ zap .Uint64 ("startTS" , c .startTS ),
109+ zap .Uint64 ("commitTS" , c .commitTS ),
110+ zap .Uint64 ("regionID" , batch .region .GetID ()),
111+ zap .Bool ("isPrimary" , batch .isPrimary ),
112+ zap .Int ("keyCount" , len (keys )))
113+ }
112114
113115 tBegin := time .Now ()
114116 attempts := 0
@@ -134,9 +136,11 @@ func (action actionCommit) handleSingleBatch(c *twoPhaseCommitter, bo *retry.Bac
134136
135137 // Unexpected error occurs, return it.
136138 if err != nil {
137- trace .TraceEvent (bo .GetCtx (), trace .CategoryTxn2PC , "commit.batch.result" ,
138- zap .Uint64 ("regionID" , batch .region .GetID ()),
139- zap .Bool ("success" , false ))
139+ if trace .IsCategoryEnabled (trace .CategoryTxn2PC ) {
140+ trace .TraceEvent (bo .GetCtx (), trace .CategoryTxn2PC , "commit.batch.result" ,
141+ zap .Uint64 ("regionID" , batch .region .GetID ()),
142+ zap .Bool ("success" , false ))
143+ }
140144 return err
141145 }
142146
@@ -256,9 +260,11 @@ func (action actionCommit) handleSingleBatch(c *twoPhaseCommitter, bo *retry.Bac
256260 // Group that contains primary key is always the first.
257261 // We mark transaction's status committed when we receive the first success response.
258262 c .mu .committed = true
259- trace .TraceEvent (bo .GetCtx (), trace .CategoryTxn2PC , "commit.batch.result" ,
260- zap .Uint64 ("regionID" , batch .region .GetID ()),
261- zap .Bool ("success" , true ))
263+ if trace .IsCategoryEnabled (trace .CategoryTxn2PC ) {
264+ trace .TraceEvent (bo .GetCtx (), trace .CategoryTxn2PC , "commit.batch.result" ,
265+ zap .Uint64 ("regionID" , batch .region .GetID ()),
266+ zap .Bool ("success" , true ))
267+ }
262268 return nil
263269}
264270
0 commit comments