File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
main/java/com/google/cloud/spanner/connection
test/java/com/google/cloud/spanner/connection Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change 57
57
import com .google .common .collect .Iterables ;
58
58
import com .google .common .util .concurrent .MoreExecutors ;
59
59
import com .google .spanner .v1 .SpannerGrpc ;
60
+ import io .opentelemetry .api .common .AttributeKey ;
60
61
import io .opentelemetry .context .Scope ;
61
62
import java .time .Duration ;
62
63
import java .util .ArrayList ;
80
81
* exact same results as the original transaction.
81
82
*/
82
83
class ReadWriteTransaction extends AbstractMultiUseTransaction {
84
+ private static final AttributeKey <Boolean > TRANSACTION_RETRIED =
85
+ AttributeKey .booleanKey ("transaction.retried" );
83
86
private static final Logger logger = Logger .getLogger (ReadWriteTransaction .class .getName ());
84
87
private static final AtomicLong ID_GENERATOR = new AtomicLong ();
85
88
private static final String MAX_INTERNAL_RETRIES_EXCEEDED =
@@ -990,6 +993,7 @@ private void handleAborted(AbortedException aborted) {
990
993
long delay = aborted .getRetryDelayInMillis ();
991
994
span .addEvent (
992
995
"Transaction aborted. Backing off for " + delay + " milliseconds and retrying." );
996
+ span .setAttribute (TRANSACTION_RETRIED , true );
993
997
try {
994
998
if (delay > 0L ) {
995
999
//noinspection BusyWait
Original file line number Diff line number Diff line change @@ -447,6 +447,9 @@ public void testMultiUseReadWriteAborted() {
447
447
.filter (span -> span .getName ().equals ("CloudSpannerJdbc.ReadWriteTransaction" ))
448
448
.findFirst ()
449
449
.orElseThrow (IllegalStateException ::new );
450
+ assertEquals (
451
+ Boolean .TRUE ,
452
+ transactionSpan .getAttributes ().get (AttributeKey .booleanKey ("transaction.retried" )));
450
453
assertEquals (1 , transactionSpan .getTotalRecordedEvents ());
451
454
EventData event = transactionSpan .getEvents ().get (0 );
452
455
assertEquals (
You can’t perform that action at this time.
0 commit comments