def METHOD_NAME(*args, **kwargs):
    hit_limit = limit and Scope.profile_count > limit
    if hit_limit or random.random() > probability:
        return f(*args, **kwargs)
    else:
        Scope.profile_count += 1
        # Add a timestamp to the profile output when the callable
        # is actually called.
        final_log_file = '{}-{}{}'.format(base, datetime.now().isoformat(), ext)
        prof = cProfile.Profile()
        try:
            ret = prof.runcall(f, *args, **kwargs)
        finally:
            prof.dump_stats(final_log_file)
        return ret