guava
guava copied to clipboard
EventBus: Add extention to enable tracing
I'm using EventBus in in distributed system. I found that com.google.common.eventbus.Subscriber lost tracting infomation. Because com.google.common.eventbus.Subscriber#dispatchEvent is a final method, I can't extend it.
/** Dispatches {@code event} to this subscriber using the proper executor. */
final void dispatchEvent(final Object event) {
executor.execute(
new Runnable() {
@Override
public void run() {
try {
invokeSubscriberMethod(event);
} catch (InvocationTargetException e) {
bus.handleSubscriberException(e.getCause(), context(event));
}
}
});
}
I advice to add the TracerRunnable instead of Runnable, like this:
public abstract class TracerRunnable implements Runnable {
public abstract void doRun();
public abstract void before();
public abstract void after();
public void run() {
before();
try {
doRun();
} finally {
after();
}
}
@amalloy I would like to start working on this. If possible, please assign this to me.
@bharathk005 @amalloy how does the issue process?