This makes the low-level code a little more opinionated. If there is a
good reason for making `timers`, `counters`, etc. optional, then we can
PR it into place.
This almost makes mypy happy. I did manage to step on a defect that
there really isn't a great workaround for so I resorted to disabling
typing there.
https://github.com/python/mypy/issues/2427
Agree with @aremm here ... instead of requiring contortions to run
without a prefix, let's just require that it is explicitly set to `None`
if you want to skip the prefix. If you `prefix` isn't in the settings
explicitly, then use `$STATSD_PREFIX` if it is set; otherwise, try to
construct a prefix from service & environment, if that fails, then fail
hard in the initializer.
@nvllsvm likes the interface that https://statsd.readthedocs.io/ exposes
and I agree. I mimicked this interface on the lower-level Connector. I
left the sprockets.mixins.metrics style on the tornado helpers for
compat reasons. You can always use `self.statsd_connector.incr()` in
your request handlers if you prefer the other interface.
I snuck in a call to verify that the connected event is set before the
call to _process_metric. This closes a small loophole where the
transport could be None inside of _process_metric.
Decided to switch the tests to using asynctest so that we can guarantee
support on Python 3.7 and newer. Also added pins in setup.cfg and a
tox.ini file if you want to use it.