This repository was archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 313
StartSpanFromContext cannot be used with FollowFromRefΒ #249
Copy link
Copy link
Open
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
StartFollowsFromSpanFromContextwith similar semantics toStartSpanFromContextWithTracerbut that creates aFollowsFromRef
or,
- Add a
StartSpanOptionto signalStartSpanFromContextWithTracerto use aFollowsFrominstead ofChildOf
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 fromStartSpanFromContextWithTracerokay? - If opting for
2., adding a new option but reusing the same functionStartSpanFromContext, the current documentation states that it builds aChildOfRef- would that qualify as major version API change?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels