Make sure CallDepthThreadLocalMap is always reset (#1227)
Make sure CallDepthThreadLocalMap is always reset
This commit is contained in:
commit
ecf9bcc655
|
@ -64,7 +64,7 @@ public class CouchbaseBucketInstrumentation extends Instrumenter.Default {
|
||||||
return CallDepthThreadLocalMap.incrementCallDepth(CouchbaseCluster.class);
|
return CallDepthThreadLocalMap.incrementCallDepth(CouchbaseCluster.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit
|
@Advice.OnMethodExit(onThrowable = Throwable.class)
|
||||||
public static void subscribeResult(
|
public static void subscribeResult(
|
||||||
@Advice.Enter final int callDepth,
|
@Advice.Enter final int callDepth,
|
||||||
@Advice.Origin final Method method,
|
@Advice.Origin final Method method,
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class CouchbaseClusterInstrumentation extends Instrumenter.Default {
|
||||||
return CallDepthThreadLocalMap.incrementCallDepth(CouchbaseCluster.class);
|
return CallDepthThreadLocalMap.incrementCallDepth(CouchbaseCluster.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit
|
@Advice.OnMethodExit(onThrowable = Throwable.class)
|
||||||
public static void subscribeResult(
|
public static void subscribeResult(
|
||||||
@Advice.Enter final int callDepth,
|
@Advice.Enter final int callDepth,
|
||||||
@Advice.Origin final Method method,
|
@Advice.Origin final Method method,
|
||||||
|
|
|
@ -61,13 +61,13 @@ public final class PreparedStatementInstrumentation extends Instrumenter.Default
|
||||||
|
|
||||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||||
public static AgentScope onEnter(@Advice.This final PreparedStatement statement) {
|
public static AgentScope onEnter(@Advice.This final PreparedStatement statement) {
|
||||||
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(PreparedStatement.class);
|
final Connection connection = connectionFromStatement(statement);
|
||||||
if (callDepth > 0) {
|
if (connection == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Connection connection = connectionFromStatement(statement);
|
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(PreparedStatement.class);
|
||||||
if (connection == null) {
|
if (callDepth > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,13 +62,13 @@ public final class StatementInstrumentation extends Instrumenter.Default {
|
||||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||||
public static AgentScope onEnter(
|
public static AgentScope onEnter(
|
||||||
@Advice.Argument(0) final String sql, @Advice.This final Statement statement) {
|
@Advice.Argument(0) final String sql, @Advice.This final Statement statement) {
|
||||||
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(Statement.class);
|
final Connection connection = connectionFromStatement(statement);
|
||||||
if (callDepth > 0) {
|
if (connection == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Connection connection = connectionFromStatement(statement);
|
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(Statement.class);
|
||||||
if (connection == null) {
|
if (callDepth > 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
|
||||||
return CallDepthThreadLocalMap.incrementCallDepth(ChannelPipeline.class);
|
return CallDepthThreadLocalMap.incrementCallDepth(ChannelPipeline.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void addHandler(
|
public static void addHandler(
|
||||||
@Advice.Enter final int depth,
|
@Advice.Enter final int depth,
|
||||||
@Advice.This final ChannelPipeline pipeline,
|
@Advice.This final ChannelPipeline pipeline,
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
|
||||||
return CallDepthThreadLocalMap.incrementCallDepth(handler.getClass());
|
return CallDepthThreadLocalMap.incrementCallDepth(handler.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void addHandler(
|
public static void addHandler(
|
||||||
@Advice.Enter final int depth,
|
@Advice.Enter final int depth,
|
||||||
@Advice.This final ChannelPipeline pipeline,
|
@Advice.This final ChannelPipeline pipeline,
|
||||||
|
|
|
@ -81,14 +81,17 @@ public final class MemcachedClientInstrumentation extends Instrumenter.Default {
|
||||||
return CallDepthThreadLocalMap.incrementCallDepth(MemcachedClient.class) <= 0;
|
return CallDepthThreadLocalMap.incrementCallDepth(MemcachedClient.class) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Enter final boolean shouldInjectListener,
|
@Advice.Enter final boolean shouldInjectListener,
|
||||||
@Advice.This final MemcachedClient client,
|
@Advice.This final MemcachedClient client,
|
||||||
@Advice.Origin("#m") final String methodName,
|
@Advice.Origin("#m") final String methodName,
|
||||||
@Advice.Return final OperationFuture future) {
|
@Advice.Return final OperationFuture future) {
|
||||||
if (shouldInjectListener && future != null) {
|
if (!shouldInjectListener) {
|
||||||
CallDepthThreadLocalMap.reset(MemcachedClient.class);
|
return;
|
||||||
|
}
|
||||||
|
CallDepthThreadLocalMap.reset(MemcachedClient.class);
|
||||||
|
if (future != null) {
|
||||||
final OperationCompletionListener listener =
|
final OperationCompletionListener listener =
|
||||||
new OperationCompletionListener(client.getConnection(), methodName);
|
new OperationCompletionListener(client.getConnection(), methodName);
|
||||||
future.addListener(listener);
|
future.addListener(listener);
|
||||||
|
@ -103,14 +106,17 @@ public final class MemcachedClientInstrumentation extends Instrumenter.Default {
|
||||||
return CallDepthThreadLocalMap.incrementCallDepth(MemcachedClient.class) <= 0;
|
return CallDepthThreadLocalMap.incrementCallDepth(MemcachedClient.class) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Enter final boolean shouldInjectListener,
|
@Advice.Enter final boolean shouldInjectListener,
|
||||||
@Advice.This final MemcachedClient client,
|
@Advice.This final MemcachedClient client,
|
||||||
@Advice.Origin("#m") final String methodName,
|
@Advice.Origin("#m") final String methodName,
|
||||||
@Advice.Return final GetFuture future) {
|
@Advice.Return final GetFuture future) {
|
||||||
if (shouldInjectListener && future != null) {
|
if (!shouldInjectListener) {
|
||||||
CallDepthThreadLocalMap.reset(MemcachedClient.class);
|
return;
|
||||||
|
}
|
||||||
|
CallDepthThreadLocalMap.reset(MemcachedClient.class);
|
||||||
|
if (future != null) {
|
||||||
final GetCompletionListener listener =
|
final GetCompletionListener listener =
|
||||||
new GetCompletionListener(client.getConnection(), methodName);
|
new GetCompletionListener(client.getConnection(), methodName);
|
||||||
future.addListener(listener);
|
future.addListener(listener);
|
||||||
|
@ -125,14 +131,17 @@ public final class MemcachedClientInstrumentation extends Instrumenter.Default {
|
||||||
return CallDepthThreadLocalMap.incrementCallDepth(MemcachedClient.class) <= 0;
|
return CallDepthThreadLocalMap.incrementCallDepth(MemcachedClient.class) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||||
public static void methodExit(
|
public static void methodExit(
|
||||||
@Advice.Enter final boolean shouldInjectListener,
|
@Advice.Enter final boolean shouldInjectListener,
|
||||||
@Advice.This final MemcachedClient client,
|
@Advice.This final MemcachedClient client,
|
||||||
@Advice.Origin("#m") final String methodName,
|
@Advice.Origin("#m") final String methodName,
|
||||||
@Advice.Return final BulkFuture future) {
|
@Advice.Return final BulkFuture future) {
|
||||||
if (shouldInjectListener && future != null) {
|
if (!shouldInjectListener) {
|
||||||
CallDepthThreadLocalMap.reset(MemcachedClient.class);
|
return;
|
||||||
|
}
|
||||||
|
CallDepthThreadLocalMap.reset(MemcachedClient.class);
|
||||||
|
if (future != null) {
|
||||||
final BulkGetCompletionListener listener =
|
final BulkGetCompletionListener listener =
|
||||||
new BulkGetCompletionListener(client.getConnection(), methodName);
|
new BulkGetCompletionListener(client.getConnection(), methodName);
|
||||||
future.addListener(listener);
|
future.addListener(listener);
|
||||||
|
|
Loading…
Reference in New Issue