ratpack/ratpack — pull request #177 by rhart (2013-10-12 17:31:55+00:00)
Title: Adding basic metrics support

Initial commit for your review on the approach. I chose to use AOP as it means less noise in the code and will be more flexible going forward than using Guice method interceptors e.g. for non Guice objects. Can easily be changed though if the extra dependencies and/or JVM arg required to activate are a problem.

Usage would be as follows
```
ratpack {
modules {
register new MetricsModule()
register new MetricsJmxReporterModule()
}

handlers { MetricRegistry metrics ->
get {
render groovyTemplate("index.html", title: "My Ratpack App")
}

prefix("foo") {
get {
metrics.meter("foo get handler").mark()
response.send("foo")
}
}

prefix("bar") {
get {
render groovyTemplate("index.html", title: "My Ratpack App")
}
}

assets "public"
}
}
```

You can see that custom metrics would be easily supported. Would also intend on providing an annotation to make it even easier.
Additional modules would be created to support the other reporters.

JVM arg is required though to active AOP
```
run {
jvmArgs "-javaagent:${configurations.runtime.files.find {it.name == 'aspectjweaver-1.7.3.jar'}.path}"
systemProperty "ratpack.reloadable", "true"
}
```

![metrics](https://f.cloud.github.com/assets/226023/1320544/f56a4caa-3363-11e3-8e5c-0575924e0723.png)

Feel free to tear into it and I will make any changes :)