@@ -980,13 +980,15 @@ func (n *node) processApplyCh() {
980
980
981
981
// TODO(Anurag - 4 May 2020): Are we using pkey? Remove if unused.
982
982
func (n * node ) commitOrAbort (pkey uint64 , delta * pb.OracleDelta ) error {
983
- _ , span := otel .Tracer ("alpha.CommitLoop" ).Start (context .Background (), "commitOrAbort" )
983
+ pctx , span := otel .Tracer ("alpha.CommitLoop" ).Start (context .Background (), "alpha. commitOrAbort" )
984
984
defer span .End ()
985
985
986
986
x .PrintOracleDelta (delta )
987
987
// First let's commit all mutations to disk.
988
988
writer := posting .NewTxnWriter (pstore )
989
989
toDisk := func (start , commit uint64 ) {
990
+ _ , tspan := otel .Tracer ("alpha.CommitLoop" ).Start (pctx , "alpha.toDisk" )
991
+ defer tspan .End ()
990
992
txn := posting .Oracle ().GetTxn (start )
991
993
if txn == nil || commit == 0 {
992
994
return
@@ -1013,17 +1015,11 @@ func (n *node) commitOrAbort(pkey uint64, delta *pb.OracleDelta) error {
1013
1015
panic (err )
1014
1016
}
1015
1017
1016
- span .AddEvent ("Committed txn with start_ts: %d, commit_ts: %d" , trace .WithAttributes (
1018
+ tspan .AddEvent ("Committed txn with start_ts: %d, commit_ts: %d" , trace .WithAttributes (
1017
1019
attribute .Int64 ("start_ts" , int64 (start )),
1018
1020
attribute .Int64 ("commit_ts" , int64 (commit )),
1019
1021
))
1020
-
1021
- if txn .Span != nil {
1022
- txn .Span .AddEvent ("Committed txn with start_ts: %d, commit_ts: %d" , trace .WithAttributes (
1023
- attribute .Int64 ("start_ts" , int64 (start )),
1024
- attribute .Int64 ("commit_ts" , int64 (commit )),
1025
- ))
1026
- }
1022
+ tspan .SetAttributes (attribute .Int64 ("start_ts" , int64 (start )), attribute .Int64 ("commit_ts" , int64 (commit )))
1027
1023
}
1028
1024
1029
1025
for _ , status := range delta .Txns {
@@ -1036,7 +1032,7 @@ func (n *node) commitOrAbort(pkey uint64, delta *pb.OracleDelta) error {
1036
1032
span .AddEvent ("Flushed to disk" )
1037
1033
for _ , status := range delta .Txns {
1038
1034
txn := posting .Oracle ().GetTxn (status .StartTs )
1039
- if txn .Span != nil {
1035
+ if txn != nil && txn .Span != nil {
1040
1036
txn .Span .AddEvent ("Flushed txn with start_ts: %d, commit_ts: %d" , trace .WithAttributes (
1041
1037
attribute .Int64 ("start_ts" , int64 (status .StartTs )),
1042
1038
attribute .Int64 ("commit_ts" , int64 (status .CommitTs )),
0 commit comments