Created
May 17, 2016 01:02
-
-
Save shkhln/9ac4999dcdad23f44ffc66ae01776353 to your computer and use it in GitHub Desktop.
This file contains 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
import com.sun.btrace.AnyType; | |
import com.sun.btrace.annotations.*; | |
import static com.sun.btrace.BTraceUtils.*; | |
@BTrace | |
public class ChannelTrace { | |
@TLS static boolean subscribed = false; | |
// Play adds http-body-subscriber | |
@OnMethod(clazz = "com.typesafe.netty.http.HttpStreamsHandler", method = "unbufferedWrite", location = @Location(Kind.ENTRY)) | |
public static void onUnbufferedWrite(@ProbeClassName String pcn, @ProbeMethodName String pmn, AnyType ctx, AnyType out) { | |
subscribed = true; | |
print(name(currentThread()) + " " + pcn + "." + pmn + ": ctx = " + ctx + "\n"); | |
} | |
// Play removes http-body-subscriber | |
@OnMethod(clazz = "com.typesafe.netty.http.HttpStreamsHandler", method = "completeBody", location = @Location(Kind.ENTRY)) | |
public static void onCompleteBody(@ProbeClassName String pcn, @ProbeMethodName String pmn, AnyType ctx) { | |
subscribed = false; | |
print(name(currentThread()) + " " + pcn + "." + pmn + ": ctx = " + ctx + "\n"); | |
} | |
@OnMethod(clazz = "play.core.server.netty.PlayRequestHandler", method = "exceptionCaught", location = @Location(Kind.ENTRY)) | |
public static void onExceptionCaught(@ProbeClassName String pcn, @ProbeMethodName String pmn) { | |
subscribed = false; | |
print(name(currentThread()) + " " + pcn + "." + pmn + "\n"); | |
} | |
// Something is added to the pipeline | |
@OnMethod(clazz = "io.netty.channel.DefaultChannelPipeline", method = "addAfter0", location = @Location(Kind.ENTRY)) | |
public static void onPipelineAddAfter0(@ProbeClassName String pcn, @ProbeMethodName String pmn, AnyType ctx, AnyType newCtx) { | |
print(name(currentThread()) + " " + pcn + "." + pmn + ": newCtx = " + newCtx + "\n"); | |
} | |
// Something is removed from the pipeline | |
@OnMethod(clazz = "io.netty.channel.DefaultChannelPipeline", method = "remove0", location = @Location(Kind.ENTRY)) | |
public static void onPipelineRemove0(@ProbeClassName String pcn, @ProbeMethodName String pmn, AnyType ctx) { | |
print(name(currentThread()) + " " + pcn + "." + pmn + ": ctx = " + ctx + "\n" /*+ jstackStr(7) + "\n"*/); | |
} | |
@OnMethod(clazz = "io.netty.channel.DefaultChannelPipeline", method = "/fire.*/", location = @Location(Kind.ENTRY)) | |
public static void onPipelineEvent(@ProbeClassName String pcn, @ProbeMethodName String pmn) { | |
print(name(currentThread()) + " " + pcn + "." + pmn + "\n"); | |
} | |
// DefaultChannelPipeline.destroy removes all handlers from the pipeline | |
@OnMethod(clazz = "io.netty.channel.DefaultChannelPipeline", method = "destroy", location = @Location(Kind.ENTRY)) | |
public static void onPipelineDestroy(@ProbeClassName String pcn, @ProbeMethodName String pmn) { | |
if (subscribed) { | |
print("[This is not supposed to happen]\n"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment