-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Exception handling and api normalization #113
Comments
I think this makes a lot of sense. IMO the comparison to false is a major trap and I'm sure we have code that is broken atm because of that. |
Big 👍 for me. Assuming your backend support tags, I'm not sure I would ever use anything except It makes "everything possible" so I'm happy with the direction. |
Hi guys! 😄 I generally agree with the proposed changes. Just 2 things I'd like to mention:
|
Ideally I would do a major version bump since there's quite a bit of changes that devs will need to be aware of and quite a bit of behaviour changes to handle. IMO, if we are able to split the buckets into tags instead, they would all get collapse into the same bucket by default and allow the user to slice for the preferred dimension without loosing anything. |
This would require a major version bump. However, the way you have proposed your changes makes for a very bad upgrade path, because you have to do it in a big bang. That's going to be very painful for many of our own apps, let alone others. I've never been a big fan of these metaprogramming methods. I rather deprecate them, and add new ones that are better. I started something with #104 that I think is a more flexible design. Maybe we can continue that work, and build new metaprogramming methods on top of it? I think we only need one generic metaprogramming method, a MyClass.prepend StatsD::Instrument.measure_method(:my_method) For every other use case, what we mainly need is a way to edit the # I don't like this API but you get the idea
MyClass.prepend StatsD.instrument_method(:my_method) do |metric, parameters, return_value, exception|
metric.name = "#{metric.name}.#parameters[0]"
metric.tags << exception.class.name if exception
end Not too sure of a good API for the second use case. Maybe anyone has good ideas? |
Maybe we should discuss a new major release.
For me, these things have always annoyed me, and I'd like to fix:
|
I had mostly the same annoyance as you :) I'm pretty eager to fix all of these and expose a new major version. I would also propose a few changes for the UdpBackend, expose a per-implementation strategy instead of a primitive symbol like in #109. I think if we go we the ModuleBuilder, we can expose new methods and mark the other as deprecated. As of instance methods such as |
We could separate the |
Fixes: #110
Follow-up on #111, #112
To improve consistency of this library and try to minimize unexpected side-effects from developers, I have a few proposal I'd like to make.
changes to
.statsd_count_if
The README currently states the following:
I propose that instead of comparing against a
false
value that we use the rubyif
directly to evaluate the truthiness/falsyness of the value. If the method raises, no metric will be pushed.changes to
.statsd_count_success
I propose that we evaluate the condition to deliver the metric exactly the same way defined in
.statsd_count_if
. However, instead of creating 2 buckets forsuccess
andfailure
, I propose we add a 3rd bucketerror
for situations where the method raises.changes to measure
.statsd_measure
I propose that this method would push metrics for all situations (normal execution, raise). In other words, it would behave exactly the same way as
.statsd_count
.add
.statsd_measure_success
,.statsd_measure_if
I propose we match the same API we do for
.statsd_count_*
. This would allow us to give more flexibility as to which metrics we want to observe in the end.changes to
#measure
I suggest we create 2 distinct methods:
Note:
measure_success
would have to accept a proc in order to allow the consumer to define whatsuccess
means. By default it will simply check truthy/falsy values.changes to tags/automatic suffixes
For StatsD implementations that supports tags, instead of pushing a metric with a suffix
MetricName.success|failure|error
, we could push them as a tag with the keystatus:#{status}
.Any thoughts/concerns? ❤️
@tjoyal @simon-shopify @wvanbergen @alexsnaps @dnlserrano
The text was updated successfully, but these errors were encountered: