-
-
Notifications
You must be signed in to change notification settings - Fork 722
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
Make annotations available in the thread_state #6932
Comments
Thanks for the issue @averri. I've transferred this over to the Without digging too deeply, this seems not unreasonable as the worker (and worker state machine) cc @gjoseph92 @fjetter as you may find this interesting |
Hi @jrbourbeau, thank you so much for your reply. I agree with you, It needs a change in the signature of the function |
I'm a bit on the fence here.
I also see the problem that annotations are used to set various other things, like
This is interesting and I'd love to learn more about your use case and how we can help beyond annotations. We're tracing some internal calls as well with a unique ID and I wanted to improve/rework our logging system for a very long time now, see #4762 |
Hi @fjetter, I agree with your points (1) and (2). For point (2), maybe it should use another name different than annotations... I thought about a generic name like So, the # Here the context_data will be made available to all tasks submitted inside this context manager.
with distributed.context(**context_data):
with Client(**params) as cli:
# Submit the workload, using map/submit/get From any task's code, developers can use: context = get_context(default={})
if "user_roles" in context and "admin" in context["user_roles"]:
# Do something that only admins can do. A custom logging formatter can inspect the context and extract information to print the logs: class DaskLogContextFormatter(Formatter):
def format(self, record: LogRecord):
# get_context from Dask distributed.
context = get_context()
if context and "request_id" in context:
record.request_id = context["request_id"]
return self.format(record) Configuring the Python logging formatter above and providing the More powerful features like the ones provided by Openmonitoring can also be implemented using that. |
The following is a useful code that Dask distributed provides to get the key from a task, inside the task code:
I would like to suggest making the annotations available using the same mechanism:
This is very important to facilitate the implementation of distributed tracing and log correlation using single request ids, provided via annotations.
The text was updated successfully, but these errors were encountered: