Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Do not create the new spans from context if there is no parent span #211

Open
demdxx opened this issue Mar 17, 2019 · 2 comments
Open

Do not create the new spans from context if there is no parent span #211

demdxx opened this issue Mar 17, 2019 · 2 comments

Comments

@demdxx
Copy link

demdxx commented Mar 17, 2019

Use Case

Not all requests need to trace, and for now, you have to mark these requests somehow to avoid new spans creation. Even if those spans will be skipped with the sampler.

Proposal

No need to create the new spans from context if there is no parent span.

func StartSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context) {
	return startSpanFromContextWithTracer(ctx, GlobalTracer(), operationName, opts...)
}

Operation of the creation of root span is always explicit and made in middleware tracer.StartSpan(operationName, opts...) with the tracer object. And I await that if no parent in the context then it means that we don't have to trace it at all.

Besides this will allow not to use GlobalTracer() at all because we could be sure that it will be at the context in any case, and the global tracker could be completely removed as redundant.

Questions

  • What could be a reason to use StartSpanFromContext to create the root span?
  • Can we remove the * GlobalTracer* "singletons"? If it will really need to someone he can define it in his own module.
@demdxx demdxx changed the title No create the new spans from context if there is no parent span Do not create the new spans from context if there is no parent span Mar 17, 2019
@yurishkuro
Copy link
Member

See related discussion in #143

@yurishkuro
Copy link
Member

The Questions section seems unrelated to the main topic of this issue.

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

No branches or pull requests

2 participants