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

RUMM-2226: Fix handling of span scope in RxJava chain #968

Conversation

0xnm
Copy link
Member

@0xnm 0xnm commented Jun 30, 2022

What does this PR do?

This change fixes the usage of span scope in the RxJava chain.

Documentation of ScopeManager#activate says that "It is a programming error to neglect to call {@link Scope#close()} on the returned instance.". So to comply with that code now stores Scope returned by ScopeManager#activate call and calls Scope#close when related span is finished.

Without doing that the scope is always alive and further scopes created will get it as a parent (and new spans will have finished span as a parent).

Also examples in the docs are updated: code example for Java is slightly different from Kotlin, because Java allows having only final variables being captured, so ThreadLocal is introduced. Normally ThreadLocal could be used in Kotlin as well, because particular Scope is bound to the thread, so having a call on the instance from another thread won't have any effect, but since Kotlin allows any variable to be capture by closure, the code sample is simplified there.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@0xnm 0xnm requested review from a team as code owners June 30, 2022 12:38
Copy link
Contributor

@alai97 alai97 left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@0xnm 0xnm merged commit 4b0cc56 into develop Jul 1, 2022
@0xnm 0xnm deleted the nogorodnikov/rumm-2226/proper-handling-of-span-scope-for-rxjava branch July 1, 2022 06:56
@xgouchet xgouchet added this to the 1.14.0 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants