[cross-post from sitebricks list]
As of r176, I've added a StatModule which allows you to monitor and track
various custom stats in real time from running servers. This is really
useful for checking on the health of running services or keeping track of
various runtime stats efficiently.
Here's how it works:
Any singleton can export any variable (which has a valid toString() method)
simply by annotating that field. Let's say you have a service that is used
to download some file:
public class DownloadService {
* @Stat("download-count")*
private final AtomicInteger downloads = new AtomicInteger();
@Get void performDownload() {
downloads.incrementAndGet();
// send file...
}
}
And make sure to install the StatModule with a location at which to serve
the stats:
install(new StatModule("/stats"));
This requires Guice Servlet to be working properly. Each time you request
the /stats page you will see the aggregation of all stats in the system
snapshotted at the time at which you requested the page.
This is neat because you can build offsite monitoring services that
periodically snapshot stats in a running system and store them in a
timeseries database (for example), for later visualization. All with a
simple annotation.
It will be in Maven Central at the next push of Sitebricks (although
sitebricks is NOT needed to use this extension).
Enjoy!
Dhanji.
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.