def send_telemetry()

in src/sfctl/telemetry.py [0:0]


def send_telemetry():
    """
    Send telemetry to the provided instrumentation key. This does not includes a check to
        previously unsent telemetry for offline work.

    We don't want to keep retrying if this keeps failing.
    Increment the telemetry send retry counter in the state file before each attempt.
    Successful telemetry send will reset the counter.
    After the TELEMETRY_RETRY_MAX count, only try sending telemetry every TELEMETRY_RETRY_INTERVAL

    :return: None
    """

    # Mark the start of a telemetry send attempt
    attempt_number = increment_telemetry_send_retry_count()

    # Do not try sending telemetry if we exceed the retry count, and if we are not at the send
    # interval
    if attempt_number > TELEMETRY_RETRY_MAX:
        if ((attempt_number - TELEMETRY_RETRY_MAX) % TELEMETRY_RETRY_INTERVAL) != 0:
            # Don't bother sending telemetry
            logger.info('Not sending telemetry due to too many failed attempts.')
            return
        logger.info('Sending telemetry because retry interval is met.')

    # Get the path of where this file (telemetry.py) is.
    current_file_location = \
        os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))

    # This is the absolute path.
    send_telemetry_background_path = \
        os.path.join(current_file_location, 'send_telemetry_background.py')

    # subprocess.run is the newer version of the call command (python 3.5)
    # If you close the terminal, this process will end as well.
    Popen(['python', send_telemetry_background_path], close_fds=True)

    return