interagent / pliny

An opinionated toolkit for writing excellent APIs in Ruby.
MIT License
802 stars 73 forks source link

Add #count and #measure methods to Pliny #268

Closed gudmundur closed 8 years ago

gudmundur commented 8 years ago

Adds Pliny::Metrics.count(*names, value: 1) and Pliny::Metrics.measure(*names, &block) methods. By invoking the methods, they will emit logfmt entries.

Examples

brandur commented 8 years ago

Good stuff! Two thoughts:

  1. It may be worth thinking about making the metrics module configurable so that there could be more future options beyond just emitting log lines. I think most of the Heroku/Pliny practices are reasonable enough to emulate elsewhere, but I've always thought of the log-based emission somewhat contentious just because it's quite inefficient/expensive compared to say a UDP-based solution for example.
  2. Should we force the metrics helpers to be referenced at Pliny::Metrics rather than mixing them into the top level namespace? It's a little more typing, but I don't think the explicitness is a bad thing.
gudmundur commented 8 years ago

@brandur I've moved the methods into Pliny::Metrics. As for abstracting away how the metrics are emitted, I'd prefer to punt on that until that use case actually comes up. Is that alright with you?

brandur commented 8 years ago

@brandur I've moved the methods into Pliny::Metrics. As for abstracting away how the metrics are emitted, I'd prefer to punt on that until that use case actually comes up. Is that alright with you?

@gudmundur Yep, absolutely! It seems like the interface should be generic enough that it won't back us into a corner.

LGTM! Sorry about the review delay. Feel free to bump these more often if I'm not answering because it might mean that I declared inbox zero on GitHub issues :)