Open jasonjkeller opened 2 years ago
Will consider as a future agent roadmap item/for a future quarter
Note : This situation may still occur, even when Spring Cloud Sleuth is disabled, so consider alternate ways this same behavior could be triggered
It looks like it is still something Spring related. In the latest logs I see this tracer for org.springframework.hateoas.config.WebMvcHateoasConfiguration$DummyInvocationUtilsCacheClearer.afterCompletion
as the problematic one that is pointing to a NoOpTracer
as its parent tracer.
2022-11-15T15:57:35,398+0000 [1 546] com.newrelic FINER: Tracer (com.newrelic.agent.tracers.DefaultTracer@5c598ce9) Started: org.springframework.hateoas.config.WebMvcHateoasConfiguration$DummyInvocationUtilsCacheClearer.afterCompletion(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;Ljava/lang/Object;Ljava/lang/Exception;)V
2022-11-15T15:57:35,398+0000 [1 546] com.newrelic INFO: Tracer Debug: lastTracer set to com.newrelic.agent.tracers.NoOpTracer@2a9baf2, tracer = com.newrelic.agent.tracers.DefaultTracer@5c598ce9
2022-11-15T15:57:35,398+0000 [1 546] com.newrelic ERROR: Inconsistent state! tracer != last tracer for com.newrelic.agent.TransactionActivity@0 (com.newrelic.agent.tracers.DefaultTracer@60a202a9 != com.newrelic.agent.tracers.NoOpTracer@2a9baf2)
Likely related to either the com.newrelic.instrumentation.spring-4.3.0
or com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut
instrumentation.
Hello do you have any updates on this ticket?
I have similar issue without Sleuth. I use:
addCustomParameter
)2024-06-24T09:26:12,302+0000 [1 87] com.newrelic ERROR: Tracer Debug: Inconsistent state! tracer (actual tracer popped off stack) != lastTracer (pointer to top of stack) for com.newrelic.agent.TransactionActivity@42 (com.newrelic.agent.tracers.DefaultTracer@7ce43a8a != com.newrelic.agent.tracers.DefaultTracer@66605e92)
2024-06-24T09:26:12,302+0000 [1 87] com.newrelic ERROR: Tracer Debug: Inconsistent state! tracer (actual tracer popped off stack) != lastTracer (pointer to top of stack) for com.newrelic.agent.TransactionActivity@42 (com.newrelic.agent.tracers.DefaultTracer@3e0ff83a != com.newrelic.agent.tracers.DefaultTracer@66605e92)
2024-06-24T09:26:12,302+0000 [1 87] com.newrelic ERROR: Tracer Debug: Inconsistent state! tracer (actual tracer popped off stack) != lastTracer (pointer to top of stack) for com.newrelic.agent.TransactionActivity@42 (com.newrelic.agent.tracers.OtherRootTracer@391a244d != com.newrelic.agent.tracers.DefaultTracer@66605e92)
The Java agent does not currently support Spring Cloud Sleuth and using it can cause a clash with Java agent instrumentation that leads to the following
Inconsistent state! tracer != lastTracer
errors.For context, this issue occurs when the agent is handling some async activity and is adding tracers for each method call and popping tracers off the stack as each method call completes. The agent tracks what the first tracer (root tracer) is when the async activity started and by the end we would expect that that last tracer we pop off should be the root, but in this case it isn't, which means that the agent has lost track of the correct call stack into this async code. When the pointer to the tracer object at the top of the stack differs from the actual tracer object that gets popped off then the agent is in an inconsistent state. If this happens the agent discards the async information it was attempting to record and logs the inconsistent state error.
A separate PR adds extra debug logging to the agent to help troubleshoot such issues. https://github.com/newrelic/newrelic-java-agent/pull/1066
Here is some analysis of such debug logging (note that the logging will change slightly when PR #1066 is merged):
So what causes
DefaultTracer@53f2914f
to incorrectly point toNoOpTracer@1d1a05c7
??? Somehow this is the result that is returned when calling tracer.getParentTracer onDefaultTracer@53f2914f
.Here's info about DefaultTracer@53f2914f:
It appears to be an incompatibility with Spring Cloud Slueth? Likely the
SpanCustomizingAsyncHandlerInterceptor
is causing the agent to lose track of the active transaction, thus leading to the creation of aNoOpTracer
.Until Spring Cloud Sleuth is properly supported the options are:
Inconsistent state
error