https://dagster.io/ logo
Title
a

Alex Molotsky

02/14/2022, 3:50 PM
Hi! is there any way I can fetch the run_id without having access to the 'SolidExecutionContext'?
a

alex

02/14/2022, 4:31 PM
could you add more detail about where you are where a
run_id
would exist but you dont have access to the
context
?
The short answer is no - but may be some thing we can advise with some more detail.
a

Alex Molotsky

02/14/2022, 4:42 PM
I'm not sure what's the best practice, but basically I need to attach 'run_id' to every single log message in my app. This will require me to change the signatures of every function that needs to log (to accept context as a param). Is there maybe an easier way to retrieve the current context?
a

alex

02/14/2022, 5:01 PM
Not currently, but it is a reasonable request. Could you file an issue? cc @chris In the mean you could set your own process global /
ContextVar
from an op or resource
c

chris

02/14/2022, 5:03 PM
I’m not sure if we already have an issue for pulling a context out of thin air but I can make one if not
o

owen

02/14/2022, 5:10 PM
you can use the get_dagster_logger function to get a logger that will log messages w/ all the dagster context info (run_id, step key, job name, etc.) on it. It won't give you direct access to the context object, but if you just need the run_id to be in the log messages, that should work for you.
❤️ 2