-
-
Save robertpfeiffer/241946 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* BTrace Script Template */ | |
import com.sun.btrace.annotations.*; | |
import static com.sun.btrace.BTraceUtils.*; | |
@BTrace | |
public class TracingScript { | |
private static java.util.Map<String, Integer> myMap = newHashMap(); | |
private static int methodCountTreshold = 200; | |
@OnMethod( | |
clazz="/com\\.sowas\\.alphaagent\\..+/", | |
method="/.*/", | |
location=@Location(Kind.ENTRY) | |
) | |
public static void funcEnter() { | |
String method = probeMethod(); | |
Integer callCount = 0; | |
if (containsKey(myMap, method)) | |
callCount = get(myMap, method); | |
callCount += 1; | |
put(myMap, method, callCount); | |
if (callCount > methodCountTreshold) | |
return; | |
print(timeMillis()); | |
print(' '); | |
print("entering "); | |
print(probeClass()); | |
print('.'); | |
print(method); | |
print(" ("); | |
print(callCount); | |
println(")"); | |
} | |
@OnMethod( | |
clazz="/com\\.sowas\\.alphaagent\\..+/", | |
method="/.*/", | |
location=@Location(Kind.RETURN) | |
) | |
public static void funcLeave() { | |
String method = probeMethod(); | |
Integer callCount = 0; | |
if (containsKey(myMap, method)) | |
callCount = get(myMap, method); | |
callCount += 1; | |
put(myMap, method, callCount); | |
if (callCount > methodCountTreshold) | |
return; | |
print(timeMillis()); | |
print(' '); | |
print("leaving "); | |
print(probeClass()); | |
print('.'); | |
print(method); | |
print(" ("); | |
print(callCount); | |
println(")"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment