Class CallDepthThreadLocalMap
- java.lang.Object
-
- io.opentelemetry.javaagent.instrumentation.api.CallDepthThreadLocalMap
-
public final class CallDepthThreadLocalMap extends Object
Utility to track nested instrumentation.For example, this can be used to track nested calls to super() in constructors by calling #incrementCallDepth at the beginning of each constructor.
This works the following way. When you enter some method that you want to track, you call
incrementCallDepth(java.lang.Class<?>)method. If returned number is larger than 0, then you have already been in this method and are in recursive call now. When you then leave the method, you calldecrementCallDepth(java.lang.Class<?>)method. If returned number is larger than 0, then you have already been in this method and are in recursive call now.In short, the semantic of both methods is the same: they will return value 0 if and only if current method invocation is the first one for the current call stack.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intdecrementCallDepth(Class<?> k)static CallDepthgetCallDepth(Class<?> k)static intincrementCallDepth(Class<?> k)static voidreset(Class<?> k)
-