Set the (host, port) to connect to from the environment.

    If the environment is updated, a call to this function will update the
    address this client connects to.

    This function will prefer to use the ``STATSD`` connection string
    environment variable, but will fall back to using the ``STATSD_HOST``
    and ``STATSD_PORT``.

def set_address():
    """Set the (host, port) to connect to from the environment.

    If the environment is updated, a call to this function will update the
    address this client connects to.

    This function will prefer to use the ``STATSD`` connection string
    environment variable, but will fall back to using the ``STATSD_HOST``
    and ``STATSD_PORT``.

    """
    global STATSD_ADDR
    connection_string = os.getenv('STATSD')
    if connection_string:
        url = urlparse.urlparse(connection_string)
        STATSD_ADDR = (url.hostname, url.port)
    else:
        STATSD_ADDR = (os.getenv('STATSD_HOST', 'localhost'),
                       int(os.getenv('STATSD_PORT', 8125)))