Permalink
Browse files

Merge pull request #47 from ryankennedy/development

Robustify MetricsServlet in the face of exceptions thrown by gauges
  • Loading branch information...
2 parents fbc87d2 + f22ada1 commit 86ed300eb32008c2bd50c2d6ae0bf17015cec942 @codahale codahale committed Jun 23, 2011
@@ -268,11 +268,11 @@ private void writeGauge(JsonGenerator json, GaugeMetric gauge) throws IOExceptio
{
json.writeStringField("type", "gauge");
json.writeFieldName("value");
- final Object value = gauge.value();
try {
+ final Object value = gauge.value();
json.writeObject(value);
- } catch (JsonMappingException e) {
- json.writeString("unknown value type: " + value.getClass());
+ } catch (Exception e) {
+ json.writeString("error reading gauge: " + e.getMessage());
}
}
json.writeEndObject();
@@ -8,6 +8,9 @@ import com.yammer.metrics.reporting.MetricsServlet
object TestServer extends Instrumented {
val counter1 = metrics.counter("wah", "doody")
val counter2 = metrics.counter("woo")
+ val asplodingGauge = metrics.gauge[Int]("boo") {
+ throw new RuntimeException("asplode!")
+ }
def main(args: Array[String]) {
val server = new Server(8080)

0 comments on commit 86ed300

Please sign in to comment.