use of com.newrelic.agent.bridge.Token in project newrelic-java-agent by newrelic.
the class TransactionPropagationTest method asyncPropagationSanityCheck.
@Test
public void asyncPropagationSanityCheck() throws InterruptedException {
AtomicBoolean hadTransaction = new AtomicBoolean();
CountDownLatch done = new CountDownLatch(1);
inTransaction(() -> {
Token token = createToken();
inAnotherThread(() -> inAnnotatedWithTraceAsync(() -> {
token.linkAndExpire();
checkTransaction(hadTransaction);
done.countDown();
}));
});
done.await();
assertCapturedData(hadTransaction);
}
use of com.newrelic.agent.bridge.Token in project newrelic-java-agent by newrelic.
the class TransactionPropagationTest method testLambdaSubscriberOnError.
@Test(timeout = 10000L)
public void testLambdaSubscriberOnError() {
AtomicBoolean hadTransaction = new AtomicBoolean();
CountDownLatch done = new CountDownLatch(1);
inTransaction(() -> {
Token token = createToken();
Flux.error(new RuntimeException()).subscribeOn(Schedulers.elastic()).doOnError(v -> checkTransaction(hadTransaction)).subscribe(nil(), v -> done.countDown());
await(done);
token.expire();
});
assertCapturedData(hadTransaction);
}
use of com.newrelic.agent.bridge.Token in project newrelic-java-agent by newrelic.
the class TransactionPropagationTest method testMonoNestedInFlatMap.
@Test
public void testMonoNestedInFlatMap() {
AtomicBoolean hadTransaction = new AtomicBoolean();
inTransaction(() -> {
Token token = createToken();
Mono.just(A_VALUE).subscribeOn(Schedulers.elastic()).flatMap(v -> Mono.just(A_VALUE).subscribeOn(Schedulers.elastic()).doOnSuccess(v2 -> checkTransaction(hadTransaction))).subscriberContext(with(token)).block();
token.expire();
});
assertCapturedData(hadTransaction);
}
use of com.newrelic.agent.bridge.Token in project newrelic-java-agent by newrelic.
the class TransactionPropagationTest method testLambdaMonoSubscriberOnSuccess.
@Test(timeout = 10000L)
public void testLambdaMonoSubscriberOnSuccess() {
AtomicBoolean hadTransaction = new AtomicBoolean();
CountDownLatch done = new CountDownLatch(1);
inTransaction(() -> {
Token token = createToken();
Mono.empty().subscribeOn(Schedulers.elastic()).doOnSuccess(v -> checkTransaction(hadTransaction)).subscribe(nil(), nil(), done::countDown);
await(done);
token.expire();
});
assertCapturedData(hadTransaction);
}
use of com.newrelic.agent.bridge.Token in project newrelic-java-agent by newrelic.
the class TransactionPropagationTest method testMonoRetryBackoffOnSuccess.
@Test
public void testMonoRetryBackoffOnSuccess() {
AtomicBoolean hadTransaction = new AtomicBoolean();
inTransaction(() -> {
Token token = createToken();
AtomicBoolean firstCall = new AtomicBoolean(true);
Mono.create(monoSink -> inAnotherThread(() -> {
if (firstCall.getAndSet(false))
monoSink.error(new RuntimeException("failing the first call"));
else
monoSink.success(A_VALUE);
})).doOnSuccess(v -> checkTransaction(hadTransaction)).retryBackoff(2, Duration.ZERO).subscriberContext(with(token)).block();
token.expire();
});
assertCapturedData(hadTransaction);
}
Aggregations