Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: best practice for multi-process/multi-host logging #306

Open
stefanfoulis opened this issue May 1, 2018 · 2 comments
Open

Question: best practice for multi-process/multi-host logging #306

stefanfoulis opened this issue May 1, 2018 · 2 comments

Comments

@stefanfoulis
Copy link

For the case where a web request triggers a task on a queue to later execute: is it ok if the eliot action originally in the request has "finished" already, but the async task running in another process still adds messages to the sub-action?

Pseudocode (Django-ish, Celery-ish):

# in the web process handling requests
def a_view(request):
	with eliot.start_action('my-web-request') as action:
		my_background_task.delay(
			eliot_action_uuid=action.serialize_task_id().decode('ascii')
		)
	# at this point the action as already finished, but the code in
	# my_background_task has not run yet.
# in a worker process handling background tasks
def my_background_task(eliot_action_uuid):
	with eliot.Action.continue_task(task_id=eliot_action_uuid):
		# here we're logging stuff somewhere in the subtree of an 
		# action that is actually already "finished".
		do_stuff()

Is this ok? Or should this be avoided?

@itamarst
Copy link
Owner

itamarst commented May 1, 2018

This is OK, yes - it's one of the reasons Eliot does causal ordering rather than time-based ordering. It makes certain use cases (e.g. profiling) trickier, but it's an accurate representation of many situations.

This should probably be some sort of FAQ or documentation entry, so leaving issue open for that.

@stefanfoulis
Copy link
Author

Thanks @itamarst that information helped me a lot in figuring out how to use eliot :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants