You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a side issue that was noticed during the course of working on #1073
Below is a Spring controller that repros the problem and here is a zip of a repro app: newrelic-trace-on-util.zip
The problem is that the Transaction is lost and thus not linked when calling the response method via the /does-not-work route. Specifically this seems to be a result of using subscribeOn(Schedulers.boundedElastic()). In the past, we've seen cases where an unexpected thread hop occurred due to the use of subscribeOn(Schedulers.boundedElastic()) which caused the token linking failures.
package com.example.newrelictraceonutil;
import com.newrelic.api.agent.NewRelic;
import com.newrelic.api.agent.TracedMethod;
import com.newrelic.api.agent.Transaction;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
@RestController
public class ExampleController {
@GetMapping(path = "/works")
public Mono<String> works() {
return Mono.fromCallable(() -> response("works"));
}
@GetMapping(path = "/does-not-work")
public Mono<String> doesNotWork() {
return Mono.fromCallable(() -> response("does-not-work"))
.subscribeOn(Schedulers.boundedElastic());
}
/*
* When hitting the /works route the transaction is properly renamed to works-custom-transaction-name as it
* has reference to a valid TransactionApiImpl and DefaultTracer
*
* When hitting the /does-not-work route the transaction is NOT renamed as the Transaction context has been lost,
* and it has reference to a NoOpTransaction and NoOpTracedMethod
*/
private String response(String endpoint) {
NewRelic.setTransactionName("custom", endpoint + "-custom-transaction-name");
NewRelic.addCustomParameter("custom.param", endpoint);
Transaction transaction = NewRelic.getAgent().getTransaction();
TracedMethod tracedMethod = transaction.getTracedMethod();
return endpoint
+ "\nTransaction: " + transaction
+ "\nTracedMethod: " + tracedMethod;
}
}
Run the repro app and hit http://localhost:8080/does-not-work. The response output will indicate that a NoOpTransaction was present when response was called. Also the transaction will remain named does-not-work (GET).
Compare this to the working route http://localhost:8080/works. The response output will indicate that a TransactionApiImpl was present when response was called. The transaction is renamed to works-custom-transaction-name as expected.
works Transaction: com.newrelic.agent.TransactionApiImpl@ec51b31 TracedMethod: com.newrelic.agent.tracers.DefaultTracer@5745ebc4
The text was updated successfully, but these errors were encountered:
This is a side issue that was noticed during the course of working on #1073
Below is a Spring controller that repros the problem and here is a zip of a repro app: newrelic-trace-on-util.zip
The problem is that the
Transaction
is lost and thus not linked when calling theresponse
method via the/does-not-work
route. Specifically this seems to be a result of usingsubscribeOn(Schedulers.boundedElastic())
. In the past, we've seen cases where an unexpected thread hop occurred due to the use ofsubscribeOn(Schedulers.boundedElastic())
which caused the token linking failures.Run the repro app and hit http://localhost:8080/does-not-work. The response output will indicate that a
NoOpTransaction
was present whenresponse
was called. Also the transaction will remain nameddoes-not-work (GET)
.Compare this to the working route http://localhost:8080/works. The response output will indicate that a
TransactionApiImpl
was present whenresponse
was called. The transaction is renamed toworks-custom-transaction-name
as expected.The text was updated successfully, but these errors were encountered: