puppetlabs/puppetdb — pull request #571 by grimradical (2013-07-19 20:02:42+00:00)
Title: (21618) Track HTTP metrics for each URL, restore compatibility with v2 metrics api

When we migrated to versioned urls, we didn't update our metrics middleware.
Originally, we had urls like /resources, /commands, etc. We configured the
metrics middlware to only take the first component of the path and create a
metric for that, so we had metrics that tracked all requests to /resources,
/commands, etc. and all was right with the world.

When we moved to versioned urls, though, the first path component became /v1,
/v2, etc. So the metrics are now rolled up at that level, which is...not very
useful at all, actually. It also breaks the documented API.

I've modified the call to wrap-with-metrics to instead track metrics for all
the leading components of a url. So if you request /foo/bar/baz, we'll track
metrics for /foo/bar/baz, as well as /foo/bar and /foo. Multiple urls that
share leading path components will be treated as rollups.

Because each url has a corresponding metric, and metrics are exposed via the
/metrics endpoint, to avoid a situation where requesting a metric creates a new
metric (and so on, it's metrics all the way down) I opted to collapse all
metrics requests to a single metric.

I've added back in support for the documented metrics urls, and I added more
explanation around how to get the list of valid metrics.