Skip to content

Commit

Permalink
Add GFE latency trace for commit requests (#6079)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomoaki Fujii <tomoaki@google.com>
Co-authored-by: rahul2393 <rahulyadavsep92@gmail.com>
  • Loading branch information
3 people authored May 26, 2022
1 parent 72ccada commit 643186c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion spanner/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ func (t *ReadWriteTransaction) commit(ctx context.Context, options CommitOptions
return resp, errSessionClosed(t.sh)
}

var md metadata.MD
res, e := client.Commit(contextWithOutgoingMetadata(ctx, t.sh.getMetadata()), &sppb.CommitRequest{
Session: sid,
Transaction: &sppb.CommitRequest_TransactionId{
Expand All @@ -1134,7 +1135,12 @@ func (t *ReadWriteTransaction) commit(ctx context.Context, options CommitOptions
RequestOptions: createRequestOptions(t.txOpts.CommitPriority, "", t.txOpts.TransactionTag),
Mutations: mPb,
ReturnCommitStats: options.ReturnCommitStats,
})
}, gax.WithGRPCOptions(grpc.Header(&md)))
if getGFELatencyMetricsFlag() && md != nil && t.ct != nil {
if err := createContextAndCaptureGFELatencyMetrics(ctx, t.ct, md, "commit"); err != nil {
trace.TracePrintf(ctx, nil, "Error in recording GFE Latency. Try disabling and rerunning. Error: %v", err)
}
}
if e != nil {
return resp, toSpannerErrorWithCommitInfo(e, true)
}
Expand Down

0 comments on commit 643186c

Please sign in to comment.