RUMM-2226: Fix handling of span scope in RxJava chain #968
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 storesScope
returned byScopeManager#activate
call and callsScope#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, soThreadLocal
is introduced. NormallyThreadLocal
could be used in Kotlin as well, because particularScope
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)