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

[SYNPY-1344] Remove need to manually propogate otel context #1056

Merged

Conversation

BryanFauble
Copy link
Contributor

@BWMac Which would you prefer: The current way we are passing the context along (No change), or wrapping the calling side to handle for this (This change)?

Problem:
Because we are using run_in_executor to execute blocking code in an async context otel context is not propogating to the new code that is executing. As a result we were required to pass the context along and modify the functions to accept the parameter to make it work.

Solution:
Creating a wrapper function that we can add to run_in_executor that attaches the otel context for us; prevents us from needing to modifying all of the sync code function signatures.

Testing:
I verified I could run our OOP test scripts and all otel context remained:
image

image
image

image
image

@BryanFauble BryanFauble requested a review from a team as a code owner January 26, 2024 20:48
@pep8speaks
Copy link

pep8speaks commented Jan 26, 2024

Hello @BryanFauble! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 1574:89: E501 line too long (92 > 88 characters)
Line 1589:89: E501 line too long (92 > 88 characters)
Line 1660:89: E501 line too long (91 > 88 characters)
Line 1692:89: E501 line too long (105 > 88 characters)
Line 1734:89: E501 line too long (106 > 88 characters)
Line 1735:89: E501 line too long (102 > 88 characters)
Line 1766:89: E501 line too long (91 > 88 characters)

Line 1272:89: E501 line too long (89 > 88 characters)

Line 508:89: E501 line too long (90 > 88 characters)

Comment last updated at 2024-01-29 18:31:52 UTC

Base automatically changed from SYNPY-1344-activity-model to develop January 29, 2024 18:14
Copy link

sonarcloud bot commented Jan 29, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

5 New issues
0 Security Hotspots
96.9% Coverage on New Code
7.8% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

Choose a reason for hiding this comment

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

@BryanFauble On a high level, I prefer this over passing around the context manager. I haven't had the time to review closer, but this is great.

Can the team @Sage-Bionetworks/dpe pitch in on this review?

@BWMac BWMac requested a review from a team January 29, 2024 21:00
Copy link
Contributor

@BWMac BWMac left a comment

Choose a reason for hiding this comment

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

I like this change. LGTM but just one question.

OpenTelemetry context to the thread or context that the function is running on.

This is a hack to get around AsyncIO `run_in_executor` not propagating the context
to the code it's executing. When we are directly calling async functions after
Copy link
Contributor

Choose a reason for hiding this comment

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

If we can remove this after SYNPY-1411 is complete, what does the difference between making this change now vs. later look like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making the change to use this wrapper now prevents us from needing to modify the code in client.py to manually propagate the OTEL context.

Making the change later means we will have had to propagate the OTEL to the rest of the sync methods we want to call in client.py that haven't been called yet. And all those methods need to be changed back.

@BryanFauble BryanFauble merged commit a46bf18 into develop Jan 29, 2024
38 checks passed
@BryanFauble BryanFauble deleted the SYNPY-1344-remove-need-to-manually-propogate-otel-context branch January 29, 2024 21:36
Copy link
Contributor

@BWMac BWMac left a comment

Choose a reason for hiding this comment

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

Looks good, I really like the mixin for permissions. Only thing is permissions issues for the demo script. I'll come back and approve once I can run it.

Copy link
Contributor

@BWMac BWMac left a comment

Choose a reason for hiding this comment

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

Looks good, I really like the mixin for permissions. Only thing is permissions issues for the demo script. I'll come back and approve once I can run it.

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.

None yet

4 participants