As of Eliot 1.8, asyncio and trio coroutines have appropriate context propogation for Eliot, automatically.

On Python 3.7 or later, no particular care is needed. For Python 3.5 and 3.6 you will need to import either eliot (or the backport package aiocontextvars ) before you create your first event loop.

Here’s an example using aiohttp :

import asyncio import aiohttp from eliot import start_action , to_file to_file ( open ( "linkcheck.log" , "w" )) async def check_links ( urls ): session = aiohttp . ClientSession () with start_action ( action_type = "check_links" , urls = urls ): for url in urls : try : with start_action ( action_type = "download" , url = url ): async with session . get ( url ) as response : response . raise_for_status () except Exception as e : raise ValueError ( str ( e )) try : loop = asyncio . get_event_loop () loop . run_until_complete ( check_links ([ "http://eliot.readthedocs.io" , "http://nosuchurl" ]) ) except ValueError : print ( "Not all links were valid." )

And the resulting logs: