I have a complex stats system to monitor the behavior of our app.
One of the things I want to do is track the name of a thread/task calling a
component.
So I have a component called a Caller which I inject so that when a
component is created, I can see who called it.
The problem is, how do you change the caller at runtime?
It should be possible to do this with thread locals and a @Singleton.
So basically you have a Task, which has a Caller dependency... then that
task just does
String defaultCaller = caller.get();
try {
caller.set( "my-task" );
mytask.run();
} finally {
caller.set( defaultCaller );
}
... now I'm not super happy with thread locals, but this doesn't seem
amazingly ugly.
Is there a better way to do this?
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-guice/70f1dabe-40e0-4698-a451-6a1a07aabe28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.