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

Add __getnewargs__ to SpanContext class #1380

Merged
merged 11 commits into from
Nov 16, 2020
Merged

Add __getnewargs__ to SpanContext class #1380

merged 11 commits into from
Nov 16, 2020

Conversation

rickychu
Copy link
Contributor

@rickychu rickychu commented Nov 13, 2020

Description

SpanContext does not support pickle due to missing getnewargs function. Add function to SpanContext.

Fixes # (issue)
#1375

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Tor

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@rickychu rickychu requested review from a team, toumorokoshi and aabmass and removed request for a team November 13, 2020 04:25
Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

Interesting. Just out of curiosity, what was the use case that made you open this PR, @rickychu?

@rickychu
Copy link
Contributor Author

rickychu commented Nov 13, 2020

Interesting. Just out of curiosity, what was the use case that made you open this PR, @rickychu?

I have a multiprocessing script where the pools need to continue with the span context so it has to be pickled.

def processing_data():
    ...
    with tracer.start_as_current_span("processing_data") as span:
        work_items = get_all_work_items_to_process()

    ...
    with multiprocessing.Pool(cpu_limit) as pool:
        pool.map(partial(worker, context=span.get_current_context()), work_items)

Error:
TypeError: new() missing 2 required positional arguments: 'span_id' and 'is_remote'

It works in 0.13b0 with span.get_context()

Copy link
Member

@toumorokoshi toumorokoshi left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@codeboten codeboten merged commit f1db112 into open-telemetry:master Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants