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

Propagate spans to tasks #7898

Merged
merged 2 commits into from
Jul 5, 2023
Merged

Propagate spans to tasks #7898

merged 2 commits into from
Jul 5, 2023

Conversation

crusaderky
Copy link
Collaborator

@crusaderky crusaderky commented Jun 9, 2023

Allow spans information to be accessed by tasks.
This is useful, e.g.

  • for logging
  • when the task itself wants to spawn more tasks, e.g.
def process_df(uri):
    with span("load"):
        df = dd.read_parquet(uri)
    with span("reduce"):
        out = ...(df)
    client = get_client()
    secede()
    return out.compute()

client = Client()
with span("foo"):
    foo = client.submit(process_df, "s3://mybucket/foo.parquet", key="foo")
with span("bar"):
    bar = client.submit(process_df, "s3://mybucket/bar.parquet", key="bar")
client.gather([foo, bar])

The above example will produce spans

  • ("foo", "load")
  • ("foo", "reduce")
  • ("bar", "load")
  • ("bar", "reduce")

@crusaderky
Copy link
Collaborator Author

CC @ntabris @hendrikmakait

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2023

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

       20 files  +       1         20 suites  +1   11h 44m 11s ⏱️ + 1h 14m 51s
  3 704 tests +       1    3 595 ✔️ ±       0     106 💤 ±  0  3 +1 
35 826 runs  +1 348  34 075 ✔️ +1 266  1 748 💤 +81  3 +1 

For more details on these failures, see this check.

Results for commit d51b536. ± Comparison against base commit 67e073f.

♻️ This comment has been updated with latest results.

@crusaderky crusaderky force-pushed the propagate_spans branch 9 times, most recently from d8e6689 to 91b99b4 Compare June 22, 2023 21:20
@crusaderky crusaderky marked this pull request as ready for review June 22, 2023 22:54
@crusaderky crusaderky requested a review from fjetter as a code owner June 22, 2023 22:54
@ntabris
Copy link
Contributor

ntabris commented Jun 22, 2023

Is there a simple example of how to use this for logging?

distributed/spans.py Outdated Show resolved Hide resolved
@crusaderky
Copy link
Collaborator Author

Is there a simple example of how to use this for logging?

You may retrieve the current span with dask.get_annotations().get("span").
You can do so in the client code as well as from inside a task.

@crusaderky crusaderky mentioned this pull request Jun 23, 2023
4 tasks
@hendrikmakait hendrikmakait added the needs review Needs review from a contributor. label Jul 4, 2023
@hendrikmakait hendrikmakait self-requested a review July 4, 2023 08:02
Copy link
Member

@hendrikmakait hendrikmakait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @crusaderky! CI failures appear to be unrelated.

distributed/worker.py Outdated Show resolved Hide resolved
@crusaderky crusaderky merged commit a47cb0a into dask:main Jul 5, 2023
@crusaderky crusaderky deleted the propagate_spans branch July 5, 2023 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Needs review from a contributor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants