This library is brought to you by Edward Hartwell Goose. Thank you very much Ed!

Step 1: Download the Java library

Clone the git repository from here:
git clone https://code.google.com/p/prodeagle-java/

or download the jar file directly.

Step 2: Add counters to your code

When ever you would like to increment a counter, just call:
import com.prodeagle.java.counters.Counter;

Counter.increment("Your.Counter.Name");

Behind the scenes, this will result in a "increment" call to the memcache service, which is blazing fast 1).

To update multiple counters at the same time, you can do batch requests like this:
import com.prodeagle.java.counters.BatchCounter;
                
BatchCounter counters = new BatchCounter();
counters.increment("Food.ChocolateBars");
counters.increment("Food.CerealBars");
counters.increment("Food.FooBars");
counters.commit();

This will only do a single call to memcache instead of three sequential ones.

You can also increment a counter by any discrete number, for example by 5:
import com.prodeagle.java.counters.Counter;

counters.increment("Your.Counter.Name", 5L);

Step 3: Set up the ProdEagle export handler

ProdEagle needs to come and collect your counter data in order to be able display graphs and alert you when they drop or exceed a certain value.

Add the following handler to your web.xml:
<servlet>
        <servlet-name>ProdEagle</servlet-name>
        <servlet-class>com.prodeagle.java.servlets.HarvestHandler</servlet-class>
</servlet>
<servlet-mapping>
        <servlet-name>ProdEagle</servlet-name>
        <url-pattern>/prodeagle/*</url-pattern>
</servlet-mapping>

This handler already has its own authentication method and only allows access to ProdEagle.com and Administrators of your app.
Do not add additional authentication methods with <security-constraint>.

You should now be able to see by how much your counters have been incremented since the last time ProdEagle.com collected your data on http://your-app-id.appspot.com/prodeagle/

Step 4: Set up ProdEagle.com to collect your counter data

Go to ProdEagle.com and login using a Google Account that is an Administrator of your AppEngine app.

Add your appid.appspot.com in the "Your monitored websites" section.

Make sure you use https! Don't use a custom domain if you have on, just use https://appid.appspot.com.

Now ProdEagle.com will come and export your data every minute. You need to wait for the first export and then you can start creating new graphs and set up new alerts! Sweet, huh?


1) The first time a counter is incremented, the framework needs to do a datastore write. Additionally, when a fresh serving instance is started, the framework needs to read a datastore entry that contains all counter names. The ProdEagle.* counters record these events if SAVE_PRODEAGLE_STATS in Counter.java is true (default).