Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add IsRemote field to SpanContext, set by propagators #216

Merged
merged 5 commits into from
Oct 3, 2019

Conversation

tsloughter
Copy link
Member

Without a field to mark if a SpanContext came from a remote process Span creation and sampling can not know if the new span has a remote parent.

This PR adds a IsRemote field to SpanContext and defines that it must be set when deserializing a propagated SpanContext.

This is additionally important for implementations that can not pass the parent Span as an argument to startSpan but only a SpanContext. That is the case with the Erlang/Elixir implementations because the content of a Span is kept in a table (since it needs to be able to be mutated) while the SpanContext is an immutable record.

Closes #187

@bogdandrutu
Copy link
Member

@tsloughter let's wait couple of days until we put the RFC for sampling, the hasRemoteParent may be removed, otherwise I really like this proposal if the remote parent stays.

@tsloughter
Copy link
Member Author

@bogdandrutu ok, sounds good. Curious to see the sampling RFC.

@bogdandrutu
Copy link
Member

Please see the RFC proposal open-telemetry/oteps#24

@tsloughter
Copy link
Member Author

Now that the sampling rfc has been merged is this ready?

Copy link
Member

@songy23 songy23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about HasRemoteParent? IsRemote sounds like describing the property of a span context itself, rather than its parent.

@yurishkuro
Copy link
Member

it is indeed the property of the context itself. E.g. in this OpenTracing example:

ctx = tracer.extract(Format.HTTP, request.headers)
span = tracer.startSpan('name', childOf=ctx)

the ctx here is "remote".

@@ -30,7 +30,7 @@ Returns the sampling Decision for a `Span` to be created.
- `SpanContext` of a parent `Span`. Typically extracted from the wire. Can be
`null`.
- Boolean that indicates that `SpanContext` was extracted from the wire, i.e.
parent `Span` is from the different process.
parent `Span` is from the different process, meaning `IsRemote` is set to true.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that boolean is contained in the SpanContext, I'd remove the extra argument altogether.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, probably can remove the boolean argument.

@Oberon00
Copy link
Member

Oberon00 commented Sep 3, 2019

What about, instead of a boolean, the SpanContext having an optional reference to the in-process Span, null meaning that it is remote?

@tsloughter
Copy link
Member Author

@Oberon00 that is an interesting idea since in the Erlang impl I currently do similar. The term stored when a span is created is {SpanCtx, Parent} where Parent is another {SpanCtx, Parent} and so on. This allows for easily making the parent the current span context when finishing a span.

@bogdandrutu
Copy link
Member

@Oberon00 Having a reference to the "Span" causes a circular dependencies because Span also has a reference to the SpanContext. I think we should not do that.

@Oberon00
Copy link
Member

Span also has a reference to the SpanContext

Not necessarily. It could just store the required info directly (or in some SpanContextData object that is equivalent to SpanContext minus back-reference) and create a SpanContext on demand.

Also, I don't think a circular dependency is really a problem here, Span and SpanContext are closely related anyway.

@yurishkuro
Copy link
Member

@tsloughter do you mind elaborating why you need isRemote? What would startSpan do differently?

@tsloughter
Copy link
Member Author

@yurishkuro it is used in the probability sampler https:/open-telemetry/oteps/blob/eeab6a2d1342abb58ad5e7c0aadaaa4b1ab32310/text/0006-sampling.md#default-samplers

Allows users to configure if probability applies only for "root spans", "root spans and remote parent", or "all spans".

    Default is to apply only for "root spans and remote parent".
    Remote parent property should be added to the SpanContext see specs PR/216

@yurishkuro
Copy link
Member

I would suggest putting the circular reference discussion aside, as it is not related to this issue, only as an implementation detail. If we want to support configurable upsamping scenarios at "local root" spans, and expose it via sampling API (not just implementation), then we need isRemote in the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to know a parent is remote when starting a span
7 participants