Do the gethostbyname() lookup lazily, right before the first send.
Do the gethostbyname() lookup lazily, right before the first send.

Summary:
The way we use the statsd client, we create the client object during
the first request, whether we actually want to send data to statsd for
that request or not (it's created in the event_log.flush(), if not
before, which doesn't know whether we had tried to log anything to
statds or not).

In fact, it's possible for an instance to create a statsd client and
*never* send data to it.  In that case, don't even bother trying to
create the socket.  This will save us on our num-sockets appengine
quota, and also avoid a somewhat expensive RPC until we need it.

We were seeing backends fail to start up because of a quota-exceeded
error in /_ah/start due to this gethostbyname() call.  As long as we
don't event-log anything intended for statsd in /_ah/start, this
should keep that from happening again.

As a side note: GAE support said this
(https://enterprise.google.com/supportcenter/managecases#Case/0016000000QWp9w/4063322):

   socket.Resolve() does not consume any quota for "Socket Bytes Sent"
   [but] Resolve() also checks the available quota for "Socket Bytes
   Sent" before its execution (this makes sense because you can do
   nothing with Socket API once you hit this quota)

so this is *two* quota limits that we protect against.

Test Plan: Fingers crossed

Reviewers: chris

Reviewed By: chris

Subscribers: alpert, alan

Differential Revision: http://phabricator.khanacademy.org/D8277

Khan/pystatsd,Khan/pystatsd