Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.
This repository was 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

@demdxx

Description

@demdxx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions