socrata/socrata-http — pull request #3 by velvia (2014-09-18 08:14:46+00:00)
Title: NewLoggingHandler and Metrics

This PR forms the basis for metrics in the NBE.

- NewLoggingHandler has slightly different API from LoggingHandler and supports logging of request and response headers. Intended for request ID tracing and rollup tracing.
- Automatic instrumentation of routes via CodaHale metrics' Jetty9 InstrumentedHandler. Right now just a boolean enable/disable. Also will log all metrics every minute to log files. The logging looks like this:

```
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,164 type=METER, name=com.socrata.http.server.CountingHandler.1xx-responses, count=0, mean_rate=0.0, m1=0.0, m5=0.0, m15=0.0, rate_unit=events/second
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,165 type=METER, name=com.socrata.http.server.CountingHandler.2xx-responses, count=1, mean_rate=0.002778053129143761, m1=1.5037346967491512E-4, m5=0.00129993948281941, m15=8.117790455645684E-4, rate_unit=events/second
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,165 type=METER, name=com.socrata.http.server.CountingHandler.3xx-responses, count=0, mean_rate=0.0, m1=0.0, m5=0.0, m15=0.0, rate_unit=events/second
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,165 type=METER, name=com.socrata.http.server.CountingHandler.4xx-responses, count=0, mean_rate=0.0, m1=0.0, m5=0.0, m15=0.0, rate_unit=events/second
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,165 type=METER, name=com.socrata.http.server.CountingHandler.5xx-responses, count=0, mean_rate=0.0, m1=0.0, m5=0.0, m15=0.0, rate_unit=events/second
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,165 type=METER, name=com.socrata.http.server.CountingHandler.async-dispatches, count=0, mean_rate=0.0, m1=0.0, m5=0.0, m15=0.0, rate_unit=events/second
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,165 type=METER, name=com.socrata.http.server.CountingHandler.async-timeouts, count=0, mean_rate=0.0, m1=0.0, m5=0.0, m15=0.0, rate_unit=events/second
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,165 type=TIMER, name=com.socrata.http.server.CountingHandler.connect-requests, count=0, min=0.0, max=0.0, mean=0.0, stddev=0.0, median=0.0, p75=0.0, p95=0.0, p98=0.0, p99=0.0, p999=0.0, mean_rate=0.0, m1=0.0, m5=0.0, m15=0.0, rate_unit=events/second, duration_unit=milliseconds
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,166 type=TIMER, name=com.socrata.http.server.CountingHandler.delete-requests, count=0, min=0.0, max=0.0, mean=0.0, stddev=0.0, median=0.0, p75=0.0, p95=0.0, p98=0.0, p99=0.0, p999=0.0, mean_rate=0.0, m1=0.0, m5=0.0, m15=0.0, rate_unit=events/second, duration_unit=milliseconds
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,166 type=TIMER, name=com.socrata.http.server.CountingHandler.dispatches, count=1, min=29.0, max=29.0, mean=29.0, stddev=0.0, median=29.0, p75=29.0, p95=29.0, p98=29.0, p99=29.0, p999=29.0, mean_rate=0.0027780401096486875, m1=1.5037346967491512E-4, m5=0.00129993948281941, m15=8.117790455645684E-4, rate_unit=events/second, duration_unit=milliseconds
[metrics-logger-reporter-1-thread-1] INFO socrata-metrics 2014-09-18 01:00:56,167 type=TIMER, name=com.socrata.http.server.CountingHandler.get-requests, count=1, min=30.0, max=30.0, mean=30.0, stddev=0.0, median=30.0, p75=30.0, p95=30.0, p98=30.0, p99=30.0, p999=30.0, mean_rate=0.0027780392993107046, m1=1.5037346967491512E-4, m5=0.00129993948281941, m15=8.117790455645684E-4, rate_unit=events/second, duration_unit=milliseconds
```

This is not quite done yet but you guys can have a look. I might push some slight patches for the JettyServlet stuff to enable Swagger.