Create a new worker thread and attach the exporter to it.

    :type endpoint: str
    :param endpoint: address of the opencensus service.

    :type service_name: str
    :param service_name: name of the service

    :type host_name: str
    :param host_name: name of the host (machine or host name)

    :type interval: int or float
    :param interval: Seconds between export calls.

def new_stats_exporter(service_name,
                       hostname=None,
                       endpoint=None,
                       interval=None):
    """Create a new worker thread and attach the exporter to it.

    :type endpoint: str
    :param endpoint: address of the opencensus service.

    :type service_name: str
    :param service_name: name of the service

    :type host_name: str
    :param host_name: name of the host (machine or host name)

    :type interval: int or float
    :param interval: Seconds between export calls.
    """
    endpoint = utils.DEFAULT_ENDPOINT if endpoint is None else endpoint
    exporter = StatsExporter(
        ExportRpcHandler(_create_stub(endpoint), service_name, hostname))

    transport.get_exporter_thread(stats.stats, exporter, interval)
    return exporter