-
Notifications
You must be signed in to change notification settings - Fork 27
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
Consider adding send
-like method to MetricBuilder
that ignores results
#65
Comments
I was wondering if there's an example of a naming convention for that in the standard library. The only similar thing I found so far is But those methods are marked Another option might be |
|
I think every rust metrics lib I've seen returns a Result. I'm wondering if it's the wrong default in the first place w/ the nature of metrics, do most users ignore send results? Maybe StatsdClient could have an error_handler (say defaulting to logging an error!) while changing send to not return a Result, w/ an alternative send API that does. Then at least the typical behavior isn't a complete ignore |
Yeah that would also work for us. So you'd probably have |
I like the idea of some sort of error handler such that errors aren't completely ignored. |
Change the behavior of the `MetricBuilder::send()` method to not return a result based on the sending of the metric. Users that wan the result can now use the `MetricBuilder::try_send()` method for sending metrics. On success, the output from sending the metric with `.send()` is discarded. On error, a user supplied error handler is invoked to consume the error. By default, if no handler is supplied, the errors are sillently discarded. The motivation for discarding errors has a few parts: * We don't want to add another dependency to Cadence. * There have been issues opened in the past to remove logging from Cadence. * Users that want to do something more elaborate will have a better idea of the right course of action that us. Fixes #65
Change the behavior of the `MetricBuilder::send()` method to not return a result based on the sending of the metric. Users that want the result can now use the `MetricBuilder::try_send()` method for sending metrics. On success, the output from sending the metric with `.send()` is discarded. On error, a user supplied error handler is invoked to consume the error. By default, if no handler is supplied, the errors are silently discarded. The motivation for discarding errors has a few parts: * We don't want to add another dependency to Cadence. * There have been issues opened in the past to remove logging from Cadence. * Users that want to do something more elaborate will have a better idea of the right course of action that us. Fixes #65
Change the behavior of the `MetricBuilder::send()` method to not return a result based on the sending of the metric. Users that want the result can now use the `MetricBuilder::try_send()` method for sending metrics. On success, the output from sending the metric with `.send()` is discarded. On error, a user supplied error handler is invoked to consume the error. By default, if no handler is supplied, the errors are silently discarded. The motivation for discarding errors has a few parts: * We don't want to add another dependency to Cadence. * There have been issues opened in the past to remove logging from Cadence. * Users that want to do something more elaborate will have a better idea of the right course of action than us. Fixes #65
Change the behavior of the `MetricBuilder::send()` method to not return a result based on the sending of the metric. Users that want the result can now use the `MetricBuilder::try_send()` method for sending metrics. On success, the output from sending the metric with `.send()` is discarded. On error, a user supplied error handler is invoked to consume the error. By default, if no handler is supplied, the errors are silently discarded. The motivation for discarding errors has a few parts: * We don't want to add another dependency to Cadence. * There have been issues opened in the past to remove logging from Cadence. * Users that want to do something more elaborate will have a better idea of the right course of action than us. Fixes #65
Per #63, an attribute was added to the
MetricBuilder
to warn when it was unused. Thus, code like the following (incorrect, since the metric isn't sent) would generate a warning:However, the following (totally reasonable) code also generates a warning:
To avoid the warning, users need to do something with the
Result
from.send()
, like...To solve this, @robinst has suggested adding another method to
MetricBuilder
that sends the metric but does not return a result so that callers aren't forced to do something perfunctory with it.Example (using the name
send_quiet
which I'm not at all attached to):What are people's thoughts on this? Does adding another
send
-like method seem acceptable? If so, any thoughts on a name?/cc @robinst @pjenvey
The text was updated successfully, but these errors were encountered: