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.
As mentioned in #201 there are some situations where our current APIs fall short. This PR makes some improvements to our existing APIs to make some situations easier to handle. Below is a summary of the changes with some examples demonstrating the improvements.
I have a span, but I want it in a context
We have discussed how it's sometimes covenient to have a handle on span, where in other situations, you need to have a handle on a context containing a span. The Go SIG solved this by having API methods return both a span and a context. While multiple return values are not the best choice for Ruby, we can yield multiple parameters to blocks for Tracer#in_span and Tracer#with_span to achieve the same effect.
Before:
Now:
I have a context, but I want a span
Tracer#current_span takes an optional context parameter to read the current span from a context other than Context.current.
Before:
Now:
Context.with_* methods yield context
The various
Context.with_*
now yield context arguments to blocks they execute.Before:
Now:
There might be more scenarios we need utilities for, but this adds convenience to already existing methods for some use cases that were previously more challenging than they should be.