dscape/lynx

"Nothing to send" spam

Opened this issue · 5 comments

Why is it considered an error if there's no stats to send? If you're sending metrics with a sample rate lower than 1.0, you end up with the message "Nothing to send" spamming console.log. Sure, I could set on_error to a no-op, or manually filter out this error, but it seems extraneous. Can we remove it?

Curious about this, too. I'm filtering it in on_error now, but that's an ugly crutch.
It would be trivial to prevent this error message (or just tread it as an error if (all_stats.length === 0 && sample_rate === 1)). But perhaps there is a case where you would still consider it an error, even with sampling? Would be interesting to get @dscape's opinion on this.

This makes sense.

Can you guys show me code that would make this more elegant? If we get into agreement on the API that should be exposed I would take a pull request (if appropriately tested and documented)

thoughts?

IMO the best approach is to simply remove the message. I don't think it's particularly useful.

If you do think it's useful though, then perhaps add an on_no_stats field that has a default (empty) implementation. Consumers can override it to detect this event if they care.

Sam, if you implement this and send a pull request I'll merge it.

Please keep the default behavior as is, since it's good to keep stability
in modules.

Reopen as a PR. Closed.

Hey guys, I was working with Lynx and came across this same issue.

After looking at the implementation of send() and sample() for a while, and the flow of Lynx in comparison to what statsd accomplishes, it brought me to the roughly the same point of thinking that @samcday had, this message doesn't seem very helpful in the context it is in, and simply logging it doesn't seem like the right answer either.

The way I'm interpreting the flow is that stats are sent through sampling no matter what (387), and then returned if they do not contain a sample (582). In the case of samples, they are either an empty object(585), or the actual stat with sample to be sent to statsd (596).

So this error is thrown when there is no stat being sent to statsd whether or not it is sampled data (398). This is where my confusion with the implementation comes into play. I could understand in some cases where you are sending non sampled data, you may want to log that it has Nothing to send, but throwing an error when sending sampled data doesn't really make sense to me. That is expected behavior with statsd, having the ability to not have to send data every single call.

What I was hoping to gain here was some insight into the edge cases where you would want Nothing to send errors to be thrown. There are a few ways this could be resolved, two of which @samcday mentioned already:

  • Remove the Nothing to send messaging entirely
  • Add a flag that users can pass in as options for on_no_stats (or some similar name)
  • Move the messaging to non-sampled stats only

All of which would need a bit of background on the types of use cases you are trying to support with Lynx.

Is it important that consumers know when data was not sent? If users are sending their data via UDP then they are already taking the risk that their data may not reach the destination, and if they are using TCP then they will most likely be looking for some sort of handshake anyway.

All in all, I would love to help resolve this, I'm just trying to make sense of the situations where you would want this to throw an error, and then use that information to put forth a solution.

Thanks!