Skip to content

Instantly share code, notes, and snippets.

@tedsuo
Last active September 14, 2017 18:39
Show Gist options
  • Select an option

  • Save tedsuo/16977473e6808773736f784b56e93d73 to your computer and use it in GitHub Desktop.

Select an option

Save tedsuo/16977473e6808773736f784b56e93d73 to your computer and use it in GitHub Desktop.
ot-rc1

Scope Proposal Release Candidate 1

This Release Candidate proposes an approach to managed Span propagation without enforcing Span lifetime handling through (in-code) reference counting.

Release Candidate objectives

  • Decouple active Span propagation from Span.finish().
  • Remove ActiveSpan/ActiveSpanManager reference counting.

Approach

  • Scope replaces ActiveSpan, removing the Continuation concept.
  • ScopeManager replaces ActiveSpanSource, and is expected to be passed to the Tracer on initialization time.
  • ScopeManager.activate() is used to activate Span objects, and can optionally receive a finishOnClose flag, to either close the Span or not on Scope.close().
  • BaseSpan was removed for clarity, at the expense of extra typing when traversing from Span to Scope.
  • Scope is left with only two meaningful methods: span() and close().
  • ThreadLocalScopeManager replaces ThreadLocalActiveSpanSource, keeping the thread-local storage for active Span, without the reference counting used for Span lifetime handling.

Notes on the approach

  1. By default, using a try (Scope scope = ... also finishes the related Span.
  2. To not finish the span when the scope closes, you must call ScopeManager.activate(span, false) instead.

Notes on Continuations

The inclusion of Continuations and automatic reference counting in 0.30.0 was contentious. The lack of Continuation in the Scope will require some thought on possible migration paths for current users. For most use cases, where the call site to finish is known, the migration should be trivial, but it is possible that there are non-trivial cases.

Furthermore, though they complicate the API, Continuations may have indeed been a requirement for an OpenTracing API that can handle all scenarios. A very important part of testing and exercising this Release Candidate will be around this issue. If Continuations can be proven to be necessary, a follow up Release Candidate will be issued which returns to that pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment