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

Clarify the order of mutually exclusive params when creating spans. #136

Merged
merged 2 commits into from
Jun 20, 2019

Conversation

songy23
Copy link
Member

@songy23 songy23 commented Jun 18, 2019

Fixes #133.

The current order is local parent span -> remote parent span context -> no parent, if more than one out of the three parameters are set. Feel free to propose an alternative.

In languages that need to take all the three parameters at the same time when creating a `Span`,
parent `Span` should take precedence, then remote parent `SpanContext`, and `root` comes last.
For example:
3. `tracer.start_span(name='span', parent_span=span1, parent_span_context=ctx, root=true)`
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be language specific. Do we intend to document language specific behavior here? For Python, probably we could take a different approach, do we want to put it in the spec as well (I guess no)?

_default = object()
def start_span(tracer, name, parent=_default):
    if parent is _default:
        parent = tracer.get_current_span()
    ...

tracer.start_span('foobar')  # create a span as a child of the current span (or root span if there is no current span)
tracer.start_span('foobar', parent=parent_span)  # create a child span under span 'parent_span'
tracer.start_span('foobar', parent=None)  # create a root span
tracer.start_span('foobar', parent=ctx)  # create a span as a child of parent context

@c24t

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this PR is a bit language-specific but it's meant to reduce ambiguity in behavior. I think the approach you proposed is still consistent with the current spec, since we mentioned local parent span and remote parent span context are optional parameters so you're free to implement it with default values.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that this is language specific, but I think it's better to keep it this time like this for clarity purposes, while we figure out what other languages do.

We can refine it later ;)

Copy link
Member

Choose a reason for hiding this comment

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

I agree that this is oddly implementation-specific for the spec; it sounds more like a description of a specific language API. It's not clear to me that the spec should require that the start_span method should even handle all three cases.

Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

LGTM, though it seems to be a bit language specific.

Copy link
Member

@iredelmeier iredelmeier left a comment

Choose a reason for hiding this comment

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

Many (most?) languages allow for patterns that would let us avoid the problem solved by both this and #131 (closed too quickly to discuss there), e.g., the Python approach suggested by @reyang or an interface.

I propose that rather than focusing on workarounds, we should encourage patterns that let us avoid the problems altogether.

@SergeyKanzhelev
Copy link
Member

I propose that rather than focusing on workarounds, we should encourage patterns that let us avoid the problems altogether.

Is this comment blocking the PR? Do you have a suggestion on how to rephrase this better?

@carlosalberto
Copy link
Contributor

I propose that rather than focusing on workarounds, we should encourage patterns that let us avoid the problems altogether.

Oh, we can do that, but we need a few people from other languages to chime in and make sure one way or another sounds valid ;)

(Also, we can always change stuff later on, of course)

@SergeyKanzhelev
Copy link
Member

I suggest to merge this as it addresses the immediate problem of describing API surface and clarifying the intent and ordering of fields. Let's iterate on this doc over time

@SergeyKanzhelev SergeyKanzhelev merged commit 57c5735 into open-telemetry:master Jun 20, 2019
@songy23 songy23 deleted the span-creation-params branch June 20, 2019 16:30
@songy23
Copy link
Member Author

songy23 commented Jun 20, 2019

I propose that rather than focusing on workarounds, we should encourage patterns that let us avoid the problems altogether.

Please file an issue for that. Though I'm afraid if we go with this approach we may end up enumerating the behavior for each language in the spec.

SergeyKanzhelev pushed a commit to SergeyKanzhelev/opentelemetry-specification that referenced this pull request Feb 18, 2020
TuckTuckFloof pushed a commit to TuckTuckFloof/opentelemetry-specification that referenced this pull request Oct 15, 2020
rockb1017 pushed a commit to rockb1017/opentelemetry-specification that referenced this pull request Nov 18, 2021
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 21, 2024
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 23, 2024
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
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.

More clarifications on mutually exclusive options in Span creation
6 participants