Skip to content

Commit abacf4b

Browse files
Add logs
1 parent e11bda2 commit abacf4b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/AsyncResultSetImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ public void run() {
337337
* the buffer and dispatches the {@link CallbackRunnable} when data is ready to be consumed.
338338
*/
339339
private class ProduceRowsRunnable implements Runnable {
340+
341+
public ProduceRowsRunnable(StackTraceElement[] stackTrace) {
342+
ThreadLocal<StackTraceElement[]> threadLocal = new ThreadLocal<>();
343+
threadLocal.set(stackTrace);
344+
}
345+
340346
@Override
341347
public void run() {
342348
boolean stop = false;
@@ -502,7 +508,7 @@ private void initiateProduceRows() {
502508
this.state = State.RUNNING;
503509
}
504510
produceRowsInitiated = true;
505-
this.service.execute(new ProduceRowsRunnable());
511+
this.service.execute(new ProduceRowsRunnable(Thread.currentThread().getStackTrace()));
506512
}
507513

508514
Future<Void> getResult() {

google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,11 @@ private ByteString generateTransactionName(String session, String mutationString
652652
counter = new AtomicLong();
653653
transactionCounters.put(session, counter);
654654
}
655+
ThreadLocal<StackTraceElement[]> threadLocal = new ThreadLocal<>();
655656
transactionToTrace.put(
656657
session,
657658
String.format(
658-
"%s %s", mutationString, Arrays.toString(Thread.currentThread().getStackTrace())));
659+
"%s %s", mutationString, Arrays.toString(threadLocal.get()) + Arrays.toString(Thread.currentThread().getStackTrace())));
659660
return ByteString.copyFromUtf8(
660661
String.format("%s/transactions/%d", session, counter.incrementAndGet()));
661662
}

0 commit comments

Comments
 (0)