Skip to content

add IsRemote field to SpanContext, set by propagators#216

Merged
SergeyKanzhelev merged 5 commits intoopen-telemetry:masterfrom
tsloughter:ctx-is-remote
Oct 3, 2019
Merged

add IsRemote field to SpanContext, set by propagators#216
SergeyKanzhelev merged 5 commits intoopen-telemetry:masterfrom
tsloughter:ctx-is-remote

Conversation

@tsloughter
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

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

@bogdandrutu
Copy link
Copy Markdown
Member

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

@tsloughter
Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
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
Copy Markdown
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".

`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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@tsloughter
Copy link
Copy Markdown
Member Author

@yurishkuro it is used in the probability sampler https://github.com/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
Copy Markdown
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.

@SergeyKanzhelev SergeyKanzhelev merged commit 420d77c into open-telemetry:master Oct 3, 2019
SergeyKanzhelev pushed a commit to SergeyKanzhelev/opentelemetry-specification that referenced this pull request Feb 18, 2020
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
schmikei pushed a commit to schmikei/opentelemetry-specification that referenced this pull request Apr 17, 2025
…en-telemetry#216)

Co-authored-by: Johannes Tax <johannes@johannes.tax>
Co-authored-by: Armin Ruech <armin.ruech@dynatrace.com>
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