Modified:
/GettingStarted.wiki
=======================================
--- /GettingStarted.wiki Wed Jun 15 20:40:26 2011
+++ /GettingStarted.wiki Mon Jun 20 18:31:27 2011
@@ -153,7 +153,7 @@
}
}}}
-=== Manually Collected ===
+=== Manually Collected Data ===
In the event that Stajitics cannot know about the data being collected
through means of the span or incident trackers, a ManualTracker can collect
the data:
@@ -176,6 +176,41 @@
this.age = age;
}
}}}
+
+=== Getting Dynamic ===
+
+In the above examples, Stajistics APIs are called directly from client
code, which can be a large commitment for certain code bases. The following
shows a few ways to use Stajistics in a less intrusive manner.
+
+==== Interface Proxy ====
+
+A StatsProxy will wrap an Object, implement one or more of its interfaces,
and collect statistics on method calls. An example way to use a StatsProxy
that would minimize coupling to the Stajistics API would be to proxy
services coming out of a factory.
+
+{{{
+
+ public class ServiceFactory {
+
+ public Service createService(String name) {
+
+ Service service = new ServiceImpl(name);
+
+ // Create a key to uniquely represent the service
+ StatsKey serviceKey = Stats.buildKey("services")
+ .withAttribute("name", name)
+ .newKey();
+
+ // Proxy the service, implementing all of its interfaces
+ service = StatsProxy.wrap(Stats.getManager(),
+ serviceKey,
+ service);
+
+ // Clients of the factory are none the wiser :O
+
+ return service;
+ }
+
+ }
+
+}}}
== 5. View Collected Statistics ==