How to use the eliot.start_action function in eliot

To help you get started, we’ve selected a few eliot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github twisted / txacme / src / integration / test_client.py View on Github external
def _test_register(self, new_reg=None):
        with start_action(action_type=u'integration:register').context():
            return (
                DeferredContext(self.client.register(new_reg))
                .addActionFinish())
github twisted / txacme / src / integration / test_client.py View on Github external
def _test_poll_pending(self, auth):
        action = start_action(action_type=u'integration:poll_pending')
        with action.context():
            return (
                DeferredContext(self.client.poll(auth))
                .addCallback(
                    lambda auth:
                    self.assertEqual(auth[0].body.status, STATUS_PENDING))
                .addActionFinish())
github ClusterHQ / flocker / flocker / provision / _libcloud.py View on Github external
Message.log(
            message_type=(
                u"flocker:provision:libcloud:retry_exception:got_exception"
            ),
        )
        write_failure(failure)
        saved_failure[0] = failure
        return False

    def make_call():
        d = maybeDeferred(f)
        d = DeferredContext(d)
        d.addCallbacks(handle_success, errback=handle_failure)
        return d.result

    action = start_action(
        action_type=u"flocker:provision:libcloud:retry_exception",
        function=function_serializer(f),
    )
    with action.context():
        d = loop_until(reactor, make_call, steps)
        d = DeferredContext(d)
        d.addCallbacks(
            lambda _: saved_result[0],
            errback=lambda _: saved_failure[0],
        )
        return d.addActionFinish()
github LeastAuthority / leastauthority.com / src / lae_automation / subscription_converger.py View on Github external
def _converge_logic(actual, config, subscriptions, k8s, aws):
    convergers = [
        _converge_s3,
        _converge_service,
        _converge_configmaps,
        _converge_deployments,
        _converge_replicasets,
        _converge_pods,
        _converge_route53_customer,
        _converge_route53_infrastructure,
    ]

    jobs = []
    for converger in convergers:
        with start_action(action_type=converger.func_name):
            jobs.extend(converger(actual, config, subscriptions, k8s, aws))

    return jobs
github ClusterHQ / flocker / flocker / node / agents / gce.py View on Github external
dict.

    :param compute: The GCE compute python API object.
    :param operation: A dict representing a pending GCE operation resource.
        This can be either a zone or a global operation.
    :param timeout_steps: Iterable of times in seconds to wait until timing out
        the operation.
    :param sleep: a callable taking a number of seconds to sleep while
        polling. Defaults to `time.sleep`

    :returns dict: A dict representing the concluded GCE operation
        resource or `None` if the operation times out.
    """
    poller = _create_poller(operation)

    with start_action(
        action_type=u"flocker:node:agents:gce:wait_for_operation",
        operation=operation
    ) as action:
        def finished_operation_result():
            latest_operation = poller.poll(compute)
            if latest_operation['status'] == 'DONE':
                return latest_operation
            return None

        final_operation = poll_until(
            finished_operation_result,
            timeout_steps,
            sleep
        )
        action.add_success_fields(final_operation=final_operation)
        return final_operation
github itamarst / eliot / benchmarks / serialization.py View on Github external
def run():
    start = time.time()
    for i in range(N):
        with start_action(action_type="my_action"):
            with start_action(action_type="my_action2"):
                Message.log(
                    message_type="my_message",
                    integer=3, string=b"abcdeft", string2="dgsjdlkgjdsl",
                    list=[1, 2, 3, 4])
    end = time.time()

    # Each iteration has 5 messages: start/end of my_action, start/end of
    # my_action2, and my_message.
    print("%.6f per message" % ((end - start) / (N * 5),))
    print("%s messages/sec" % (int(N / (end-start)),))
github applied-mixnetworks / txmix / txmix / client.py View on Github external
def message_received(self, message):
        """
        receive a message
        """
        action = start_action(
            action_type=u"mix client:message received",
            client_id=binascii.hexlify(self.client_id),
        )
        with action.context():
            self.message_received_handler(message)
github LeastAuthority / leastauthority.com / src / lae_automation / subscription_converger.py View on Github external
def get_customer_grid_deployments(k8s, namespace):
    action = start_action(action_type=u"load-deployments")
    with action.context():
        d = DeferredContext(k8s.get_deployments(_s4_selector(namespace)))
        def got_deployments(deployments):
            deployments = list(deployments)
            action.add_success_fields(deployment_count=len(deployments))
            _DEPLOYMENTS.set(len(deployments))
            return deployments
        d.addCallback(got_deployments)
        return d.addActionFinish()
github LeastAuthority / leastauthority.com / src / lae_automation / subscription_converger.py View on Github external
def delete_route53_rrsets(route53, zone, subscription_ids):
    a = start_action(action_type=u"delete-route53", subscription_ids=list(subscription_ids))
    with a.context():
        d = route53.change_resource_record_sets(zone.identifier, list(
            delete_rrset(_rrset_for_subscription(subscription_id, zone.name))
            for subscription_id
            in subscription_ids
        ))
        d = DeferredContext(d)
        return d.addActionFinish()