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

Why is there a DefaultSpan? #1135

Closed
yurishkuro opened this issue Apr 24, 2020 · 13 comments
Closed

Why is there a DefaultSpan? #1135

yurishkuro opened this issue Apr 24, 2020 · 13 comments
Labels
priority:p2 Medium priority issues and bugs. release:required-for-ga Required for 1.0 GA release

Comments

@yurishkuro
Copy link
Member

There is no such concept in the specification, but this class is present in the Java API.

https://github.com/open-telemetry/opentelemetry-java/blob/efc49522ac4fd01bcf94afa60789264515aa75cd/api/src/main/java/io/opentelemetry/trace/DefaultSpan.java

Can it not be hidden inside the SDK as implementation detail?

@jkwatson
Copy link
Contributor

@carlosalberto Can probably answer this more completely than I can, but the purpose of the DefaultSpan is to provide an implementation when there is no SDK installed. The implementation does context propagation but nothing else.

@yurishkuro
Copy link
Member Author

I don't think that's the only reason, because such default implementation can be done without exposing the DefaultSpan as a public class in the API.

@jkwatson
Copy link
Contributor

jkwatson commented Apr 24, 2020

Looks like the only usage that's keeping it from being made package-access is in the HttpTraceContext implementation (and other Propagators). @carlosalberto would probably have the most insight into why that leaked in there.

@bogdandrutu
Copy link
Member

@yurishkuro I am happy to work on making the default implementations not public. Would also be good to make this call across different languages, currently looking for example at go https://godoc.org/go.opentelemetry.io/otel/api/trace there a Noop public types. I think it is good to be consistent.

@carlosalberto
Copy link
Contributor

Well, having DefaultSpan accessible (or at least, allowing the user to create it) allows us to do some in-propagation stuff.

I'd like us to offer a way to keep this, if possible (by keeping a method somewhere, that returns an empty Span out of a SpanContext).

@yurishkuro
Copy link
Member Author

Can you be specific? What does it allow?

@carlosalberto
Copy link
Contributor

Hey @yurishkuro

So it allows users to use a SpanContext as a Span. Moreover, with the latest changes from OTEP 66, this is the only way to store an active SpanContext there:

Context context = TracingContextUtils.withSpan(DefaultSpan.create(spanContext)); // OR
Scope scope = TracingContextUtils.currentContextWithSpan(DefaultSpan.create(spanContext));

But perhaps that's the only important case we need to support. I see two alternatives:

  1. Keep a method somewhere to create empty Spans out of SpanContext values (as it's currently the case with DefaultSpan.create()), or

  2. Add TracingContextUtils method overloads taking a SpanContext instead of Span (which internally would use a DefaultSpan anyway):

public static Scope currentContextWithSpanContext(SpanContext spanContext) {
  return currentContextWithSpan(DefaultSpan.create(spanContext));
}

@yurishkuro
Copy link
Member Author

This sounds like a private contract between the SDK Tracer and the base Propagator. It could be all encapsulated in the base propagator, with Tracer having no knowledge of how the span/spancontext are stored in the Context.

@bogdandrutu
Copy link
Member

@yurishkuro there are two use-cases:

  1. We use the same instance instead of duplicating code in the SDK if the sampling decision is to not sample when creating a Span. I would not duplicate that code, but we can do it.
  2. We use it in the propagator as @carlosalberto described.

@yurishkuro
Copy link
Member Author

@bogdandrutu

  1. is an implementation detail that does not require this class in the API
  2. is also an implementation detail of the propagator

Just recently I saw several questions in OpenTracing about "how can I create a NoopSpan", "why my NoopSpan is being rejected", etc. - having API concerts like DefaultSpan invites these questions.

@ghost
Copy link

ghost commented Jun 18, 2020

Drive by comment, we're using this library and interoperating with it and having the following would help:

Add TracingContextUtils method overloads taking a SpanContext instead of Span (which internally would use a DefaultSpan anyway):

@carlosalberto
Copy link
Contributor

Closing as now we have this as PropagatedSpan in the Specification.

@jkwatson
Copy link
Contributor

This will be resolved by #1704, so yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p2 Medium priority issues and bugs. release:required-for-ga Required for 1.0 GA release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants