@@ -434,9 +434,7 @@ func (n *node) applyMutations(ctx context.Context, proposal *pb.Proposal) (rerr
434434 // by detectPendingTxns below.
435435 startTs := posting .Oracle ().MaxAssigned ()
436436
437- if span .IsRecording () {
438- span .AddEvent ("Applying schema and types" )
439- }
437+ span .AddEvent ("Applying schema and types" )
440438 for _ , supdate := range proposal .Mutations .Schema {
441439 // We should not need to check for predicate move here.
442440 if err := detectPendingTxns (supdate .Predicate ); err != nil {
@@ -476,14 +474,10 @@ func (n *node) applyMutations(ctx context.Context, proposal *pb.Proposal) (rerr
476474 // We should only drop the predicate if there is no pending
477475 // transaction.
478476 if err := detectPendingTxns (edge .Attr ); err != nil {
479- if span .IsRecording () {
480- span .AddEvent ("Found pending transactions. Retry later." )
481- }
477+ span .AddEvent ("Found pending transactions. Retry later." )
482478 return err
483479 }
484- if span .IsRecording () {
485- span .AddEvent ("Deleting predicate" )
486- }
480+ span .AddEvent ("Deleting predicate" )
487481 return posting .DeletePredicate (ctx , edge .Attr , proposal .StartTs )
488482 }
489483 // Don't derive schema when doing deletion.
@@ -536,11 +530,9 @@ func (n *node) applyMutations(ctx context.Context, proposal *pb.Proposal) (rerr
536530
537531 txn := posting .Oracle ().RegisterStartTs (m .StartTs )
538532 if txn .ShouldAbort () {
539- if span .IsRecording () {
540- span .AddEvent ("Txn should abort." , trace .WithAttributes (
541- attribute .Int64 ("start_ts" , int64 (m .StartTs )),
542- ))
543- }
533+ span .AddEvent ("Txn should abort." , trace .WithAttributes (
534+ attribute .Int64 ("start_ts" , int64 (m .StartTs )),
535+ ))
544536 return x .ErrConflict
545537 }
546538 // Discard the posting lists from cache to release memory at the end.
@@ -633,12 +625,10 @@ func (n *node) applyCommitted(proposal *pb.Proposal, key uint64) error {
633625
634626 ctx := n .Ctx (key )
635627 span := trace .SpanFromContext (ctx )
636- if span .IsRecording () {
637- span .AddEvent ("Node.applyCommited" , trace .WithAttributes (
638- attribute .Int64 ("node id" , int64 (n .Id )),
639- attribute .Int64 ("Group Id" , int64 (n .gid )),
640- attribute .Int64 ("proposal key" , int64 (key ))))
641- }
628+ span .AddEvent ("Node.applyCommited" , trace .WithAttributes (
629+ attribute .Int64 ("node id" , int64 (n .Id )),
630+ attribute .Int64 ("Group Id" , int64 (n .gid )),
631+ attribute .Int64 ("proposal key" , int64 (key ))))
642632
643633 if proposal .Mutations != nil {
644634 // syncmarks for this shouldn't be marked done until it's committed.
@@ -857,17 +847,16 @@ func (n *node) processApplyCh() {
857847 p := & P {err : perr , size : psz , seen : time .Now ()}
858848 previous [key ] = p
859849 }
850+ span := trace .SpanFromContext (n .ctx )
860851 if perr != nil {
861852 glog .Errorf ("Applying proposal. Error: %v. Proposal: %q." , perr , proposal )
853+ span .AddEvent (fmt .Sprintf ("Applying proposal failed. Error: %v Proposal: %q" , perr , proposal ))
862854 }
863- span := trace .SpanFromContext (n .ctx )
864- if span .IsRecording () {
865- span .AddEvent ("Applied proposal with key: %d, index: %d. Err: %v" ,
866- trace .WithAttributes (
867- attribute .Int64 ("key" , int64 (key )),
868- attribute .Int64 ("index" , int64 (proposal .Index )),
869- attribute .String ("error" , perr .Error ())))
870- }
855+ span .AddEvent ("Applied proposal with key: %d, index: %d. Err: %v" ,
856+ trace .WithAttributes (
857+ attribute .Int64 ("key" , int64 (key )),
858+ attribute .Int64 ("index" , int64 (proposal .Index )),
859+ ))
871860
872861 var tags []tag.Mutator
873862 switch {
@@ -1428,13 +1417,10 @@ func (n *node) Run() {
14281417 // Store the hardstate and entries. Note that these are not CommittedEntries.
14291418 n .SaveToStorage (& rd .HardState , rd .Entries , & rd .Snapshot )
14301419 timer .Record ("disk" )
1431- if span != nil {
1432- span .AddEvent ("Saved %d entries. Snapshot, HardState empty? (%v, %v)" ,
1433- trace .WithAttributes (
1434- attribute .Int ("entries" , len (rd .Entries )),
1435- attribute .Bool ("snapshotEmpty" , raft .IsEmptySnap (rd .Snapshot )),
1436- attribute .Bool ("hardStateEmpty" , raft .IsEmptyHardState (rd .HardState ))))
1437- }
1420+ span .AddEvent (fmt .Sprintf ("Saved %d entries. Snapshot, HardState empty? (%v, %v)" ,
1421+ len (rd .Entries ),
1422+ raft .IsEmptySnap (rd .Snapshot ),
1423+ raft .IsEmptyHardState (rd .HardState )))
14381424
14391425 for x .WorkerConfig .HardSync && rd .MustSync {
14401426 if err := n .Store .Sync (); err != nil {
0 commit comments