This looks like a great start. A couple questions:
Why do the protocols conform to
AnyObject? Is this just another way of restricting the protocol to a class, or does it mean something more? Side note, maybe it would be nice to have a protocol for this like
MetricsObject or something that unites them.
How will you register which
MetricsHandler you want to use? Will that be exactly like how logging works? Something like
How will using shared metrics objects work? It seems that with the current design, if you wanted to use a shared counter, recorder, and timer you would need to pass those all separately (i.e.,
req.recorder.record(...)). Comparing to logging, we have:
Logger, but more than one
Maybe there should be a separate, unified type like
Logger in this package. With Logging, you just pass around the
Logger and you can log any type of message (i.e.,
But I'm not really sure if this difference is a bad thing. Maybe it's a common use case to only want to pass around one type of metrics object.