This repository was archived by the owner on May 23, 2023. It is now read-only.

Description
Use Case
Given a parent context, using the following code always results in ChildOfRef:
span, ctx := opentracing.StartSpanFromContext(parentCtx, "foo")
I'd however wish to start a FollowsFromRef from the parent context.
Problem
Using an option doesn't work since the ChildOf() option is appended last and hence takes precedence. Moreover the FollowsFrom() option requires a SpanContext which would be required to be extracted beforehand
// extra (boilerplate) work that would be needed each time
var opts []StartSpanOption
if parentSpan := SpanFromContext(parentCtx); parentSpan != nil {
opts = append(opts, FollowsFrom(parentSpan.Context()))
}
// doesn't work either way since the `ChildOf` option takes precedence
// and adds multiple conflicting references to the span
span, ctx := opentracing.StartSpanFromContext(parentCtx, "foo", opts...)
There is no matching function that can start a FollowsFrom span from context.
Proposal
This can be solved via either of two ways:
- Add a new function
StartFollowsFromSpanFromContext with similar semantics to StartSpanFromContextWithTracer but that creates a FollowsFromRef
or,
- Add a
StartSpanOption to signal StartSpanFromContextWithTracer to use a FollowsFrom instead of ChildOf
Questions to address (if any)
- Which one of the solutions best fits the project semantics.
- If opting for
1., adding a new function for follows from, is minimal code duplication from StartSpanFromContextWithTracer okay?
- If opting for
2., adding a new option but reusing the same function StartSpanFromContext, the current documentation states that it builds a ChildOfRef - would that qualify as major version API change?